; LLVM IR from brewlin/garbage-collect :: compact-two-finger (test)

; 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"

%struct.t = type { i32, ptr }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__.test_add_root_gc = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1

declare void @gc_init(i64 noundef) #0

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

declare ptr @gc_malloc(i64 noundef) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @test_add_root_gc() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @gc_init(i64 noundef 128)
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %5 = call ptr @gc_malloc(i64 noundef 16)
  store ptr %5, ptr %1, align 8, !tbaa !5
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.t, ptr %6, i32 0, i32 0
  store i32 11, ptr %7, align 8, !tbaa !9
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %0
  br label %12

11:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 34, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

12:                                               ; preds = %10
  call void @add_roots(ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %13 = call ptr @gc_malloc(i64 noundef 16)
  store ptr %13, ptr %2, align 8, !tbaa !5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.t, ptr %14, i32 0, i32 0
  store i32 12, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.t, ptr %17, i32 0, i32 1
  store ptr %16, ptr %18, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %19 = call ptr @gc_malloc(i64 noundef 16)
  store ptr %19, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %12
  br label %24

23:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 42, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.t, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = icmp eq i32 %27, 11
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  br label %31

30:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 43, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

31:                                               ; preds = %29
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.t, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = icmp eq i32 %34, 12
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  br label %38

37:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 44, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

38:                                               ; preds = %36
  %39 = load ptr, ptr %1, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.t, ptr %39, i32 0, i32 1
  store ptr null, ptr %40, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %41 = call ptr @gc_malloc(i64 noundef 16)
  store ptr %41, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %1, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.t, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !9
  %45 = icmp eq i32 %44, 11
  br i1 %45, label %46, label %47

46:                                               ; preds = %38
  br label %48

47:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 50, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

48:                                               ; preds = %46
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.t, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !9
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  br label %55

54:                                               ; preds = %48
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 51, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

55:                                               ; preds = %53
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  br label %60

59:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 52, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

60:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare void @add_roots(ptr noundef) #0

attributes #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 = { noreturn 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 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 }
attributes #5 = { noreturn 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"}
!9 = !{!10, !11, i64 0}
!10 = !{!"t", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}


; 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 [83 x i8], align 1
@__PRETTY_FUNCTION__.test_add_root_gc = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1

declare void @gc_init(i64 noundef) local_unnamed_addr #0

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

declare ptr @gc_malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local void @test_add_root_gc() local_unnamed_addr #3 {
  %1 = alloca ptr, align 8
  tail call void @gc_init(i64 noundef 128) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %2 = tail call ptr @gc_malloc(i64 noundef 16) #4
  store ptr %2, ptr %1, align 8, !tbaa !5
  store i32 11, ptr %2, align 8, !tbaa !9
  call void @add_roots(ptr noundef nonnull %1) #4
  %3 = call ptr @gc_malloc(i64 noundef 16) #4
  store i32 12, ptr %3, align 8, !tbaa !9
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %5, align 8, !tbaa !12
  %6 = call ptr @gc_malloc(i64 noundef 16) #4
  %7 = icmp eq ptr %6, null
  br i1 %7, label %9, label %8

8:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 42, ptr noundef nonnull @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

9:                                                ; preds = %0
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = icmp eq i32 %11, 11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 43, ptr noundef nonnull @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

14:                                               ; preds = %9
  %15 = load i32, ptr %3, align 8, !tbaa !9
  %16 = icmp eq i32 %15, 12
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 44, ptr noundef nonnull @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr null, ptr %19, align 8, !tbaa !12
  %20 = call ptr @gc_malloc(i64 noundef 16) #4
  %21 = load ptr, ptr %1, align 8, !tbaa !5
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp eq i32 %22, 11
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 50, ptr noundef nonnull @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

25:                                               ; preds = %18
  %26 = load i32, ptr %3, align 8, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 51, ptr noundef nonnull @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

29:                                               ; preds = %25
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %30, label %31

30:                                               ; preds = %29
  call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 52, ptr noundef nonnull @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

31:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret void
}

declare void @add_roots(ptr noundef) local_unnamed_addr #0

attributes #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 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 }
attributes #5 = { noreturn 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"}
!9 = !{!10, !11, i64 0}
!10 = !{!"t", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}


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