; LLVM IR from asllop/AppOS :: app (main_testmem)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@termID = external hidden global i32, align 4
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @console_put_string(i8 noundef zeroext, ptr noundef, i32 noundef, i32 noundef) #1

declare ptr @core_malloc(i64 noundef) #1

declare ptr @itoa(i64 noundef, ptr noundef, i32 noundef) #1

declare void @core_free(ptr noundef) #1

declare void @core_fatal(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @cnt0_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt1_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt2_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt3_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt4_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt5_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt6_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt7_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt8_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt9_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt10_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt11_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @showUsedMem() #2

; Function Attrs: nounwind uwtable
define dso_local void @main(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca [20 x i8], align 16
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 20, ptr %5) #3
  %11 = call i32 @term_serial_init(i8 noundef zeroext 0)
  store i32 %11, ptr @termID, align 4, !tbaa !5
  %12 = load i32, ptr @termID, align 4, !tbaa !5
  %13 = icmp eq i32 %12, -1
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  call void @core_fatal(ptr noundef @.str.6)
  br label %15

15:                                               ; preds = %14, %2
  call void @console_put_data(i32 noundef 27, i8 noundef signext -80, i32 noundef 2000, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %16 = call ptr @core_malloc(i64 noundef 70000)
  store ptr %16, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !9
  %18 = call i64 @core_size(ptr noundef %17)
  store i64 %18, ptr %7, align 8, !tbaa !11
  call void @core_log(ptr noundef @.str.7)
  %19 = load i64, ptr %7, align 8, !tbaa !11
  %20 = getelementptr inbounds [20 x i8], ptr %5, i64 0, i64 0
  %21 = call ptr @itoa(i64 noundef %19, ptr noundef %20, i32 noundef 10)
  call void @core_log(ptr noundef %21)
  call void @core_log(ptr noundef @.str.8)
  %22 = call i32 @core_create(ptr noundef @cnt0_task, i32 noundef 0, i64 noundef 1024)
  %23 = call i32 @core_create(ptr noundef @cnt1_task, i32 noundef 5, i64 noundef 1024)
  %24 = call i32 @core_create(ptr noundef @cnt2_task, i32 noundef 10, i64 noundef 1024)
  %25 = call i32 @core_create(ptr noundef @cnt3_task, i32 noundef 20, i64 noundef 1024)
  %26 = call i32 @core_create(ptr noundef @cnt4_task, i32 noundef 0, i64 noundef 1024)
  %27 = call i32 @core_create(ptr noundef @cnt5_task, i32 noundef 5, i64 noundef 1024)
  %28 = call i32 @core_create(ptr noundef @cnt6_task, i32 noundef 10, i64 noundef 1024)
  %29 = call i32 @core_create(ptr noundef @cnt7_task, i32 noundef 20, i64 noundef 1024)
  %30 = call i32 @core_create(ptr noundef @cnt8_task, i32 noundef 0, i64 noundef 1024)
  %31 = call i32 @core_create(ptr noundef @cnt9_task, i32 noundef 5, i64 noundef 1024)
  %32 = call i32 @core_create(ptr noundef @cnt10_task, i32 noundef 10, i64 noundef 1024)
  %33 = call i32 @core_create(ptr noundef @cnt11_task, i32 noundef 20, i64 noundef 1024)
  call void @console_put_string(i8 noundef zeroext 79, ptr noundef @.str.9, i32 noundef 34, i32 noundef 1)
  %34 = load ptr, ptr %6, align 8, !tbaa !9
  call void @core_free(ptr noundef %34)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 5, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %53, %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %36 = call ptr @core_malloc(i64 noundef 5000)
  store ptr %36, ptr %10, align 8, !tbaa !9
  %37 = load i32, ptr %9, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = load i32, ptr %8, align 4, !tbaa !5
  call void @console_put_string(i8 noundef zeroext 79, ptr noundef @.str.1, i32 noundef 2, i32 noundef %40)
  br label %41

41:                                               ; preds = %39, %35
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds [20 x i8], ptr %5, i64 0, i64 0
  %45 = call ptr @itoa(i64 noundef %43, ptr noundef %44, i32 noundef 10)
  %46 = load i32, ptr %8, align 4, !tbaa !5
  call void @console_put_string(i8 noundef zeroext 79, ptr noundef %45, i32 noundef 2, i32 noundef %46)
  call void @showUsedMem()
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %51

49:                                               ; preds = %41
  %50 = load ptr, ptr %10, align 8, !tbaa !9
  call void @core_free(ptr noundef %50)
  br label %52

51:                                               ; preds = %41
  call void @core_fatal(ptr noundef @.str.10)
  br label %52

52:                                               ; preds = %51, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = add i32 %54, 1
  store i32 %55, ptr %9, align 4, !tbaa !5
  br label %35
}

declare i32 @term_serial_init(i8 noundef zeroext) #1

declare void @console_put_data(i32 noundef, i8 noundef signext, i32 noundef, i32 noundef) #1

declare i64 @core_size(ptr noundef) #1

declare void @core_log(ptr noundef) #1

declare i32 @core_create(ptr noundef, i32 noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@termID = external hidden local_unnamed_addr global i32, align 4
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @console_put_string(i8 noundef zeroext, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @core_malloc(i64 noundef) local_unnamed_addr #1

declare ptr @itoa(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @core_free(ptr noundef) local_unnamed_addr #1

declare void @core_fatal(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @cnt0_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt1_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt2_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt3_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt4_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt5_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt6_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt7_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt8_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt9_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt10_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @cnt11_task() #2

; Function Attrs: nounwind uwtable
declare dso_local void @showUsedMem() local_unnamed_addr #2

; Function Attrs: noreturn nounwind uwtable
define dso_local void @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #3 {
  %3 = alloca [20 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %3) #4
  %4 = tail call i32 @term_serial_init(i8 noundef zeroext 0) #4
  store i32 %4, ptr @termID, align 4, !tbaa !5
  %5 = icmp eq i32 %4, -1
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @core_fatal(ptr noundef nonnull @.str.6) #4
  br label %7

7:                                                ; preds = %6, %2
  tail call void @console_put_data(i32 noundef 27, i8 noundef signext -80, i32 noundef 2000, i32 noundef 0) #4
  %8 = tail call ptr @core_malloc(i64 noundef 70000) #4
  %9 = tail call i64 @core_size(ptr noundef %8) #4
  tail call void @core_log(ptr noundef nonnull @.str.7) #4
  %10 = call ptr @itoa(i64 noundef %9, ptr noundef nonnull %3, i32 noundef 10) #4
  call void @core_log(ptr noundef %10) #4
  call void @core_log(ptr noundef nonnull @.str.8) #4
  %11 = call i32 @core_create(ptr noundef nonnull @cnt0_task, i32 noundef 0, i64 noundef 1024) #4
  %12 = call i32 @core_create(ptr noundef nonnull @cnt1_task, i32 noundef 5, i64 noundef 1024) #4
  %13 = call i32 @core_create(ptr noundef nonnull @cnt2_task, i32 noundef 10, i64 noundef 1024) #4
  %14 = call i32 @core_create(ptr noundef nonnull @cnt3_task, i32 noundef 20, i64 noundef 1024) #4
  %15 = call i32 @core_create(ptr noundef nonnull @cnt4_task, i32 noundef 0, i64 noundef 1024) #4
  %16 = call i32 @core_create(ptr noundef nonnull @cnt5_task, i32 noundef 5, i64 noundef 1024) #4
  %17 = call i32 @core_create(ptr noundef nonnull @cnt6_task, i32 noundef 10, i64 noundef 1024) #4
  %18 = call i32 @core_create(ptr noundef nonnull @cnt7_task, i32 noundef 20, i64 noundef 1024) #4
  %19 = call i32 @core_create(ptr noundef nonnull @cnt8_task, i32 noundef 0, i64 noundef 1024) #4
  %20 = call i32 @core_create(ptr noundef nonnull @cnt9_task, i32 noundef 5, i64 noundef 1024) #4
  %21 = call i32 @core_create(ptr noundef nonnull @cnt10_task, i32 noundef 10, i64 noundef 1024) #4
  %22 = call i32 @core_create(ptr noundef nonnull @cnt11_task, i32 noundef 20, i64 noundef 1024) #4
  call void @console_put_string(i8 noundef zeroext 79, ptr noundef nonnull @.str.9, i32 noundef 34, i32 noundef 1) #4
  call void @core_free(ptr noundef %8) #4
  br label %23

23:                                               ; preds = %32, %7
  %.0 = phi i32 [ 0, %7 ], [ %33, %32 ]
  %24 = call ptr @core_malloc(i64 noundef 5000) #4
  %25 = icmp eq i32 %.0, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  call void @console_put_string(i8 noundef zeroext 79, ptr noundef nonnull @.str.1, i32 noundef 2, i32 noundef 5) #4
  br label %27

27:                                               ; preds = %26, %23
  %28 = zext i32 %.0 to i64
  %29 = call ptr @itoa(i64 noundef %28, ptr noundef nonnull %3, i32 noundef 10) #4
  call void @console_put_string(i8 noundef zeroext 79, ptr noundef %29, i32 noundef 2, i32 noundef 5) #4
  call void @showUsedMem()
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %31, label %30

30:                                               ; preds = %27
  call void @core_free(ptr noundef nonnull %24) #4
  br label %32

31:                                               ; preds = %27
  call void @core_fatal(ptr noundef nonnull @.str.10) #4
  br label %32

32:                                               ; preds = %31, %30
  %33 = add i32 %.0, 1
  br label %23
}

declare i32 @term_serial_init(i8 noundef zeroext) local_unnamed_addr #1

declare void @console_put_data(i32 noundef, i8 noundef signext, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i64 @core_size(ptr noundef) local_unnamed_addr #1

declare void @core_log(ptr noundef) local_unnamed_addr #1

declare i32 @core_create(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { noreturn nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass