678
|
1 |
@.str = private constant [4 x i8] c"%d\0A\00"
|
|
2 |
|
|
3 |
declare i32 @printf(i8*, ...)
|
|
4 |
|
|
5 |
; prints out an integer
|
|
6 |
define i32 @printInt(i32 %x) {
|
|
7 |
%t0 = getelementptr [4 x i8], [4 x i8]* @.str, i32 0, i32 0
|
|
8 |
call i32 (i8*, ...) @printf(i8* %t0, i32 %x)
|
|
9 |
ret i32 %x
|
|
10 |
}
|
|
11 |
|
|
12 |
; square function
|
|
13 |
define i32 @sqr(i32 %x) {
|
|
14 |
%tmp = mul i32 %x, %x
|
|
15 |
ret i32 %tmp
|
|
16 |
}
|
|
17 |
|
|
18 |
; main
|
|
19 |
define i32 @main() {
|
|
20 |
%1 = call i32 @sqr(i32 5)
|
701
|
21 |
%2 = call i32 @printInt(i32 %1)
|
678
|
22 |
ret i32 %1
|
|
23 |
}
|
|
24 |
|