Created
August 21, 2013 00:30
-
-
Save primenumber/6289082 to your computer and use it in GitHub Desktop.
peryaudo~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'runtime.ll' | |
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-macosx10.8.0" | |
%struct.String = type { i32, i32, i8* } | |
@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 | |
@.str1 = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 | |
; Function Attrs: nounwind ssp uwtable | |
define i32 @main(i32 %argc, i8** %argv) #0 { | |
%1 = alloca i32, align 4 | |
%2 = alloca i32, align 4 | |
%3 = alloca i8**, align 8 | |
store i32 0, i32* %1 | |
store i32 %argc, i32* %2, align 4 | |
store i8** %argv, i8*** %3, align 8 | |
call void (...)* @PeryanMain() | |
ret i32 0 | |
} | |
declare void @PeryanMain(...) | |
; Function Attrs: nounwind ssp uwtable | |
define void @printNum(i32 %num) #0 { | |
%1 = alloca i32, align 4 | |
store i32 %num, i32* %1, align 4 | |
%2 = load i32* %1, align 4 | |
%3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %2) | |
ret void | |
} | |
declare i32 @printf(i8*, ...) | |
; Function Attrs: nounwind ssp uwtable | |
define { i64, i8* } @PRStringConstructor(i8* %cStr) #0 { | |
%1 = alloca %struct.String, align 8 | |
%2 = alloca i8*, align 8 | |
%res = alloca %struct.String, align 8 | |
store i8* %cStr, i8** %2, align 8 | |
%3 = load i8** %2, align 8 | |
%4 = call i64 @strlen(i8* %3) | |
%5 = trunc i64 %4 to i32 | |
%6 = getelementptr inbounds %struct.String* %res, i32 0, i32 0 | |
store i32 %5, i32* %6, align 4 | |
%7 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
store i32 1024, i32* %7, align 4 | |
br label %8 | |
; <label>:8 ; preds = %15, %0 | |
%9 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
%10 = load i32* %9, align 4 | |
%11 = getelementptr inbounds %struct.String* %res, i32 0, i32 0 | |
%12 = load i32* %11, align 4 | |
%13 = add nsw i32 %12, 1 | |
%14 = icmp slt i32 %10, %13 | |
br i1 %14, label %15, label %19 | |
; <label>:15 ; preds = %8 | |
%16 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
%17 = load i32* %16, align 4 | |
%18 = mul nsw i32 %17, 2 | |
store i32 %18, i32* %16, align 4 | |
br label %8 | |
; <label>:19 ; preds = %8 | |
%20 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
%21 = load i32* %20, align 4 | |
%22 = sext i32 %21 to i64 | |
%23 = call i8* @malloc(i64 %22) | |
%24 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
store i8* %23, i8** %24, align 8 | |
%25 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%26 = load i8** %25, align 8 | |
%27 = call i64 @llvm.objectsize.i64(i8* %26, i1 false) | |
%28 = icmp ne i64 %27, -1 | |
br i1 %28, label %29, label %37 | |
; <label>:29 ; preds = %19 | |
%30 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%31 = load i8** %30, align 8 | |
%32 = load i8** %2, align 8 | |
%33 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%34 = load i8** %33, align 8 | |
%35 = call i64 @llvm.objectsize.i64(i8* %34, i1 false) | |
%36 = call i8* @__strcpy_chk(i8* %31, i8* %32, i64 %35) #2 | |
br label %42 | |
; <label>:37 ; preds = %19 | |
%38 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%39 = load i8** %38, align 8 | |
%40 = load i8** %2, align 8 | |
%41 = call i8* @__inline_strcpy_chk(i8* %39, i8* %40) | |
br label %42 | |
; <label>:42 ; preds = %37, %29 | |
%43 = phi i8* [ %36, %29 ], [ %41, %37 ] | |
%44 = bitcast %struct.String* %1 to i8* | |
%45 = bitcast %struct.String* %res to i8* | |
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %44, i8* %45, i64 16, i32 8, i1 false) | |
%46 = bitcast %struct.String* %1 to { i64, i8* }* | |
%47 = load { i64, i8* }* %46, align 1 | |
ret { i64, i8* } %47 | |
} | |
declare i64 @strlen(i8*) | |
declare i8* @malloc(i64) | |
; Function Attrs: nounwind readnone | |
declare i64 @llvm.objectsize.i64(i8*, i1) #1 | |
; Function Attrs: nounwind | |
declare i8* @__strcpy_chk(i8*, i8*, i64) #2 | |
; Function Attrs: inlinehint nounwind ssp uwtable | |
define internal i8* @__inline_strcpy_chk(i8* noalias %__dest, i8* noalias %__src) #3 { | |
%1 = alloca i8*, align 8 | |
%2 = alloca i8*, align 8 | |
store i8* %__dest, i8** %1, align 8 | |
store i8* %__src, i8** %2, align 8 | |
%3 = load i8** %1, align 8 | |
%4 = load i8** %2, align 8 | |
%5 = load i8** %1, align 8 | |
%6 = call i64 @llvm.objectsize.i64(i8* %5, i1 false) | |
%7 = call i8* @__strcpy_chk(i8* %3, i8* %4, i64 %6) #2 | |
ret i8* %7 | |
} | |
; Function Attrs: nounwind | |
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #2 | |
; Function Attrs: nounwind ssp uwtable | |
define { i64, i8* } @PRStringConcatenate(i64 %lhs.coerce0, i8* %lhs.coerce1, i64 %rhs.coerce0, i8* %rhs.coerce1) #0 { | |
%1 = alloca %struct.String, align 8 | |
%lhs = alloca %struct.String, align 8 | |
%rhs = alloca %struct.String, align 8 | |
%res = alloca %struct.String, align 8 | |
%2 = bitcast %struct.String* %lhs to { i64, i8* }* | |
%3 = getelementptr { i64, i8* }* %2, i32 0, i32 0 | |
store i64 %lhs.coerce0, i64* %3 | |
%4 = getelementptr { i64, i8* }* %2, i32 0, i32 1 | |
store i8* %lhs.coerce1, i8** %4 | |
%5 = bitcast %struct.String* %rhs to { i64, i8* }* | |
%6 = getelementptr { i64, i8* }* %5, i32 0, i32 0 | |
store i64 %rhs.coerce0, i64* %6 | |
%7 = getelementptr { i64, i8* }* %5, i32 0, i32 1 | |
store i8* %rhs.coerce1, i8** %7 | |
%8 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 0 | |
%9 = load i32* %8, align 4 | |
%10 = getelementptr inbounds %struct.String* %rhs, i32 0, i32 0 | |
%11 = load i32* %10, align 4 | |
%12 = add nsw i32 %9, %11 | |
%13 = getelementptr inbounds %struct.String* %res, i32 0, i32 0 | |
store i32 %12, i32* %13, align 4 | |
%14 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
store i32 1024, i32* %14, align 4 | |
br label %15 | |
; <label>:15 ; preds = %22, %0 | |
%16 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
%17 = load i32* %16, align 4 | |
%18 = getelementptr inbounds %struct.String* %res, i32 0, i32 0 | |
%19 = load i32* %18, align 4 | |
%20 = add nsw i32 %19, 1 | |
%21 = icmp slt i32 %17, %20 | |
br i1 %21, label %22, label %26 | |
; <label>:22 ; preds = %15 | |
%23 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
%24 = load i32* %23, align 4 | |
%25 = mul nsw i32 %24, 2 | |
store i32 %25, i32* %23, align 4 | |
br label %15 | |
; <label>:26 ; preds = %15 | |
%27 = getelementptr inbounds %struct.String* %res, i32 0, i32 1 | |
%28 = load i32* %27, align 4 | |
%29 = sext i32 %28 to i64 | |
%30 = call i8* @malloc(i64 %29) | |
%31 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
store i8* %30, i8** %31, align 8 | |
%32 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%33 = load i8** %32, align 8 | |
%34 = call i64 @llvm.objectsize.i64(i8* %33, i1 false) | |
%35 = icmp ne i64 %34, -1 | |
br i1 %35, label %36, label %45 | |
; <label>:36 ; preds = %26 | |
%37 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%38 = load i8** %37, align 8 | |
%39 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 2 | |
%40 = load i8** %39, align 8 | |
%41 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%42 = load i8** %41, align 8 | |
%43 = call i64 @llvm.objectsize.i64(i8* %42, i1 false) | |
%44 = call i8* @__strcpy_chk(i8* %38, i8* %40, i64 %43) #2 | |
br label %51 | |
; <label>:45 ; preds = %26 | |
%46 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%47 = load i8** %46, align 8 | |
%48 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 2 | |
%49 = load i8** %48, align 8 | |
%50 = call i8* @__inline_strcpy_chk(i8* %47, i8* %49) | |
br label %51 | |
; <label>:51 ; preds = %45, %36 | |
%52 = phi i8* [ %44, %36 ], [ %50, %45 ] | |
%53 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%54 = load i8** %53, align 8 | |
%55 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 0 | |
%56 = load i32* %55, align 4 | |
%57 = sext i32 %56 to i64 | |
%58 = getelementptr inbounds i8* %54, i64 %57 | |
%59 = call i64 @llvm.objectsize.i64(i8* %58, i1 false) | |
%60 = icmp ne i64 %59, -1 | |
br i1 %60, label %61, label %78 | |
; <label>:61 ; preds = %51 | |
%62 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%63 = load i8** %62, align 8 | |
%64 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 0 | |
%65 = load i32* %64, align 4 | |
%66 = sext i32 %65 to i64 | |
%67 = getelementptr inbounds i8* %63, i64 %66 | |
%68 = getelementptr inbounds %struct.String* %rhs, i32 0, i32 2 | |
%69 = load i8** %68, align 8 | |
%70 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%71 = load i8** %70, align 8 | |
%72 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 0 | |
%73 = load i32* %72, align 4 | |
%74 = sext i32 %73 to i64 | |
%75 = getelementptr inbounds i8* %71, i64 %74 | |
%76 = call i64 @llvm.objectsize.i64(i8* %75, i1 false) | |
%77 = call i8* @__strcpy_chk(i8* %67, i8* %69, i64 %76) #2 | |
br label %88 | |
; <label>:78 ; preds = %51 | |
%79 = getelementptr inbounds %struct.String* %res, i32 0, i32 2 | |
%80 = load i8** %79, align 8 | |
%81 = getelementptr inbounds %struct.String* %lhs, i32 0, i32 0 | |
%82 = load i32* %81, align 4 | |
%83 = sext i32 %82 to i64 | |
%84 = getelementptr inbounds i8* %80, i64 %83 | |
%85 = getelementptr inbounds %struct.String* %rhs, i32 0, i32 2 | |
%86 = load i8** %85, align 8 | |
%87 = call i8* @__inline_strcpy_chk(i8* %84, i8* %86) | |
br label %88 | |
; <label>:88 ; preds = %78, %61 | |
%89 = phi i8* [ %77, %61 ], [ %87, %78 ] | |
%90 = bitcast %struct.String* %1 to i8* | |
%91 = bitcast %struct.String* %res to i8* | |
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %90, i8* %91, i64 16, i32 8, i1 false) | |
%92 = bitcast %struct.String* %1 to { i64, i8* }* | |
%93 = load { i64, i8* }* %92, align 1 | |
ret { i64, i8* } %93 | |
} | |
; Function Attrs: nounwind ssp uwtable | |
define void @PRStringDestructor(i64 %str.coerce0, i8* %str.coerce1) #0 { | |
%str = alloca %struct.String, align 8 | |
%1 = bitcast %struct.String* %str to { i64, i8* }* | |
%2 = getelementptr { i64, i8* }* %1, i32 0, i32 0 | |
store i64 %str.coerce0, i64* %2 | |
%3 = getelementptr { i64, i8* }* %1, i32 0, i32 1 | |
store i8* %str.coerce1, i8** %3 | |
%4 = getelementptr inbounds %struct.String* %str, i32 0, i32 2 | |
%5 = load i8** %4, align 8 | |
call void @free(i8* %5) | |
ret void | |
} | |
declare void @free(i8*) | |
; Function Attrs: nounwind ssp uwtable | |
define void @mes(i64 %str.coerce0, i8* %str.coerce1) #0 { | |
%str = alloca %struct.String, align 8 | |
%1 = bitcast %struct.String* %str to { i64, i8* }* | |
%2 = getelementptr { i64, i8* }* %1, i32 0, i32 0 | |
store i64 %str.coerce0, i64* %2 | |
%3 = getelementptr { i64, i8* }* %1, i32 0, i32 1 | |
store i8* %str.coerce1, i8** %3 | |
%4 = getelementptr inbounds %struct.String* %str, i32 0, i32 2 | |
%5 = load i8** %4, align 8 | |
%6 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str1, i32 0, i32 0), i8* %5) | |
ret void | |
} | |
attributes #0 = { nounwind ssp uwtable } | |
attributes #1 = { nounwind readnone } | |
attributes #2 = { nounwind } | |
attributes #3 = { inlinehint nounwind ssp uwtable } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment