; LLVM IR from recp/ds :: src (rb)

; 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.DsAllocator = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.RBNode = type { ptr, ptr, [2 x ptr], i8 }
%struct.RBTree = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64 }

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__.rb_newtree = external hidden unnamed_addr constant [54 x i8], align 1
@rb_emptystr = external hidden global ptr, align 8

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

13:                                               ; preds = %3
  %14 = call ptr @ds_allocator()
  br label %17

15:                                               ; preds = %3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %15, %13
  %18 = phi ptr [ %14, %13 ], [ %16, %15 ]
  store ptr %18, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DsAllocator, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call ptr %21(i64 noundef 1, i64 noundef 72)
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.DsAllocator, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = call ptr %25(i64 noundef 1, i64 noundef 40)
  store ptr %26, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DsAllocator, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call ptr %29(i64 noundef 1, i64 noundef 40)
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %40

33:                                               ; preds = %17
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %40

36:                                               ; preds = %33
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  br label %41

40:                                               ; preds = %36, %33, %17
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 123, ptr noundef @__PRETTY_FUNCTION__.rb_newtree) #5
  unreachable

41:                                               ; preds = %39
  %42 = load ptr, ptr @rb_emptystr, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.RBNode, ptr %43, i32 0, i32 0
  store ptr %42, ptr %44, align 8, !tbaa !11
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.RBNode, ptr %46, i32 0, i32 2
  %48 = getelementptr inbounds [2 x ptr], ptr %47, i64 0, i64 0
  store ptr %45, ptr %48, align 8, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.RBNode, ptr %50, i32 0, i32 2
  %52 = getelementptr inbounds [2 x ptr], ptr %51, i64 0, i64 1
  store ptr %49, ptr %52, align 8, !tbaa !5
  %53 = load ptr, ptr @rb_emptystr, align 8, !tbaa !5
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.RBNode, ptr %54, i32 0, i32 0
  store ptr %53, ptr %55, align 8, !tbaa !11
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.RBNode, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds [2 x ptr], ptr %58, i64 0, i64 0
  store ptr %56, ptr %59, align 8, !tbaa !5
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.RBNode, ptr %61, i32 0, i32 2
  %63 = getelementptr inbounds [2 x ptr], ptr %62, i64 0, i64 1
  store ptr %60, ptr %63, align 8, !tbaa !5
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.RBTree, ptr %65, i32 0, i32 1
  store ptr %64, ptr %66, align 8, !tbaa !13
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.RBTree, ptr %68, i32 0, i32 2
  store ptr %67, ptr %69, align 8, !tbaa !16
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.RBTree, ptr %71, i32 0, i32 0
  store ptr %70, ptr %72, align 8, !tbaa !17
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %75, label %77

75:                                               ; preds = %41
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  br label %78

77:                                               ; preds = %41
  br label %78

78:                                               ; preds = %77, %75
  %79 = phi ptr [ %76, %75 ], [ @ds_cmp_str, %77 ]
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.RBTree, ptr %80, i32 0, i32 4
  store ptr %79, ptr %81, align 8, !tbaa !18
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %86

84:                                               ; preds = %78
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  br label %87

86:                                               ; preds = %78
  br label %87

87:                                               ; preds = %86, %84
  %88 = phi ptr [ %85, %84 ], [ @ds_print_str, %86 ]
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.RBTree, ptr %89, i32 0, i32 5
  store ptr %88, ptr %90, align 8, !tbaa !19
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.RBTree, ptr %91, i32 0, i32 8
  store i64 0, ptr %92, align 8, !tbaa !20
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret ptr %93
}

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

declare ptr @ds_allocator() #2

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

declare i32 @ds_cmp_str(ptr noundef, ptr noundef) #2

declare void @ds_print_str(ptr noundef) #2

; 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 = { "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 "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, !6, i64 8}
!10 = !{!"DsAllocator", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!12, !6, i64 0}
!12 = !{!"RBNode", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 32}
!13 = !{!14, !6, i64 8}
!14 = !{!"RBTree", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !15, i64 64}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !6, i64 16}
!17 = !{!14, !6, i64 0}
!18 = !{!14, !6, i64 32}
!19 = !{!14, !6, i64 40}
!20 = !{!14, !15, i64 64}


; 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 [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__.rb_newtree = external hidden unnamed_addr constant [54 x i8], align 1
@rb_emptystr = external hidden local_unnamed_addr global ptr, align 8

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

4:                                                ; preds = %3
  %5 = tail call ptr @ds_allocator() #3
  br label %6

6:                                                ; preds = %3, %4
  %7 = phi ptr [ %5, %4 ], [ %0, %3 ]
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = tail call ptr %9(i64 noundef 1, i64 noundef 72) #3
  %11 = load ptr, ptr %8, align 8, !tbaa !5
  %12 = tail call ptr %11(i64 noundef 1, i64 noundef 40) #3
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = tail call ptr %13(i64 noundef 1, i64 noundef 40) #3
  %15 = icmp ne ptr %10, null
  %16 = icmp ne ptr %12, null
  %or.cond = select i1 %15, i1 %16, i1 false
  %17 = icmp ne ptr %14, null
  %or.cond3 = select i1 %or.cond, i1 %17, i1 false
  br i1 %or.cond3, label %19, label %18

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

19:                                               ; preds = %6
  %20 = load ptr, ptr @rb_emptystr, align 8, !tbaa !10
  store ptr %20, ptr %14, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %14, i64 16
  store ptr %14, ptr %21, align 8, !tbaa !10
  %22 = getelementptr inbounds i8, ptr %14, i64 24
  store ptr %14, ptr %22, align 8, !tbaa !10
  store ptr %20, ptr %12, align 8, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %12, i64 16
  store ptr %14, ptr %23, align 8, !tbaa !10
  %24 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr %14, ptr %24, align 8, !tbaa !10
  %25 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %12, ptr %25, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %14, ptr %26, align 8, !tbaa !16
  store ptr %7, ptr %10, align 8, !tbaa !17
  %27 = insertelement <2 x ptr> poison, ptr %1, i64 0
  %28 = insertelement <2 x ptr> %27, ptr %2, i64 1
  %29 = icmp eq <2 x ptr> %28, zeroinitializer
  %30 = getelementptr inbounds i8, ptr %10, i64 32
  %31 = select <2 x i1> %29, <2 x ptr> <ptr @ds_cmp_str, ptr @ds_print_str>, <2 x ptr> %28
  store <2 x ptr> %31, ptr %30, align 8, !tbaa !10
  %32 = getelementptr inbounds i8, ptr %10, i64 64
  store i64 0, ptr %32, align 8, !tbaa !18
  ret ptr %10
}

declare ptr @ds_allocator() local_unnamed_addr #1

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

declare i32 @ds_cmp_str(ptr noundef, ptr noundef) #1

declare void @ds_print_str(ptr noundef) #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 = { "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 "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 }
attributes #4 = { 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, !7, i64 8}
!6 = !{!"DsAllocator", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"RBNode", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 32}
!13 = !{!14, !7, i64 8}
!14 = !{!"RBTree", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !15, i64 64}
!15 = !{!"long", !8, i64 0}
!16 = !{!14, !7, i64 16}
!17 = !{!14, !7, i64 0}
!18 = !{!14, !15, i64 64}


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