You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1021 B
38 lines
1021 B
; ModuleID = 'asdf'
|
|
|
|
declare i32 @getchar()
|
|
|
|
declare i32 @putchar(i32)
|
|
|
|
define i32 @main() {
|
|
%malloccall = tail call i8* @malloc(i32 mul (i32 ptrtoint (i8* getelementptr (i8* null, i32 1) to i32), i32 100))
|
|
call void @llvm.memset.p0i8.i32(i8* %malloccall, i8 0, i32 100, i32 1, i1 false)
|
|
%1 = getelementptr i8* %malloccall, i32 50
|
|
%2 = load i8* %1
|
|
%3 = add i8 %2, 1
|
|
store i8 %3, i8* %1
|
|
%4 = load i8* %1
|
|
%5 = icmp ne i8 %4, 0
|
|
br i1 %5, label %6, label %14
|
|
|
|
; <label>:6 ; preds = %6, %0
|
|
%7 = load i8* %1
|
|
%8 = sext i8 %7 to i32
|
|
%9 = call i32 @putchar(i32 %8)
|
|
%10 = load i8* %1
|
|
%11 = add i8 %10, 1
|
|
store i8 %11, i8* %1
|
|
%12 = load i8* %1
|
|
%13 = icmp ne i8 %12, 0
|
|
br i1 %13, label %6, label %14
|
|
|
|
; <label>:14 ; preds = %6, %0
|
|
tail call void @free(i8* %malloccall)
|
|
ret i32 0
|
|
}
|
|
|
|
declare noalias i8* @malloc(i32)
|
|
|
|
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
|
|
|
|
declare void @free(i8*)
|
|
|