; LLVM IR from mguinhos/Collector :: src/lib.ll_collector (keep)

; 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.Collector = type { ptr, ptr, i64, ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local ptr @collector__new() #0

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

; 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 zeroext i1 @collector__keep(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %82

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  store i1 false, ptr %3, align 1
  br label %82

17:                                               ; preds = %13
  br label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %19, ptr %6, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %35, %18
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %39

23:                                               ; preds = %20
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Collector, ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %34

29:                                               ; preds = %23
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Collector, ptr %30, i32 0, i32 2
  %32 = load i64, ptr %31, align 8, !tbaa !12
  %33 = add i64 %32, 1
  store i64 %33, ptr %31, align 8, !tbaa !12
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %81

34:                                               ; preds = %23
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Collector, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  store ptr %38, ptr %6, align 8, !tbaa !5
  br label %20, !llvm.loop !14

39:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %40, ptr %8, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %47, %39
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Collector, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %51

46:                                               ; preds = %41
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Collector, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  store ptr %50, ptr %8, align 8, !tbaa !5
  br label %41, !llvm.loop !16

51:                                               ; preds = %41
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Collector, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %62

56:                                               ; preds = %51
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.Collector, ptr %57, i32 0, i32 2
  store i64 1, ptr %58, align 8, !tbaa !12
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Collector, ptr %60, i32 0, i32 3
  store ptr %59, ptr %61, align 8, !tbaa !9
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %80

62:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %63 = call ptr @collector__new()
  store ptr %63, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = icmp eq ptr %64, null
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %79

67:                                               ; preds = %62
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Collector, ptr %69, i32 0, i32 1
  store ptr %68, ptr %70, align 8, !tbaa !17
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Collector, ptr %71, i32 0, i32 2
  store i64 1, ptr %72, align 8, !tbaa !12
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.Collector, ptr %74, i32 0, i32 3
  store ptr %73, ptr %75, align 8, !tbaa !9
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Collector, ptr %77, i32 0, i32 0
  store ptr %76, ptr %78, align 8, !tbaa !13
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %79

79:                                               ; preds = %67, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %80

80:                                               ; preds = %79, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %81

81:                                               ; preds = %80, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %82

82:                                               ; preds = %81, %16, %12
  %83 = load i1, ptr %3, align 1
  ret i1 %83
}

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 = { 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, !6, i64 24}
!10 = !{!"Collector", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!10, !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!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"

; Function Attrs: nounwind uwtable
declare dso_local ptr @collector__new() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @collector__keep(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %27, label %.preheader32

.preheader32:                                     ; preds = %2, %12
  %.02534 = phi ptr [ %13, %12 ], [ %0, %2 ]
  %5 = getelementptr inbounds i8, ptr %.02534, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, %1
  br i1 %7, label %8, label %12

8:                                                ; preds = %.preheader32
  %9 = getelementptr inbounds i8, ptr %.02534, i64 16
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = add i64 %10, 1
  store i64 %11, ptr %9, align 8, !tbaa !11
  br label %27

12:                                               ; preds = %.preheader32
  %13 = load ptr, ptr %.02534, align 8, !tbaa !12
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %.preheader, label %.preheader32, !llvm.loop !13

.preheader:                                       ; preds = %12, %.preheader
  %.024 = phi ptr [ %14, %.preheader ], [ %0, %12 ]
  %14 = load ptr, ptr %.024, align 8, !tbaa !12
  %.not30 = icmp eq ptr %14, null
  br i1 %.not30, label %15, label %.preheader, !llvm.loop !15

15:                                               ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %.024, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %.024, i64 16
  store i64 1, ptr %20, align 8, !tbaa !11
  store ptr %1, ptr %16, align 8, !tbaa !5
  br label %27

21:                                               ; preds = %15
  %22 = tail call ptr @collector__new()
  %.not31 = icmp eq ptr %22, null
  br i1 %.not31, label %27, label %23

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %22, i64 8
  store ptr %.024, ptr %24, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %22, i64 16
  store i64 1, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %22, i64 24
  store ptr %1, ptr %26, align 8, !tbaa !5
  store ptr %22, ptr %.024, align 8, !tbaa !12
  br label %27

27:                                               ; preds = %8, %23, %21, %19, %2
  %.3 = phi i1 [ false, %2 ], [ true, %8 ], [ true, %19 ], [ false, %21 ], [ true, %23 ]
  ret i1 %.3
}

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

!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, !7, i64 24}
!6 = !{!"Collector", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!6, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!6, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass