; LLVM IR from humz2k/sugaryc :: ext/bdwgc/tests (trace)

; 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 = external hidden unnamed_addr constant [59 x i8], align 1
@root = external dso_local global [10 x ptr], align 16
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @GC_init()
  %3 = call i32 @GC_get_find_leak()
  %4 = icmp ne i32 %3, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %0
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %7

7:                                                ; preds = %5, %0
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %16, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 10
  br i1 %10, label %11, label %19

11:                                               ; preds = %8
  %12 = call ptr @mktree(i32 noundef 12)
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [10 x ptr], ptr @root, i64 0, i64 %14
  store ptr %12, ptr %15, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !11

19:                                               ; preds = %8
  call void @GC_generate_random_backtrace()
  call void @GC_generate_random_backtrace()
  call void @GC_generate_random_backtrace()
  call void @GC_generate_random_backtrace()
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

declare void @GC_init() #2

declare i32 @GC_get_find_leak() #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @mktree(i32 noundef) #0

declare void @GC_generate_random_backtrace() #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 = external hidden unnamed_addr constant [59 x i8], align 1
@root = external dso_local local_unnamed_addr global [10 x ptr], align 16
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @GC_init() #3
  %1 = tail call i32 @GC_get_find_leak() #3
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %4, label %2

2:                                                ; preds = %0
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %4

4:                                                ; preds = %2, %0
  %5 = tail call ptr @mktree(i32 noundef 12)
  store ptr %5, ptr @root, align 16, !tbaa !5
  %6 = tail call ptr @mktree(i32 noundef 12)
  store ptr %6, ptr getelementptr inbounds (i8, ptr @root, i64 8), align 8, !tbaa !5
  %7 = tail call ptr @mktree(i32 noundef 12)
  store ptr %7, ptr getelementptr inbounds (i8, ptr @root, i64 16), align 16, !tbaa !5
  %8 = tail call ptr @mktree(i32 noundef 12)
  store ptr %8, ptr getelementptr inbounds (i8, ptr @root, i64 24), align 8, !tbaa !5
  %9 = tail call ptr @mktree(i32 noundef 12)
  store ptr %9, ptr getelementptr inbounds (i8, ptr @root, i64 32), align 16, !tbaa !5
  %10 = tail call ptr @mktree(i32 noundef 12)
  store ptr %10, ptr getelementptr inbounds (i8, ptr @root, i64 40), align 8, !tbaa !5
  %11 = tail call ptr @mktree(i32 noundef 12)
  store ptr %11, ptr getelementptr inbounds (i8, ptr @root, i64 48), align 16, !tbaa !5
  %12 = tail call ptr @mktree(i32 noundef 12)
  store ptr %12, ptr getelementptr inbounds (i8, ptr @root, i64 56), align 8, !tbaa !5
  %13 = tail call ptr @mktree(i32 noundef 12)
  store ptr %13, ptr getelementptr inbounds (i8, ptr @root, i64 64), align 16, !tbaa !5
  %14 = tail call ptr @mktree(i32 noundef 12)
  store ptr %14, ptr getelementptr inbounds (i8, ptr @root, i64 72), align 8, !tbaa !5
  tail call void @GC_generate_random_backtrace() #3
  tail call void @GC_generate_random_backtrace() #3
  tail call void @GC_generate_random_backtrace() #3
  tail call void @GC_generate_random_backtrace() #3
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  ret i32 0
}

declare void @GC_init() local_unnamed_addr #1

declare i32 @GC_get_find_leak() local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden ptr @mktree(i32 noundef) local_unnamed_addr #0

declare void @GC_generate_random_backtrace() local_unnamed_addr #1

attributes #0 = { 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 #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 = { nofree nounwind "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass