; LLVM IR from Water-Melon/Melon :: t (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.user_defined_s = type { i32, %struct.mln_rbtree_node_s }
%struct.mln_rbtree_node_s = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%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 }

@.str.1 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@__PRETTY_FUNCTION__.test2 = external hidden unnamed_addr constant [16 x i8], align 1

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

declare ptr @mln_rbtree_new(ptr noundef) #1

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

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

declare i32 @printf(ptr noundef, ...) #1

declare void @mln_rbtree_delete(ptr noundef, ptr noundef) #1

declare void @mln_rbtree_node_free(ptr noundef, ptr noundef) #1

declare void @mln_rbtree_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @test2() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca %struct.user_defined_s, align 8
  %3 = alloca %struct.user_defined_s, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.mln_rbtree_attr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 40, ptr %5) #4
  %10 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %5, i32 0, i32 0
  store ptr null, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %5, i32 0, i32 1
  store ptr null, ptr %11, align 8, !tbaa !10
  %12 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %5, i32 0, i32 2
  store ptr null, ptr %12, align 8, !tbaa !11
  %13 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %5, i32 0, i32 3
  store ptr @cmp2_handler, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %5, i32 0, i32 4
  store ptr null, ptr %14, align 8, !tbaa !13
  %15 = call ptr @mln_rbtree_new(ptr noundef %5)
  store ptr %15, ptr %1, align 8, !tbaa !14
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %0
  br label %19

18:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 56, ptr noundef @__PRETTY_FUNCTION__.test2) #5
  unreachable

19:                                               ; preds = %17
  %20 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 0
  store i32 1, ptr %20, align 8, !tbaa !15
  %21 = getelementptr inbounds %struct.user_defined_s, ptr %3, i32 0, i32 0
  store i32 2, ptr %21, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 1
  %23 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %22, i32 0, i32 0
  store ptr %2, ptr %23, align 8, !tbaa !19
  %24 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 1
  %25 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %24, i32 0, i32 6
  %26 = load i32, ptr %25, align 8
  %27 = and i32 %26, -2
  %28 = or i32 %27, 1
  store i32 %28, ptr %25, align 8
  %29 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 1
  store ptr %29, ptr %6, align 8, !tbaa !14
  %30 = load ptr, ptr %6, align 8, !tbaa !14
  %31 = getelementptr inbounds %struct.user_defined_s, ptr %3, i32 0, i32 1
  %32 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %31, i32 0, i32 0
  store ptr %3, ptr %32, align 8, !tbaa !19
  %33 = getelementptr inbounds %struct.user_defined_s, ptr %3, i32 0, i32 1
  %34 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %33, i32 0, i32 6
  %35 = load i32, ptr %34, align 8
  %36 = and i32 %35, -2
  %37 = or i32 %36, 1
  store i32 %37, ptr %34, align 8
  %38 = getelementptr inbounds %struct.user_defined_s, ptr %3, i32 0, i32 1
  store ptr %38, ptr %7, align 8, !tbaa !14
  %39 = load ptr, ptr %7, align 8, !tbaa !14
  %40 = load ptr, ptr %1, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 1
  call void @mln_rbtree_insert(ptr noundef %40, ptr noundef %41)
  %42 = load ptr, ptr %1, align 8, !tbaa !14
  %43 = getelementptr inbounds %struct.user_defined_s, ptr %3, i32 0, i32 1
  call void @mln_rbtree_insert(ptr noundef %42, ptr noundef %43)
  %44 = load ptr, ptr %1, align 8, !tbaa !14
  %45 = call ptr @mln_rbtree_search(ptr noundef %44, ptr noundef %2)
  store ptr %45, ptr %4, align 8, !tbaa !14
  %46 = load ptr, ptr %4, align 8, !tbaa !14
  %47 = load ptr, ptr %1, align 8, !tbaa !14
  %48 = getelementptr inbounds %struct.rbtree_s, ptr %47, i32 0, i32 5
  %49 = icmp eq ptr %46, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %19
  br label %52

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

52:                                               ; preds = %50
  %53 = load ptr, ptr %4, align 8, !tbaa !14
  %54 = getelementptr inbounds %struct.mln_rbtree_node_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = getelementptr inbounds %struct.user_defined_s, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !15
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %57)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !14
  %59 = load ptr, ptr %4, align 8, !tbaa !14
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %64

61:                                               ; preds = %52
  %62 = load ptr, ptr %4, align 8, !tbaa !14
  %63 = getelementptr inbounds i8, ptr %62, i64 sub (i64 0, i64 ptrtoint (ptr getelementptr inbounds (%struct.user_defined_s, ptr null, i32 0, i32 1) to i64))
  store ptr %63, ptr %8, align 8, !tbaa !14
  br label %64

64:                                               ; preds = %61, %52
  %65 = load ptr, ptr %8, align 8, !tbaa !14
  store ptr %65, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %66 = load ptr, ptr %9, align 8, !tbaa !14
  %67 = getelementptr inbounds %struct.user_defined_s, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !15
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %68)
  %70 = load ptr, ptr %1, align 8, !tbaa !14
  %71 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 1
  call void @mln_rbtree_delete(ptr noundef %70, ptr noundef %71)
  %72 = load ptr, ptr %1, align 8, !tbaa !14
  %73 = getelementptr inbounds %struct.user_defined_s, ptr %2, i32 0, i32 1
  call void @mln_rbtree_node_free(ptr noundef %72, ptr noundef %73)
  %74 = load ptr, ptr %1, align 8, !tbaa !14
  call void @mln_rbtree_free(ptr noundef %74)
  call void @llvm.lifetime.end.p0(i64 40, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret i32 0
}

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

declare void @mln_rbtree_insert(ptr noundef, ptr noundef) #1

declare ptr @mln_rbtree_search(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !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 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 32}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"user_defined_s", !17, i64 0, !18, i64 8}
!17 = !{!"int", !8, i64 0}
!18 = !{!"mln_rbtree_node_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !17, i64 48, !17, i64 48}
!19 = !{!16, !7, i64 8}
!20 = !{!18, !7, i64 0}


; 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"

%struct.user_defined_s = type { i32, %struct.mln_rbtree_node_s }
%struct.mln_rbtree_node_s = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.mln_rbtree_attr = type { ptr, ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@__PRETTY_FUNCTION__.test2 = external hidden unnamed_addr constant [16 x i8], align 1

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

declare ptr @mln_rbtree_new(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare void @mln_rbtree_delete(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mln_rbtree_node_free(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mln_rbtree_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @test2() local_unnamed_addr #4 {
  %1 = alloca %struct.user_defined_s, align 8
  %2 = alloca %struct.user_defined_s, align 8
  %3 = alloca %struct.mln_rbtree_attr, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #6
  %4 = getelementptr inbounds i8, ptr %3, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, i8 0, i64 24, i1 false)
  store ptr @cmp2_handler, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr null, ptr %5, align 8, !tbaa !10
  %6 = call ptr @mln_rbtree_new(ptr noundef nonnull %3) #6
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %8

7:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 56, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #7
  unreachable

8:                                                ; preds = %0
  store i32 1, ptr %1, align 8, !tbaa !11
  store i32 2, ptr %2, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %1, ptr %9, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %1, i64 56
  store i32 -1, ptr %10, align 8
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %2, ptr %11, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %2, i64 56
  store i32 -1, ptr %12, align 8
  call void @mln_rbtree_insert(ptr noundef nonnull %6, ptr noundef nonnull %9) #6
  call void @mln_rbtree_insert(ptr noundef nonnull %6, ptr noundef nonnull %11) #6
  %13 = call ptr @mln_rbtree_search(ptr noundef nonnull %6, ptr noundef nonnull %1) #6
  %14 = getelementptr inbounds i8, ptr %6, i64 40
  %15 = icmp eq ptr %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %8
  call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 68, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #7
  unreachable

17:                                               ; preds = %8
  %18 = load ptr, ptr %13, align 8, !tbaa !16
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %19)
  %21 = getelementptr inbounds i8, ptr %13, i64 -8
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %22)
  call void @mln_rbtree_delete(ptr noundef nonnull %6, ptr noundef nonnull %9) #6
  call void @mln_rbtree_node_free(ptr noundef nonnull %6, ptr noundef nonnull %9) #6
  call void @mln_rbtree_free(ptr noundef nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %1) #6
  ret i32 0
}

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

declare void @mln_rbtree_insert(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @mln_rbtree_search(ptr noundef, ptr 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) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree 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 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { 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 24}
!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 32}
!11 = !{!12, !13, i64 0}
!12 = !{!"user_defined_s", !13, i64 0, !14, i64 8}
!13 = !{!"int", !8, i64 0}
!14 = !{!"mln_rbtree_node_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !13, i64 48, !13, i64 48}
!15 = !{!12, !7, i64 8}
!16 = !{!14, !7, i64 0}


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