
declare i32 @printf(i8*, ...)

@.str_nl = private constant [2 x i8] c"\0A\00"
@.str_star = private constant [2 x i8] c"*\00"
@.str_space = private constant [2 x i8] c" \00"

define void @new_line() #0 {
  %t0 = getelementptr [2 x i8], [2 x i8]* @.str_nl, i32 0, i32 0
  %1 = call i32 (i8*, ...) @printf(i8* %t0)
  ret void
}

define void @print_star() #0 {
  %t0 = getelementptr [2 x i8], [2 x i8]* @.str_star, i32 0, i32 0
  %1 = call i32 (i8*, ...) @printf(i8* %t0)
  ret void
}

define void @print_space() #0 {
  %t0 = getelementptr [2 x i8], [2 x i8]* @.str_space, i32 0, i32 0
  %1 = call i32 (i8*, ...) @printf(i8* %t0)
  ret void
}

define void @skip() #0 {
  ret void
}

@.str_int = private constant [3 x i8] c"%d\00"

define void @print_int(i32 %x) {
   %t0 = getelementptr [3 x i8], [3 x i8]* @.str_int, i32 0, i32 0
   call i32 (i8*, ...) @printf(i8* %t0, i32 %x) 
   ret void
}

@.str_char = private constant [3 x i8] c"%c\00"

define void @print_char(i32 %x) {
   %t0 = getelementptr [3 x i8], [3 x i8]* @.str_char, i32 0, i32 0
   call i32 (i8*, ...) @printf(i8* %t0, i32 %x) 
   ret void
}

; END OF BUILD-IN FUNCTIONS (prelude)

@Max = global i32 10

define i32 @sqr (i32 %x) {
   %tmp_20 = mul i32  %x, %x
   ret i32 %tmp_20
}

define void @all (i32 %n) {
   %tmp_22 = load i32, i32* @Max
   %tmp_21 = icmp sle i32  %n, %tmp_22
   br i1 %tmp_21, label %if_branch_29, label %else_branch_30

if_branch_29:
   %tmp_23 = call i32 @sqr (i32 %n)
   call void @print_int (i32 %tmp_23)
   call void @new_line ()
   %tmp_26 = add i32  %n, 1
   call void @all (i32 %tmp_26)
   ret void

else_branch_30:
   call void @skip ()
   ret void
}

define i32 @main() {
   call void @all (i32 0)
   ret i32 0
}

