; LLVM IR from maksimandrianov/cdcontainers :: src (treap)

; 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.cdc_treap = type { ptr, i64, ptr, ptr }
%struct.cdc_data_info = type { ptr, ptr, ptr, ptr, ptr, i64, i64 }
%struct.cdc_treap_node = type { ptr, ptr, ptr, ptr, ptr, i32 }
%struct.cdc_treap_iter = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__.cdc_treap_insert_or_assign1 = external hidden unnamed_addr constant [94 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #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
declare hidden ptr @cdc_find_tree_node(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @cdc_tree_predecessor(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @make_new_node(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @find_nearest(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @insert_unique(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @cdc_treap_insert_or_assign1(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %5
  br label %20

19:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 435, ptr noundef @__PRETTY_FUNCTION__.cdc_treap_insert_or_assign1) #3
  unreachable

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.cdc_treap, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.cdc_treap, ptr %25, i32 0, i32 3
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = getelementptr inbounds %struct.cdc_data_info, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = call ptr @cdc_find_tree_node(ptr noundef %23, ptr noundef %24, ptr noundef %29)
  store ptr %30, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #4
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  %33 = zext i1 %32 to i8
  store i8 %33, ptr %13, align 1, !tbaa !15
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %61, label %36

36:                                               ; preds = %20
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.cdc_treap, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = call i32 %40(ptr noundef %41)
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = call ptr @make_new_node(ptr noundef %37, i32 noundef %42, ptr noundef %43)
  store ptr %44, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %48, label %47

47:                                               ; preds = %36
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %89

48:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.cdc_treap_node, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.cdc_treap_node, ptr %53, i32 0, i32 5
  %55 = load i32, ptr %54, align 8, !tbaa !21
  %56 = call ptr @find_nearest(ptr noundef %49, ptr noundef %52, i32 noundef %55)
  store ptr %56, ptr %15, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  %60 = call ptr @insert_unique(ptr noundef %57, ptr noundef %58, ptr noundef %59)
  store ptr %60, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %65

61:                                               ; preds = %20
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.cdc_treap_node, ptr %63, i32 0, i32 4
  store ptr %62, ptr %64, align 8, !tbaa !22
  br label %65

65:                                               ; preds = %61, %48
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %79

68:                                               ; preds = %65
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.cdc_treap_iter, ptr %70, i32 0, i32 0
  store ptr %69, ptr %71, align 8, !tbaa !23
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.cdc_treap_iter, ptr %73, i32 0, i32 2
  store ptr %72, ptr %74, align 8, !tbaa !25
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = call ptr @cdc_tree_predecessor(ptr noundef %75)
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.cdc_treap_iter, ptr %77, i32 0, i32 1
  store ptr %76, ptr %78, align 8, !tbaa !26
  br label %79

79:                                               ; preds = %68, %65
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %88

82:                                               ; preds = %79
  %83 = load i8, ptr %13, align 1, !tbaa !15, !range !27, !noundef !28
  %84 = trunc i8 %83 to i1
  %85 = xor i1 %84, true
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = zext i1 %85 to i8
  store i8 %87, ptr %86, align 1, !tbaa !15
  br label %88

88:                                               ; preds = %82, %79
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %47
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %90 = load i32, ptr %6, align 4
  ret i32 %90
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { noreturn nounwind }
attributes #4 = { 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 = !{!"cdc_treap", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!14, !6, i64 8}
!14 = !{!"cdc_data_info", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 48}
!15 = !{!16, !16, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!10, !6, i64 16}
!18 = !{!19, !6, i64 24}
!19 = !{!"cdc_treap_node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !20, i64 40}
!20 = !{!"int", !7, i64 0}
!21 = !{!19, !20, i64 40}
!22 = !{!19, !6, i64 32}
!23 = !{!24, !6, i64 0}
!24 = !{!"cdc_treap_iter", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!24, !6, i64 16}
!26 = !{!24, !6, i64 8}
!27 = !{i8 0, i8 2}
!28 = !{}


; 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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__.cdc_treap_insert_or_assign1 = external hidden unnamed_addr constant [94 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @cdc_find_tree_node(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @cdc_tree_predecessor(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @make_new_node(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @find_nearest(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @insert_unique(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @cdc_treap_insert_or_assign1(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef writeonly %3, ptr noundef writeonly %4) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %6, label %7

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

7:                                                ; preds = %5
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = tail call ptr @cdc_find_tree_node(ptr noundef %8, ptr noundef %1, ptr noundef %12)
  %.not35 = icmp eq ptr %13, null
  br i1 %.not35, label %14, label %26

14:                                               ; preds = %7
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = tail call i32 %16(ptr noundef %2) #3
  %18 = tail call ptr @make_new_node(ptr noundef %1, i32 noundef %17, ptr noundef %2)
  %.not36 = icmp eq ptr %18, null
  br i1 %.not36, label %36, label %19

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %18, i64 24
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %18, i64 40
  %23 = load i32, ptr %22, align 8, !tbaa !18
  %24 = tail call ptr @find_nearest(ptr noundef nonnull %0, ptr noundef %21, i32 noundef %23)
  %25 = tail call ptr @insert_unique(ptr noundef nonnull %0, ptr noundef nonnull %18, ptr noundef %24)
  br label %28

26:                                               ; preds = %7
  %27 = getelementptr inbounds i8, ptr %13, i64 32
  store ptr %2, ptr %27, align 8, !tbaa !19
  br label %28

28:                                               ; preds = %26, %19
  %.029 = phi ptr [ %13, %26 ], [ %25, %19 ]
  %.not37 = icmp eq ptr %3, null
  br i1 %.not37, label %33, label %29

29:                                               ; preds = %28
  store ptr %0, ptr %3, align 8, !tbaa !20
  %30 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %.029, ptr %30, align 8, !tbaa !22
  %31 = tail call ptr @cdc_tree_predecessor(ptr noundef %.029)
  %32 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %31, ptr %32, align 8, !tbaa !23
  br label %33

33:                                               ; preds = %29, %28
  %.not38 = icmp eq ptr %4, null
  br i1 %.not38, label %36, label %34

34:                                               ; preds = %33
  %35 = zext i1 %.not35 to i8
  store i8 %35, ptr %4, align 1, !tbaa !24
  br label %36

36:                                               ; preds = %33, %34, %14
  %.0 = phi i32 [ 1, %14 ], [ 0, %34 ], [ 0, %33 ]
  ret i32 %.0
}

attributes #0 = { 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 #1 = { 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 #2 = { noreturn nounwind }
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, !7, i64 0}
!6 = !{!"cdc_treap", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!13, !7, i64 8}
!13 = !{!"cdc_data_info", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48}
!14 = !{!6, !7, i64 16}
!15 = !{!16, !7, i64 24}
!16 = !{!"cdc_treap_node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !17, i64 40}
!17 = !{!"int", !8, i64 0}
!18 = !{!16, !17, i64 40}
!19 = !{!16, !7, i64 32}
!20 = !{!21, !7, i64 0}
!21 = !{!"cdc_treap_iter", !7, i64 0, !7, i64 8, !7, i64 16}
!22 = !{!21, !7, i64 16}
!23 = !{!21, !7, i64 8}
!24 = !{!25, !25, i64 0}
!25 = !{!"_Bool", !8, i64 0}


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