; 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.mln_rbtree_attr = type { ptr, ptr, ptr, ptr, ptr }
%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: nounwind uwtable
define dso_local ptr @mln_rbtree_new(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %13, label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %8, %1
  %14 = call noalias ptr @malloc(i64 noundef 152) #4
  store ptr %14, ptr %4, align 8, !tbaa !5
  br label %23

15:                                               ; preds = %8
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call ptr %18(ptr noundef %21, i64 noundef 152)
  store ptr %22, ptr %4, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %15, %13
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %114

27:                                               ; preds = %23
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %41

30:                                               ; preds = %27
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.rbtree_s, ptr %31, i32 0, i32 0
  store ptr null, ptr %32, align 8, !tbaa !12
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.rbtree_s, ptr %33, i32 0, i32 1
  store ptr null, ptr %34, align 8, !tbaa !17
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.rbtree_s, ptr %35, i32 0, i32 2
  store ptr null, ptr %36, align 8, !tbaa !18
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.rbtree_s, ptr %37, i32 0, i32 3
  store ptr null, ptr %38, align 8, !tbaa !19
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.rbtree_s, ptr %39, i32 0, i32 4
  store ptr null, ptr %40, align 8, !tbaa !20
  br label %67

41:                                               ; preds = %27
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.rbtree_s, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !12
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.rbtree_s, ptr %50, i32 0, i32 1
  store ptr %49, ptr %51, align 8, !tbaa !17
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !21
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.rbtree_s, ptr %55, i32 0, i32 2
  store ptr %54, ptr %56, align 8, !tbaa !18
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !22
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.rbtree_s, ptr %60, i32 0, i32 3
  store ptr %59, ptr %61, align 8, !tbaa !19
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !23
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.rbtree_s, ptr %65, i32 0, i32 4
  store ptr %64, ptr %66, align 8, !tbaa !20
  br label %67

67:                                               ; preds = %41, %30
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.rbtree_s, ptr %68, i32 0, i32 5
  %70 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %69, i32 0, i32 0
  store ptr null, ptr %70, align 8, !tbaa !24
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.rbtree_s, ptr %71, i32 0, i32 5
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.rbtree_s, ptr %73, i32 0, i32 5
  %75 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %74, i32 0, i32 3
  store ptr %72, ptr %75, align 8, !tbaa !25
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.rbtree_s, ptr %76, i32 0, i32 5
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.rbtree_s, ptr %78, i32 0, i32 5
  %80 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %79, i32 0, i32 4
  store ptr %77, ptr %80, align 8, !tbaa !26
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.rbtree_s, ptr %81, i32 0, i32 5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.rbtree_s, ptr %83, i32 0, i32 5
  %85 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %84, i32 0, i32 5
  store ptr %82, ptr %85, align 8, !tbaa !27
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.rbtree_s, ptr %86, i32 0, i32 5
  %88 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %87, i32 0, i32 6
  %89 = load i32, ptr %88, align 8
  %90 = and i32 %89, 1
  %91 = or i32 %90, 2
  store i32 %91, ptr %88, align 8
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.rbtree_s, ptr %92, i32 0, i32 5
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.rbtree_s, ptr %94, i32 0, i32 6
  store ptr %93, ptr %95, align 8, !tbaa !28
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.rbtree_s, ptr %96, i32 0, i32 5
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.rbtree_s, ptr %98, i32 0, i32 7
  store ptr %97, ptr %99, align 8, !tbaa !29
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.rbtree_s, ptr %100, i32 0, i32 9
  store ptr null, ptr %101, align 8, !tbaa !30
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.rbtree_s, ptr %102, i32 0, i32 8
  store ptr null, ptr %103, align 8, !tbaa !31
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.rbtree_s, ptr %104, i32 0, i32 10
  store ptr null, ptr %105, align 8, !tbaa !32
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.rbtree_s, ptr %106, i32 0, i32 11
  store i64 0, ptr %107, align 8, !tbaa !33
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.rbtree_s, ptr %108, i32 0, i32 12
  %110 = load i8, ptr %109, align 8
  %111 = and i8 %110, -2
  %112 = or i8 %111, 0
  store i8 %112, ptr %109, align 8
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %113, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %114

114:                                              ; preds = %67, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %115 = load ptr, ptr %2, align 8
  ret ptr %115
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 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 = { 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 #3 = { nounwind }
attributes #4 = { 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 = !{!"mln_rbtree_attr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !6, i64 0}
!13 = !{!"rbtree_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !16, i64 136, !15, i64 144}
!14 = !{!"mln_rbtree_node_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !15, i64 48, !15, i64 48}
!15 = !{!"int", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!13, !6, i64 8}
!18 = !{!13, !6, i64 16}
!19 = !{!13, !6, i64 24}
!20 = !{!13, !6, i64 32}
!21 = !{!10, !6, i64 16}
!22 = !{!10, !6, i64 24}
!23 = !{!10, !6, i64 32}
!24 = !{!13, !6, i64 40}
!25 = !{!13, !6, i64 64}
!26 = !{!13, !6, i64 72}
!27 = !{!13, !6, i64 80}
!28 = !{!13, !6, i64 96}
!29 = !{!13, !6, i64 104}
!30 = !{!13, !6, i64 120}
!31 = !{!13, !6, i64 112}
!32 = !{!13, !6, i64 128}
!33 = !{!13, !16, 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 noundef ptr @mln_rbtree_new(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %6, label %3

3:                                                ; preds = %1
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %.thread49, label %.thread

6:                                                ; preds = %1
  %7 = tail call noalias dereferenceable_or_null(152) ptr @malloc(i64 noundef 152) #3
  %8 = icmp eq ptr %7, null
  br i1 %8, label %38, label %15

.thread49:                                        ; preds = %3
  %9 = tail call noalias dereferenceable_or_null(152) ptr @malloc(i64 noundef 152) #3
  %10 = icmp eq ptr %9, null
  br i1 %10, label %38, label %.thread45

.thread:                                          ; preds = %3
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !10
  %13 = tail call ptr %12(ptr noundef nonnull %4, i64 noundef 152) #4
  %14 = icmp eq ptr %13, null
  br i1 %14, label %38, label %.thread..thread45_crit_edge

.thread..thread45_crit_edge:                      ; preds = %.thread
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %.thread45

15:                                               ; preds = %6
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %7, i8 0, i64 40, i1 false)
  br label %23

.thread45:                                        ; preds = %.thread..thread45_crit_edge, %.thread49
  %16 = phi ptr [ %.pre, %.thread..thread45_crit_edge ], [ null, %.thread49 ]
  %.04447 = phi ptr [ %13, %.thread..thread45_crit_edge ], [ %9, %.thread49 ]
  store ptr %16, ptr %.04447, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = getelementptr inbounds i8, ptr %.04447, i64 8
  %19 = load <2 x ptr>, ptr %17, align 8, !tbaa !16
  store <2 x ptr> %19, ptr %18, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = getelementptr inbounds i8, ptr %.04447, i64 24
  %22 = load <2 x ptr>, ptr %20, align 8, !tbaa !16
  store <2 x ptr> %22, ptr %21, align 8, !tbaa !16
  br label %23

23:                                               ; preds = %.thread45, %15
  %.04448 = phi ptr [ %.04447, %.thread45 ], [ %7, %15 ]
  %24 = getelementptr inbounds i8, ptr %.04448, i64 40
  store ptr null, ptr %24, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %.04448, i64 64
  store ptr %24, ptr %25, align 8, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %.04448, i64 72
  store ptr %24, ptr %26, align 8, !tbaa !19
  %27 = getelementptr inbounds i8, ptr %.04448, i64 80
  store ptr %24, ptr %27, align 8, !tbaa !20
  %28 = getelementptr inbounds i8, ptr %.04448, i64 88
  %29 = load i32, ptr %28, align 8
  %30 = and i32 %29, 1
  %31 = or disjoint i32 %30, 2
  store i32 %31, ptr %28, align 8
  %32 = getelementptr inbounds i8, ptr %.04448, i64 96
  store ptr %24, ptr %32, align 8, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %.04448, i64 104
  store ptr %24, ptr %33, align 8, !tbaa !22
  %34 = getelementptr inbounds i8, ptr %.04448, i64 112
  %35 = getelementptr inbounds i8, ptr %.04448, i64 144
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %34, i8 0, i64 32, i1 false)
  %36 = load i8, ptr %35, align 8
  %37 = and i8 %36, -2
  store i8 %37, ptr %35, align 8
  br label %38

38:                                               ; preds = %.thread49, %.thread, %6, %23
  %.040 = phi ptr [ %.04448, %23 ], [ null, %6 ], [ null, %.thread ], [ null, %.thread49 ]
  ret ptr %.040
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind allocsize(0) }
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, !7, i64 0}
!6 = !{!"mln_rbtree_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !7, i64 0}
!12 = !{!"rbtree_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !13, i64 40, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !15, i64 136, !14, i64 144}
!13 = !{!"mln_rbtree_node_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !14, i64 48, !14, i64 48}
!14 = !{!"int", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !7, i64 40}
!18 = !{!12, !7, i64 64}
!19 = !{!12, !7, i64 72}
!20 = !{!12, !7, i64 80}
!21 = !{!12, !7, i64 96}
!22 = !{!12, !7, i64 104}


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