; LLVM IR from dpt/Containers :: libraries/container/critbit (critbit)

; 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.icontainer = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.icontainer_key = type { ptr, ptr, ptr, %struct.icontainer_kv }
%struct.icontainer_kv = type { ptr, ptr, ptr }
%struct.container_critbit = type { %struct.icontainer, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.icontainer_value = type { ptr, %struct.icontainer_kv }

@container_create_critbit.methods = external hidden constant %struct.icontainer, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__.container_create_critbit = external hidden unnamed_addr constant [102 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @container_create_critbit(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %15

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 135, ptr noundef @__PRETTY_FUNCTION__.container_create_critbit) #8
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 136, ptr noundef @__PRETTY_FUNCTION__.container_create_critbit) #8
  unreachable

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

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 137, ptr noundef @__PRETTY_FUNCTION__.container_create_critbit) #8
  unreachable

25:                                               ; preds = %23
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %26, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.icontainer_key, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %25
  store i64 200, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %92

32:                                               ; preds = %25
  %33 = call noalias ptr @malloc(i64 noundef 120) #9
  store ptr %33, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  store i64 1, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %92

37:                                               ; preds = %32
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.container_critbit, ptr %38, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %39, ptr align 8 @container_create_critbit.methods, i64 72, i1 false), !tbaa.struct !12
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.icontainer_key, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.container_critbit, ptr %43, i32 0, i32 2
  store ptr %42, ptr %44, align 8, !tbaa !13
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.icontainer_key, ptr %45, i32 0, i32 3
  %47 = getelementptr inbounds %struct.icontainer_kv, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.container_critbit, ptr %49, i32 0, i32 3
  store ptr %48, ptr %50, align 8, !tbaa !17
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.icontainer_key, ptr %51, i32 0, i32 3
  %53 = getelementptr inbounds %struct.icontainer_kv, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !18
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.container_critbit, ptr %55, i32 0, i32 4
  store ptr %54, ptr %56, align 8, !tbaa !19
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.icontainer_value, ptr %57, i32 0, i32 1
  %59 = getelementptr inbounds %struct.icontainer_kv, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.container_critbit, ptr %61, i32 0, i32 5
  store ptr %60, ptr %62, align 8, !tbaa !22
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.icontainer_value, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds %struct.icontainer_kv, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !23
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.container_critbit, ptr %67, i32 0, i32 6
  store ptr %66, ptr %68, align 8, !tbaa !24
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.icontainer_value, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !25
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.icontainer_key, ptr %72, i32 0, i32 3
  %74 = getelementptr inbounds %struct.icontainer_kv, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !26
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.icontainer_value, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds %struct.icontainer_kv, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !27
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.container_critbit, ptr %80, i32 0, i32 1
  %82 = call i64 @critbit_create(ptr noundef %71, ptr noundef %75, ptr noundef %79, ptr noundef %81)
  store i64 %82, ptr %8, align 8, !tbaa !28
  %83 = load i64, ptr %8, align 8, !tbaa !28
  %84 = icmp ne i64 %83, 0
  br i1 %84, label %85, label %88

85:                                               ; preds = %37
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %86) #7
  %87 = load i64, ptr %8, align 8, !tbaa !28
  store i64 %87, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %92

88:                                               ; preds = %37
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.container_critbit, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %90, ptr %91, align 8, !tbaa !5
  store i64 0, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %92

92:                                               ; preds = %88, %85, %36, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %93 = load i64, ptr %4, align 8
  ret i64 %93
}

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare i64 @critbit_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #6

; 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 = { 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 allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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 #6 = { 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(0) }

!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 0}
!10 = !{!"icontainer_key", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"icontainer_kv", !6, i64 0, !6, i64 8, !6, i64 16}
!12 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 8, !5, i64 56, i64 8, !5, i64 64, i64 8, !5}
!13 = !{!14, !6, i64 80}
!14 = !{!"container_critbit", !15, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112}
!15 = !{!"icontainer", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!16 = !{!10, !6, i64 32}
!17 = !{!14, !6, i64 88}
!18 = !{!10, !6, i64 40}
!19 = !{!14, !6, i64 96}
!20 = !{!21, !6, i64 16}
!21 = !{!"icontainer_value", !6, i64 0, !11, i64 8}
!22 = !{!14, !6, i64 104}
!23 = !{!21, !6, i64 24}
!24 = !{!14, !6, i64 112}
!25 = !{!21, !6, i64 0}
!26 = !{!10, !6, i64 24}
!27 = !{!21, !6, i64 8}
!28 = !{!29, !29, i64 0}
!29 = !{!"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"

%struct.icontainer = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@container_create_critbit.methods = external hidden local_unnamed_addr constant %struct.icontainer, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__.container_create_critbit = external hidden unnamed_addr constant [102 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @container_create_critbit(ptr noundef writeonly %0, ptr noundef readonly %1, ptr noundef readonly %2) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 135, ptr noundef nonnull @__PRETTY_FUNCTION__.container_create_critbit) #6
  unreachable

5:                                                ; preds = %3
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 136, ptr noundef nonnull @__PRETTY_FUNCTION__.container_create_critbit) #6
  unreachable

7:                                                ; preds = %5
  %.not32 = icmp eq ptr %2, null
  br i1 %.not32, label %8, label %9

8:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 137, ptr noundef nonnull @__PRETTY_FUNCTION__.container_create_critbit) #6
  unreachable

9:                                                ; preds = %7
  store ptr null, ptr %0, align 8, !tbaa !5
  %10 = load ptr, ptr %1, align 8, !tbaa !9
  %11 = icmp eq ptr %10, null
  br i1 %11, label %32, label %12

12:                                               ; preds = %9
  %13 = tail call noalias dereferenceable_or_null(120) ptr @malloc(i64 noundef 120) #7
  %14 = icmp eq ptr %13, null
  br i1 %14, label %32, label %15

15:                                               ; preds = %12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %13, ptr noundef nonnull align 8 dereferenceable(72) @container_create_critbit.methods, i64 72, i1 false), !tbaa.struct !12
  %16 = getelementptr inbounds i8, ptr %13, i64 80
  store ptr %10, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %1, i64 24
  %18 = getelementptr inbounds i8, ptr %1, i64 32
  %19 = getelementptr inbounds i8, ptr %13, i64 88
  %20 = load <2 x ptr>, ptr %18, align 8, !tbaa !5
  store <2 x ptr> %20, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  %22 = getelementptr inbounds i8, ptr %2, i64 16
  %23 = getelementptr inbounds i8, ptr %13, i64 104
  %24 = load <2 x ptr>, ptr %22, align 8, !tbaa !5
  store <2 x ptr> %24, ptr %23, align 8, !tbaa !5
  %25 = load ptr, ptr %2, align 8, !tbaa !16
  %26 = load ptr, ptr %17, align 8, !tbaa !18
  %27 = load ptr, ptr %21, align 8, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %13, i64 72
  %29 = tail call i64 @critbit_create(ptr noundef %25, ptr noundef %26, ptr noundef %27, ptr noundef nonnull %28) #8
  %.not33 = icmp eq i64 %29, 0
  br i1 %.not33, label %31, label %30

30:                                               ; preds = %15
  tail call void @free(ptr noundef nonnull %13) #8
  br label %32

31:                                               ; preds = %15
  store ptr %13, ptr %0, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %12, %9, %31, %30
  %.0 = phi i64 [ %29, %30 ], [ 0, %31 ], [ 200, %9 ], [ 1, %12 ]
  ret i64 %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare i64 @critbit_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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 = { 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { noreturn nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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 0}
!10 = !{!"icontainer_key", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"icontainer_kv", !6, i64 0, !6, i64 8, !6, i64 16}
!12 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 8, !5, i64 56, i64 8, !5, i64 64, i64 8, !5}
!13 = !{!14, !6, i64 80}
!14 = !{!"container_critbit", !15, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112}
!15 = !{!"icontainer", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!16 = !{!17, !6, i64 0}
!17 = !{!"icontainer_value", !6, i64 0, !11, i64 8}
!18 = !{!10, !6, i64 24}
!19 = !{!17, !6, i64 8}


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