; LLVM IR from brewlin/garbage-collect :: compact-lisp2 (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 [78 x i8], align 1
@__PRETTY_FUNCTION__.test_add_root_gc = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = 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
  %5 = alloca ptr, align 8
  call void @gc_init(i64 noundef 192)
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %6 = call ptr @gc_malloc(i64 noundef 16)
  store ptr %6, ptr %1, align 8, !tbaa !5
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.t, ptr %7, i32 0, i32 0
  store i32 11, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %0
  br label %13

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

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

29:                                               ; preds = %13
  br label %31

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

31:                                               ; preds = %29
  %32 = load ptr, ptr %1, 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, 11
  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 49, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

38:                                               ; preds = %36
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.t, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !9
  %42 = icmp eq i32 %41, 12
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  br label %45

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

45:                                               ; preds = %43
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.t, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = icmp eq i32 %48, 13
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  br label %52

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

52:                                               ; preds = %50
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.t, ptr %53, i32 0, i32 1
  store ptr null, ptr %54, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %55 = call ptr @gc_malloc(i64 noundef 16)
  store ptr %55, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %1, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.t, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !9
  %59 = icmp eq i32 %58, 11
  br i1 %59, label %60, label %61

60:                                               ; preds = %52
  br label %62

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

62:                                               ; preds = %60
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.t, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !9
  %66 = icmp eq i32 %65, 12
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  br label %69

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

69:                                               ; preds = %67
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.t, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 8, !tbaa !9
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %69
  br label %76

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

76:                                               ; preds = %74
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %80

79:                                               ; preds = %76
  br label %81

80:                                               ; preds = %76
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 60, ptr noundef @__PRETTY_FUNCTION__.test_add_root_gc) #5
  unreachable

81:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  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 [78 x i8], align 1
@__PRETTY_FUNCTION__.test_add_root_gc = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = 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 192) #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 = call ptr @gc_malloc(i64 noundef 16) #4
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %3, ptr %6, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %4, ptr %7, align 8, !tbaa !12
  store i32 13, ptr %4, align 8, !tbaa !9
  %8 = call ptr @gc_malloc(i64 noundef 16) #4
  %9 = icmp eq ptr %8, null
  br i1 %9, label %11, label %10

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

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

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

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

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

20:                                               ; preds = %16
  %21 = load i32, ptr %4, align 8, !tbaa !9
  %22 = icmp eq i32 %21, 13
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %20
  store ptr null, ptr %7, align 8, !tbaa !12
  %25 = call ptr @gc_malloc(i64 noundef 16) #4
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = icmp eq i32 %27, 11
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %24
  %31 = load i32, ptr %3, align 8, !tbaa !9
  %32 = icmp eq i32 %31, 12
  br i1 %32, label %34, label %33

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

34:                                               ; preds = %30
  %35 = load i32, ptr %4, align 8, !tbaa !9
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %34
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %39, label %40

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

40:                                               ; preds = %38
  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