; LLVM IR from Water-Melon/Melon :: t (fheap)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 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_fheap_new(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

; 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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mln_fheap_remove_child(ptr noundef) #3

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @fheap_test() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 10, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %16 = call ptr @mln_fheap_new(ptr noundef %3, ptr noundef null)
  store ptr %16, ptr %4, align 8, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %0
  %20 = load ptr, ptr @stderr, align 8, !tbaa !9
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str) #5
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %196

22:                                               ; preds = %0
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  %24 = call ptr @mln_fheap_node_new(ptr noundef %23, ptr noundef %2)
  store ptr %24, ptr %5, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %30

27:                                               ; preds = %22
  %28 = load ptr, ptr @stderr, align 8, !tbaa !9
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.2) #5
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %196

30:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr @cmp_handler, ptr %7, align 8, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %37

33:                                               ; preds = %30
  %34 = load ptr, ptr %4, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.mln_fheap_t, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  store ptr %36, ptr %7, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %33, %30
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.mln_fheap_t, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  call void @mln_fheap_add_child(ptr noundef %39, ptr noundef %40)
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %41, i32 0, i32 1
  store ptr null, ptr %42, align 8, !tbaa !14
  %43 = load ptr, ptr %4, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.mln_fheap_t, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %51

47:                                               ; preds = %37
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.mln_fheap_t, ptr %49, i32 0, i32 1
  store ptr %48, ptr %50, align 8, !tbaa !16
  br label %68

51:                                               ; preds = %37
  %52 = load ptr, ptr %7, align 8, !tbaa !9
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.mln_fheap_t, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  %59 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = call i32 %52(ptr noundef %55, ptr noundef %60)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %67, label %63

63:                                               ; preds = %51
  %64 = load ptr, ptr %5, align 8, !tbaa !9
  %65 = load ptr, ptr %4, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.mln_fheap_t, ptr %65, i32 0, i32 1
  store ptr %64, ptr %66, align 8, !tbaa !16
  br label %67

67:                                               ; preds = %63, %51
  br label %68

68:                                               ; preds = %67, %47
  %69 = load ptr, ptr %4, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.mln_fheap_t, ptr %69, i32 0, i32 5
  %71 = load i64, ptr %70, align 8, !tbaa !18
  %72 = add i64 %71, 1
  store i64 %72, ptr %70, align 8, !tbaa !18
  store i64 %72, ptr %8, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %73 = load i64, ptr %8, align 8, !tbaa !19
  %74 = load ptr, ptr %4, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.mln_fheap_t, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !16
  store ptr %76, ptr %5, align 8, !tbaa !9
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !17
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %80)
  %82 = load ptr, ptr %4, align 8, !tbaa !9
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %195

84:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  br label %85

85:                                               ; preds = %181, %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store ptr @cmp_handler, ptr %10, align 8, !tbaa !9
  %86 = load ptr, ptr %10, align 8, !tbaa !9
  %87 = icmp eq ptr %86, null
  br i1 %87, label %88, label %92

88:                                               ; preds = %85
  %89 = load ptr, ptr %4, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.mln_fheap_t, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !11
  store ptr %91, ptr %10, align 8, !tbaa !9
  br label %92

92:                                               ; preds = %88, %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %93 = load ptr, ptr %4, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.mln_fheap_t, ptr %93, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !16
  store ptr %95, ptr %11, align 8, !tbaa !9
  %96 = load ptr, ptr %11, align 8, !tbaa !9
  %97 = icmp ne ptr %96, null
  br i1 %97, label %98, label %134

98:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  br label %99

99:                                               ; preds = %104, %98
  %100 = load ptr, ptr %11, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %100, i32 0, i32 2
  %102 = call ptr @mln_fheap_remove_child(ptr noundef %101)
  store ptr %102, ptr %12, align 8, !tbaa !9
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %110

104:                                              ; preds = %99
  %105 = load ptr, ptr %4, align 8, !tbaa !9
  %106 = getelementptr inbounds %struct.mln_fheap_t, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %12, align 8, !tbaa !9
  call void @mln_fheap_add_child(ptr noundef %106, ptr noundef %107)
  %108 = load ptr, ptr %12, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %108, i32 0, i32 1
  store ptr null, ptr %109, align 8, !tbaa !14
  br label %99, !llvm.loop !20

110:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %111 = load ptr, ptr %11, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %111, i32 0, i32 4
  %113 = load ptr, ptr %112, align 8, !tbaa !22
  store ptr %113, ptr %13, align 8, !tbaa !9
  %114 = load ptr, ptr %4, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.mln_fheap_t, ptr %114, i32 0, i32 0
  %116 = load ptr, ptr %11, align 8, !tbaa !9
  call void @mln_fheap_del_child(ptr noundef %115, ptr noundef %116)
  %117 = load ptr, ptr %11, align 8, !tbaa !9
  %118 = load ptr, ptr %13, align 8, !tbaa !9
  %119 = icmp eq ptr %117, %118
  br i1 %119, label %120, label %123

120:                                              ; preds = %110
  %121 = load ptr, ptr %4, align 8, !tbaa !9
  %122 = getelementptr inbounds %struct.mln_fheap_t, ptr %121, i32 0, i32 1
  store ptr null, ptr %122, align 8, !tbaa !16
  br label %129

123:                                              ; preds = %110
  %124 = load ptr, ptr %13, align 8, !tbaa !9
  %125 = load ptr, ptr %4, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.mln_fheap_t, ptr %125, i32 0, i32 1
  store ptr %124, ptr %126, align 8, !tbaa !16
  %127 = load ptr, ptr %4, align 8, !tbaa !9
  %128 = load ptr, ptr %10, align 8, !tbaa !9
  call void @mln_fheap_consolidate(ptr noundef %127, ptr noundef %128)
  br label %129

129:                                              ; preds = %123, %120
  %130 = load ptr, ptr %4, align 8, !tbaa !9
  %131 = getelementptr inbounds %struct.mln_fheap_t, ptr %130, i32 0, i32 5
  %132 = load i64, ptr %131, align 8, !tbaa !18
  %133 = add i64 %132, -1
  store i64 %133, ptr %131, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %134

134:                                              ; preds = %129, %92
  %135 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %135, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %136 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %136, ptr %9, align 8, !tbaa !9
  %137 = icmp ne ptr %136, null
  br i1 %137, label %138, label %182

138:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store ptr null, ptr %15, align 8, !tbaa !9
  %139 = load ptr, ptr %15, align 8, !tbaa !9
  %140 = icmp eq ptr %139, null
  br i1 %140, label %141, label %145

141:                                              ; preds = %138
  %142 = load ptr, ptr %4, align 8, !tbaa !9
  %143 = getelementptr inbounds %struct.mln_fheap_t, ptr %142, i32 0, i32 4
  %144 = load ptr, ptr %143, align 8, !tbaa !23
  store ptr %144, ptr %15, align 8, !tbaa !9
  br label %145

145:                                              ; preds = %141, %138
  %146 = load ptr, ptr %9, align 8, !tbaa !9
  %147 = icmp ne ptr %146, null
  br i1 %147, label %148, label %181

148:                                              ; preds = %145
  %149 = load ptr, ptr %15, align 8, !tbaa !9
  %150 = icmp ne ptr %149, null
  br i1 %150, label %151, label %161

151:                                              ; preds = %148
  %152 = load ptr, ptr %9, align 8, !tbaa !9
  %153 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %152, i32 0, i32 0
  %154 = load ptr, ptr %153, align 8, !tbaa !17
  %155 = icmp ne ptr %154, null
  br i1 %155, label %156, label %161

156:                                              ; preds = %151
  %157 = load ptr, ptr %15, align 8, !tbaa !9
  %158 = load ptr, ptr %9, align 8, !tbaa !9
  %159 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %158, i32 0, i32 0
  %160 = load ptr, ptr %159, align 8, !tbaa !17
  call void %157(ptr noundef %160)
  br label %161

161:                                              ; preds = %156, %151, %148
  %162 = load ptr, ptr %9, align 8, !tbaa !9
  %163 = getelementptr inbounds %struct.mln_fheap_node_s, ptr %162, i32 0, i32 6
  %164 = load i32, ptr %163, align 8
  %165 = and i32 %164, 1
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %180, label %167

167:                                              ; preds = %161
  %168 = load ptr, ptr %4, align 8, !tbaa !9
  %169 = getelementptr inbounds %struct.mln_fheap_t, ptr %168, i32 0, i32 7
  %170 = load ptr, ptr %169, align 8, !tbaa !24
  %171 = icmp ne ptr %170, null
  br i1 %171, label %172, label %177

172:                                              ; preds = %167
  %173 = load ptr, ptr %4, align 8, !tbaa !9
  %174 = getelementptr inbounds %struct.mln_fheap_t, ptr %173, i32 0, i32 9
  %175 = load ptr, ptr %174, align 8, !tbaa !25
  %176 = load ptr, ptr %9, align 8, !tbaa !9
  call void %175(ptr noundef %176)
  br label %179

177:                                              ; preds = %167
  %178 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %178) #5
  br label %179

179:                                              ; preds = %177, %172
  br label %180

180:                                              ; preds = %179, %161
  br label %181

181:                                              ; preds = %180, %145
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %85, !llvm.loop !26

182:                                              ; preds = %134
  %183 = load ptr, ptr %4, align 8, !tbaa !9
  %184 = getelementptr inbounds %struct.mln_fheap_t, ptr %183, i32 0, i32 7
  %185 = load ptr, ptr %184, align 8, !tbaa !24
  %186 = icmp ne ptr %185, null
  br i1 %186, label %187, label %192

187:                                              ; preds = %182
  %188 = load ptr, ptr %4, align 8, !tbaa !9
  %189 = getelementptr inbounds %struct.mln_fheap_t, ptr %188, i32 0, i32 9
  %190 = load ptr, ptr %189, align 8, !tbaa !25
  %191 = load ptr, ptr %4, align 8, !tbaa !9
  call void %190(ptr noundef %191)
  br label %194

192:                                              ; preds = %182
  %193 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %193) #5
  br label %194

194:                                              ; preds = %192, %187
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %195

195:                                              ; preds = %194, %68
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %196

196:                                              ; preds = %195, %27, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %197 = load i32, ptr %1, align 4
  ret i32 %197
}

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

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

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 = { 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 = { 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 #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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"mln_fheap_node_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 48}
!16 = !{!12, !10, i64 8}
!17 = !{!15, !10, i64 0}
!18 = !{!12, !13, i64 40}
!19 = !{!13, !13, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!15, !10, i64 32}
!23 = !{!12, !10, i64 32}
!24 = !{!12, !10, i64 56}
!25 = !{!12, !10, i64 72}
!26 = distinct !{!26, !21}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 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_fheap_new(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

; 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 #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mln_fheap_remove_child(ptr noundef) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @fheap_test() local_unnamed_addr #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 10, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = call ptr @mln_fheap_new(ptr noundef nonnull %2, ptr noundef null) #6
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %8

5:                                                ; preds = %0
  %6 = load ptr, ptr @stderr, align 8, !tbaa !9
  %7 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str) #7
  br label %72

8:                                                ; preds = %0
  %9 = call ptr @mln_fheap_node_new(ptr noundef nonnull %3, ptr noundef nonnull %1) #6
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %8
  %12 = load ptr, ptr @stderr, align 8, !tbaa !9
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.2) #7
  br label %72

14:                                               ; preds = %8
  call void @mln_fheap_add_child(ptr noundef nonnull %3, ptr noundef nonnull %9)
  %15 = getelementptr inbounds i8, ptr %9, i64 8
  store ptr null, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %3, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  store ptr %9, ptr %16, align 8, !tbaa !14
  br label %25

20:                                               ; preds = %14
  %21 = load ptr, ptr %9, align 8, !tbaa !16
  %22 = load ptr, ptr %17, align 8, !tbaa !16
  %23 = call i32 @cmp_handler(ptr noundef %21, ptr noundef %22)
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %24, label %._crit_edge77

._crit_edge77:                                    ; preds = %20
  %.pre = load ptr, ptr %16, align 8, !tbaa !14
  br label %25

24:                                               ; preds = %20
  store ptr %9, ptr %16, align 8, !tbaa !14
  br label %25

25:                                               ; preds = %._crit_edge77, %24, %19
  %26 = phi ptr [ %.pre, %._crit_edge77 ], [ %9, %24 ], [ %9, %19 ]
  %27 = getelementptr inbounds i8, ptr %3, i64 40
  %28 = load i64, ptr %27, align 8, !tbaa !17
  %29 = add i64 %28, 1
  store i64 %29, ptr %27, align 8, !tbaa !17
  %30 = load ptr, ptr %26, align 8, !tbaa !16
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %31)
  %33 = load ptr, ptr %16, align 8, !tbaa !14
  %.not6876 = icmp eq ptr %33, null
  br i1 %.not6876, label %.critedge, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %25
  %34 = getelementptr inbounds i8, ptr %3, i64 32
  %35 = getelementptr inbounds i8, ptr %3, i64 56
  %36 = getelementptr inbounds i8, ptr %3, i64 72
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %64
  %37 = phi ptr [ %33, %.preheader.lr.ph ], [ %65, %64 ]
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  %39 = call ptr @mln_fheap_remove_child(ptr noundef nonnull %38)
  %.not6975 = icmp eq ptr %39, null
  br i1 %.not6975, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %40 = phi ptr [ %42, %.lr.ph ], [ %39, %.preheader ]
  call void @mln_fheap_add_child(ptr noundef nonnull %3, ptr noundef nonnull %40)
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  store ptr null, ptr %41, align 8, !tbaa !11
  %42 = call ptr @mln_fheap_remove_child(ptr noundef nonnull %38)
  %.not69 = icmp eq ptr %42, null
  br i1 %.not69, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %43 = getelementptr inbounds i8, ptr %37, i64 32
  %44 = load ptr, ptr %43, align 8, !tbaa !20
  call void @mln_fheap_del_child(ptr noundef nonnull %3, ptr noundef nonnull %37)
  %45 = icmp eq ptr %37, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %._crit_edge
  store ptr null, ptr %16, align 8, !tbaa !14
  br label %48

47:                                               ; preds = %._crit_edge
  store ptr %44, ptr %16, align 8, !tbaa !14
  call void @mln_fheap_consolidate(ptr noundef nonnull %3, ptr noundef nonnull @cmp_handler)
  br label %48

48:                                               ; preds = %46, %47
  %49 = load i64, ptr %27, align 8, !tbaa !17
  %50 = add i64 %49, -1
  store i64 %50, ptr %27, align 8, !tbaa !17
  %51 = load ptr, ptr %34, align 8, !tbaa !21
  %.not71 = icmp eq ptr %51, null
  br i1 %.not71, label %55, label %52

52:                                               ; preds = %48
  %53 = load ptr, ptr %37, align 8, !tbaa !16
  %.not72 = icmp eq ptr %53, null
  br i1 %.not72, label %55, label %54

54:                                               ; preds = %52
  call void %51(ptr noundef nonnull %53) #6
  br label %55

55:                                               ; preds = %54, %52, %48
  %56 = getelementptr inbounds i8, ptr %37, i64 48
  %57 = load i32, ptr %56, align 8
  %58 = and i32 %57, 1
  %.not73 = icmp eq i32 %58, 0
  br i1 %.not73, label %59, label %64

59:                                               ; preds = %55
  %60 = load ptr, ptr %35, align 8, !tbaa !22
  %.not74 = icmp eq ptr %60, null
  br i1 %.not74, label %63, label %61

61:                                               ; preds = %59
  %62 = load ptr, ptr %36, align 8, !tbaa !23
  call void %62(ptr noundef nonnull %37) #6
  br label %64

63:                                               ; preds = %59
  call void @free(ptr noundef nonnull %37) #6
  br label %64

64:                                               ; preds = %55, %63, %61
  %65 = load ptr, ptr %16, align 8, !tbaa !14
  %.not68 = icmp eq ptr %65, null
  br i1 %.not68, label %.critedge, label %.preheader, !llvm.loop !24

.critedge:                                        ; preds = %64, %25
  %66 = getelementptr inbounds i8, ptr %3, i64 56
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  %.not70 = icmp eq ptr %67, null
  br i1 %.not70, label %71, label %68

68:                                               ; preds = %.critedge
  %69 = getelementptr inbounds i8, ptr %3, i64 72
  %70 = load ptr, ptr %69, align 8, !tbaa !23
  call void %70(ptr noundef nonnull %3) #6
  br label %72

71:                                               ; preds = %.critedge
  call void @free(ptr noundef nonnull %3) #6
  br label %72

72:                                               ; preds = %71, %68, %11, %5
  %.058 = phi i32 [ -1, %5 ], [ -1, %11 ], [ 0, %68 ], [ 0, %71 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 %.058
}

declare ptr @mln_fheap_node_new(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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 = { 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 #3 = { 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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { cold 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"mln_fheap_node_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 48}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!16 = !{!12, !10, i64 0}
!17 = !{!15, !13, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !10, i64 32}
!21 = !{!15, !10, i64 32}
!22 = !{!15, !10, i64 56}
!23 = !{!15, !10, i64 72}
!24 = distinct !{!24, !19}


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