; ModuleID = 'LFortran'
source_filename = "LFortran"

@0 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@1 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1
@2 = private unnamed_addr constant [11 x i8] c"ERROR STOP\00", align 1
@3 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@4 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1

define i32 @main(i32 %0, i8** %1) {
.entry:
  %call_arg_value3 = alloca i32, align 4
  %call_arg_value = alloca i32, align 4
  %i = alloca i32, align 4
  %s = alloca i32, align 4
  call void @_lpython_call_initial_functions(i32 %0, i8** %1)
  %i1 = alloca i32, align 4
  %s2 = alloca i32, align 4
  %x = alloca [10 x i32], align 4
  store i32 0, i32* %i1, align 4
  br label %loop.head

loop.head:                                        ; preds = %loop.body, %.entry
  %2 = load i32, i32* %i1, align 4
  %3 = add i32 %2, 1
  %4 = icmp sle i32 %3, 10
  br i1 %4, label %loop.body, label %loop.end

loop.body:                                        ; preds = %loop.head
  %5 = load i32, i32* %i1, align 4
  %6 = add i32 %5, 1
  store i32 %6, i32* %i1, align 4
  %7 = load i32, i32* %i1, align 4
  %8 = sub i32 %7, 1
  %9 = mul i32 1, %8
  %10 = add i32 0, %9
  %11 = getelementptr [10 x i32], [10 x i32]* %x, i32 0, i32 %10
  %12 = load i32, i32* %i1, align 4
  store i32 %12, i32* %11, align 4
  br label %loop.head

loop.end:                                         ; preds = %loop.head
  %13 = getelementptr [10 x i32], [10 x i32]* %x, i32 0, i32 0
  store i32 1, i32* %call_arg_value, align 4
  store i32 10, i32* %call_arg_value3, align 4
  %14 = call i32 @mysum_integer____0(i32* %13, i32* %call_arg_value, i32* %call_arg_value3)
  store i32 %14, i32* %s2, align 4
  %15 = load i32, i32* %s2, align 4
  %16 = sext i32 %15 to i64
  %17 = call i8* (i32, i8*, ...) @_lcompilers_string_format_fortran(i32 2, i8* null, i32 2, i64 %16)
  call void (i8*, ...) @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0))
  %18 = load i32, i32* %s2, align 4
  %19 = icmp ne i32 %18, 55
  br i1 %19, label %then, label %else

then:                                             ; preds = %loop.end
  call void (i8*, ...) @_lcompilers_print_error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @4, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0))
  call void @exit(i32 1)
  br label %ifcont

else:                                             ; preds = %loop.end
  br label %ifcont

ifcont:                                           ; preds = %else, %then
  call void @_lpython_free_argv()
  br label %return

return:                                           ; preds = %ifcont
  ret i32 0
}

define i32 @mysum_integer____0(i32* %a, i32* %__1a, i32* %__2a) {
.entry:
  %i = alloca i32, align 4
  %r = alloca i32, align 4
  store i32 0, i32* %r, align 4
  store i32 0, i32* %i, align 4
  br label %loop.head

loop.head:                                        ; preds = %loop.body, %.entry
  %0 = load i32, i32* %i, align 4
  %1 = add i32 %0, 1
  %2 = load i32, i32* %__2a, align 4
  %3 = mul i32 1, %2
  %4 = icmp sle i32 %1, %3
  br i1 %4, label %loop.body, label %loop.end

loop.body:                                        ; preds = %loop.head
  %5 = load i32, i32* %i, align 4
  %6 = add i32 %5, 1
  store i32 %6, i32* %i, align 4
  %7 = load i32, i32* %r, align 4
  %8 = load i32, i32* %i, align 4
  %9 = load i32, i32* %__1a, align 4
  %10 = load i32, i32* %__2a, align 4
  %11 = sub i32 %8, %9
  %12 = mul i32 1, %11
  %13 = add i32 0, %12
  %14 = mul i32 1, %10
  %15 = getelementptr inbounds i32, i32* %a, i32 %13
  %16 = load i32, i32* %15, align 4
  %17 = add i32 %7, %16
  store i32 %17, i32* %r, align 4
  br label %loop.head

loop.end:                                         ; preds = %loop.head
  br label %return

return:                                           ; preds = %loop.end
  %18 = load i32, i32* %r, align 4
  ret i32 %18
}

declare void @_lpython_call_initial_functions(i32, i8**)

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

declare void @_lfortran_printf(i8*, ...)

declare void @_lcompilers_print_error(i8*, ...)

declare void @exit(i32)

declare void @_lpython_free_argv()
