; LLVM IR from Water-Melon/Melon :: src (mln_rbtree)

; 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.rbtree_s = type { ptr, ptr, ptr, ptr, ptr, %struct.mln_rbtree_node_s, ptr, ptr, ptr, ptr, ptr, i64, i8 }
%struct.mln_rbtree_node_s = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mln_rbtree_insert(ptr noundef nonnull %0, ptr noundef nonnull %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.rbtree_s, ptr %8, i32 0, i32 5
  store ptr %9, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.rbtree_s, ptr %10, i32 0, i32 6
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.rbtree_s, ptr %13, i32 0, i32 5
  store ptr %14, ptr %7, align 8, !tbaa !5
  br label %15

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

19:                                               ; preds = %15
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %20, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.rbtree_s, ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = call i32 %23(ptr noundef %26, ptr noundef %29)
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %19
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  store ptr %35, ptr %6, align 8, !tbaa !5
  br label %40

36:                                               ; preds = %19
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %37, i32 0, i32 5
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  store ptr %39, ptr %6, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %36, %32
  br label %15, !llvm.loop !18

41:                                               ; preds = %15
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %43, i32 0, i32 3
  store ptr %42, ptr %44, align 8, !tbaa !20
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp eq ptr %45, %46
  br i1 %47, label %48, label %52

48:                                               ; preds = %41
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.rbtree_s, ptr %50, i32 0, i32 6
  store ptr %49, ptr %51, align 8, !tbaa !9
  br label %73

52:                                               ; preds = %41
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.rbtree_s, ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = call i32 %55(ptr noundef %58, ptr noundef %61)
  %63 = icmp slt i32 %62, 0
  br i1 %63, label %64, label %68

64:                                               ; preds = %52
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %66, i32 0, i32 4
  store ptr %65, ptr %67, align 8, !tbaa !16
  br label %72

68:                                               ; preds = %52
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %70, i32 0, i32 5
  store ptr %69, ptr %71, align 8, !tbaa !17
  br label %72

72:                                               ; preds = %68, %64
  br label %73

73:                                               ; preds = %72, %48
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %75, i32 0, i32 5
  store ptr %74, ptr %76, align 8, !tbaa !17
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %77, i32 0, i32 4
  store ptr %74, ptr %78, align 8, !tbaa !16
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %79, i32 0, i32 6
  %81 = load i32, ptr %80, align 8
  %82 = and i32 %81, 1
  %83 = or i32 %82, 0
  store i32 %83, ptr %80, align 8
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  call void @rbtree_insert_fixup(ptr noundef %84, ptr noundef %85)
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.rbtree_s, ptr %86, i32 0, i32 7
  %88 = load ptr, ptr %87, align 8, !tbaa !21
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = icmp eq ptr %88, %89
  br i1 %90, label %91, label %95

91:                                               ; preds = %73
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.rbtree_s, ptr %93, i32 0, i32 7
  store ptr %92, ptr %94, align 8, !tbaa !21
  br label %114

95:                                               ; preds = %73
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.rbtree_s, ptr %96, i32 0, i32 3
  %98 = load ptr, ptr %97, align 8, !tbaa !14
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !15
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.rbtree_s, ptr %102, i32 0, i32 7
  %104 = load ptr, ptr %103, align 8, !tbaa !21
  %105 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8, !tbaa !15
  %107 = call i32 %98(ptr noundef %101, ptr noundef %106)
  %108 = icmp slt i32 %107, 0
  br i1 %108, label %109, label %113

109:                                              ; preds = %95
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.rbtree_s, ptr %111, i32 0, i32 7
  store ptr %110, ptr %112, align 8, !tbaa !21
  br label %113

113:                                              ; preds = %109, %95
  br label %114

114:                                              ; preds = %113, %91
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.rbtree_s, ptr %115, i32 0, i32 11
  %117 = load i64, ptr %116, align 8, !tbaa !22
  %118 = add i64 %117, 1
  store i64 %118, ptr %116, align 8, !tbaa !22
  %119 = load ptr, ptr %3, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.rbtree_s, ptr %119, i32 0, i32 8
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.rbtree_s, ptr %121, i32 0, i32 9
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mln_rbtree_chain_add(ptr noundef %120, ptr noundef %122, ptr noundef %123)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 96}
!10 = !{!"rbtree_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !13, i64 136, !12, i64 144}
!11 = !{!"mln_rbtree_node_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 48}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !6, i64 24}
!15 = !{!11, !6, i64 0}
!16 = !{!11, !6, i64 32}
!17 = !{!11, !6, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!11, !6, i64 24}
!21 = !{!10, !6, i64 104}
!22 = !{!10, !13, i64 136}


; 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
define dso_local void @mln_rbtree_insert(ptr noundef nonnull %0, ptr noundef nonnull %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = getelementptr inbounds i8, ptr %0, i64 96
  %.04346 = load ptr, ptr %4, align 8, !tbaa !5
  %.not47 = icmp eq ptr %.04346, %3
  br i1 %.not47, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %3, ptr %5, align 8, !tbaa !9
  br label %26

.lr.ph:                                           ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  br label %7

7:                                                ; preds = %.lr.ph, %7
  %.04348 = phi ptr [ %.04346, %.lr.ph ], [ %.043, %7 ]
  %8 = load ptr, ptr %6, align 8, !tbaa !12
  %9 = load ptr, ptr %1, align 8, !tbaa !15
  %10 = load ptr, ptr %.04348, align 8, !tbaa !15
  %11 = tail call i32 %8(ptr noundef %9, ptr noundef %10) #2
  %12 = icmp slt i32 %11, 0
  %.1.in.v = select i1 %12, i64 32, i64 40
  %.1.in = getelementptr inbounds i8, ptr %.04348, i64 %.1.in.v
  %.043 = load ptr, ptr %.1.in, align 8, !tbaa !5
  %.not = icmp eq ptr %.043, %3
  br i1 %.not, label %._crit_edge, label %7, !llvm.loop !16

._crit_edge:                                      ; preds = %7
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %.04348, ptr %13, align 8, !tbaa !9
  %14 = icmp eq ptr %.04348, %3
  br i1 %14, label %26, label %15

15:                                               ; preds = %._crit_edge
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = load ptr, ptr %1, align 8, !tbaa !15
  %19 = load ptr, ptr %.04348, align 8, !tbaa !15
  %20 = tail call i32 %17(ptr noundef %18, ptr noundef %19) #2
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %15
  %23 = getelementptr inbounds i8, ptr %.04348, i64 32
  br label %26

24:                                               ; preds = %15
  %25 = getelementptr inbounds i8, ptr %.04348, i64 40
  br label %26

26:                                               ; preds = %._crit_edge, %._crit_edge.thread, %22, %24
  %.sink = phi ptr [ %23, %22 ], [ %25, %24 ], [ %4, %._crit_edge.thread ], [ %4, %._crit_edge ]
  store ptr %1, ptr %.sink, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 40
  store ptr %3, ptr %27, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %3, ptr %28, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %1, i64 48
  %30 = load i32, ptr %29, align 8
  %31 = and i32 %30, 1
  store i32 %31, ptr %29, align 8
  tail call void @rbtree_insert_fixup(ptr noundef nonnull %0, ptr noundef nonnull %1)
  %32 = getelementptr inbounds i8, ptr %0, i64 104
  %33 = load ptr, ptr %32, align 8, !tbaa !20
  %34 = icmp eq ptr %33, %3
  br i1 %34, label %.sink.split, label %35

35:                                               ; preds = %26
  %36 = getelementptr inbounds i8, ptr %0, i64 24
  %37 = load ptr, ptr %36, align 8, !tbaa !12
  %38 = load ptr, ptr %1, align 8, !tbaa !15
  %39 = load ptr, ptr %33, align 8, !tbaa !15
  %40 = tail call i32 %37(ptr noundef %38, ptr noundef %39) #2
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %.sink.split, label %42

.sink.split:                                      ; preds = %35, %26
  store ptr %1, ptr %32, align 8, !tbaa !20
  br label %42

42:                                               ; preds = %.sink.split, %35
  %43 = getelementptr inbounds i8, ptr %0, i64 136
  %44 = load i64, ptr %43, align 8, !tbaa !21
  %45 = add i64 %44, 1
  store i64 %45, ptr %43, align 8, !tbaa !21
  %46 = getelementptr inbounds i8, ptr %0, i64 112
  %47 = getelementptr inbounds i8, ptr %0, i64 120
  tail call void @mln_rbtree_chain_add(ptr noundef nonnull %46, ptr noundef nonnull %47, ptr noundef nonnull %1)
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_rbtree_chain_add(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { inlinehint 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 = { 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 = !{!"mln_rbtree_node_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"rbtree_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !14, i64 136, !11, i64 144}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !6, i64 40}
!19 = !{!10, !6, i64 32}
!20 = !{!13, !6, i64 104}
!21 = !{!13, !14, i64 136}


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