; 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_insert1 = external hidden unnamed_addr constant [84 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
define dso_local i32 @cdc_treap_insert1(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 392, ptr noundef @__PRETTY_FUNCTION__.cdc_treap_insert1) #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 %85

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 %61

61:                                               ; preds = %48, %20
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %75

64:                                               ; preds = %61
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.cdc_treap_iter, ptr %66, i32 0, i32 0
  store ptr %65, ptr %67, align 8, !tbaa !22
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.cdc_treap_iter, ptr %69, i32 0, i32 2
  store ptr %68, ptr %70, align 8, !tbaa !24
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = call ptr @cdc_tree_predecessor(ptr noundef %71)
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.cdc_treap_iter, ptr %73, i32 0, i32 1
  store ptr %72, ptr %74, align 8, !tbaa !25
  br label %75

75:                                               ; preds = %64, %61
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = icmp ne ptr %76, null
  br i1 %77, label %78, label %84

78:                                               ; preds = %75
  %79 = load i8, ptr %13, align 1, !tbaa !15, !range !26, !noundef !27
  %80 = trunc i8 %79 to i1
  %81 = xor i1 %80, true
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  %83 = zext i1 %81 to i8
  store i8 %83, ptr %82, align 1, !tbaa !15
  br label %84

84:                                               ; preds = %78, %75
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %85

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

; 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

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 = !{!23, !6, i64 0}
!23 = !{!"cdc_treap_iter", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!23, !6, i64 16}
!25 = !{!23, !6, i64 8}
!26 = !{i8 0, i8 2}
!27 = !{}


; 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_insert1 = external hidden unnamed_addr constant [84 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
define dso_local range(i32 0, 2) i32 @cdc_treap_insert1(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 392, ptr noundef nonnull @__PRETTY_FUNCTION__.cdc_treap_insert1) #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)
  %.not33 = icmp eq ptr %13, null
  br i1 %.not33, 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)
  %.not34 = icmp eq ptr %18, null
  br i1 %.not34, label %34, 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 %26

26:                                               ; preds = %19, %7
  %.027 = phi ptr [ %13, %7 ], [ %25, %19 ]
  %.not35 = icmp eq ptr %3, null
  br i1 %.not35, label %31, label %27

27:                                               ; preds = %26
  store ptr %0, ptr %3, align 8, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %.027, ptr %28, align 8, !tbaa !21
  %29 = tail call ptr @cdc_tree_predecessor(ptr noundef %.027)
  %30 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %29, ptr %30, align 8, !tbaa !22
  br label %31

31:                                               ; preds = %27, %26
  %.not36 = icmp eq ptr %4, null
  br i1 %.not36, label %34, label %32

32:                                               ; preds = %31
  %33 = zext i1 %.not33 to i8
  store i8 %33, ptr %4, align 1, !tbaa !23
  br label %34

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

; 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

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 = !{!20, !7, i64 0}
!20 = !{!"cdc_treap_iter", !7, i64 0, !7, i64 8, !7, i64 16}
!21 = !{!20, !7, i64 16}
!22 = !{!20, !7, i64 8}
!23 = !{!24, !24, i64 0}
!24 = !{!"_Bool", !8, i64 0}


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