; LLVM IR from Water-Melon/Melon :: src (mln_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_attr = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mln_fheap_t = type { ptr, ptr, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr }

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

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.mln_fheap_attr, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %23

15:                                               ; preds = %10
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mln_fheap_attr, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mln_fheap_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 80)
  store ptr %22, ptr %6, align 8, !tbaa !5
  br label %25

23:                                               ; preds = %10, %2
  %24 = call noalias ptr @malloc(i64 noundef 80) #4
  store ptr %24, ptr %6, align 8, !tbaa !5
  br label %25

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

28:                                               ; preds = %25
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %87

29:                                               ; preds = %25
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %63

32:                                               ; preds = %29
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mln_fheap_attr, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mln_fheap_t, ptr %36, i32 0, i32 7
  store ptr %35, ptr %37, align 8, !tbaa !12
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mln_fheap_attr, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_fheap_t, ptr %41, i32 0, i32 8
  store ptr %40, ptr %42, align 8, !tbaa !15
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mln_fheap_attr, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mln_fheap_t, ptr %46, i32 0, i32 9
  store ptr %45, ptr %47, align 8, !tbaa !17
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mln_fheap_attr, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mln_fheap_t, ptr %51, i32 0, i32 2
  store ptr %50, ptr %52, align 8, !tbaa !19
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mln_fheap_attr, ptr %53, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_fheap_t, ptr %56, i32 0, i32 3
  store ptr %55, ptr %57, align 8, !tbaa !21
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mln_fheap_attr, ptr %58, i32 0, i32 5
  %60 = load ptr, ptr %59, align 8, !tbaa !22
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mln_fheap_t, ptr %61, i32 0, i32 4
  store ptr %60, ptr %62, align 8, !tbaa !23
  br label %76

63:                                               ; preds = %29
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mln_fheap_t, ptr %64, i32 0, i32 7
  store ptr null, ptr %65, align 8, !tbaa !12
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.mln_fheap_t, ptr %66, i32 0, i32 8
  store ptr null, ptr %67, align 8, !tbaa !15
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mln_fheap_t, ptr %68, i32 0, i32 9
  store ptr null, ptr %69, align 8, !tbaa !17
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mln_fheap_t, ptr %70, i32 0, i32 2
  store ptr null, ptr %71, align 8, !tbaa !19
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mln_fheap_t, ptr %72, i32 0, i32 3
  store ptr null, ptr %73, align 8, !tbaa !21
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mln_fheap_t, ptr %74, i32 0, i32 4
  store ptr null, ptr %75, align 8, !tbaa !23
  br label %76

76:                                               ; preds = %63, %32
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mln_fheap_t, ptr %78, i32 0, i32 6
  store ptr %77, ptr %79, align 8, !tbaa !24
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.mln_fheap_t, ptr %80, i32 0, i32 1
  store ptr null, ptr %81, align 8, !tbaa !25
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.mln_fheap_t, ptr %82, i32 0, i32 0
  store ptr null, ptr %83, align 8, !tbaa !26
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.mln_fheap_t, ptr %84, i32 0, i32 5
  store i64 0, ptr %85, align 8, !tbaa !27
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %86, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %87

87:                                               ; preds = %76, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %88 = load ptr, ptr %3, align 8
  ret ptr %88
}

; 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_fheap_attr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !6, i64 56}
!13 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !6, i64 64}
!16 = !{!10, !6, i64 16}
!17 = !{!13, !6, i64 72}
!18 = !{!10, !6, i64 24}
!19 = !{!13, !6, i64 16}
!20 = !{!10, !6, i64 32}
!21 = !{!13, !6, i64 24}
!22 = !{!10, !6, i64 40}
!23 = !{!13, !6, i64 32}
!24 = !{!13, !6, i64 48}
!25 = !{!13, !6, i64 8}
!26 = !{!13, !6, i64 0}
!27 = !{!13, !14, i64 40}


; 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_fheap_new(ptr noundef nonnull %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %5, label %3

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

5:                                                ; preds = %2
  %6 = tail call noalias dereferenceable_or_null(80) ptr @malloc(i64 noundef 80) #3
  %7 = icmp eq ptr %6, null
  br i1 %7, label %31, label %25

.thread41:                                        ; preds = %3
  %8 = tail call noalias dereferenceable_or_null(80) ptr @malloc(i64 noundef 80) #3
  %9 = icmp eq ptr %8, null
  br i1 %9, label %31, label %.thread37

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

.thread..thread37_crit_edge:                      ; preds = %.thread
  %.pre = load ptr, ptr %1, align 8, !tbaa !5
  br label %.thread37

.thread37:                                        ; preds = %.thread..thread37_crit_edge, %.thread41
  %14 = phi ptr [ %.pre, %.thread..thread37_crit_edge ], [ null, %.thread41 ]
  %.03640 = phi ptr [ %12, %.thread..thread37_crit_edge ], [ %8, %.thread41 ]
  %15 = getelementptr inbounds i8, ptr %.03640, i64 56
  store ptr %14, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = getelementptr inbounds i8, ptr %.03640, i64 64
  %18 = load <2 x ptr>, ptr %16, align 8, !tbaa !14
  store <2 x ptr> %18, ptr %17, align 8, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %1, i64 24
  %20 = getelementptr inbounds i8, ptr %.03640, i64 16
  %21 = load <2 x ptr>, ptr %19, align 8, !tbaa !14
  store <2 x ptr> %21, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %1, i64 40
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %.03640, i64 32
  store ptr %23, ptr %24, align 8, !tbaa !16
  br label %28

25:                                               ; preds = %5
  %26 = getelementptr inbounds i8, ptr %6, i64 56
  %27 = getelementptr inbounds i8, ptr %6, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %27, i8 0, i64 24, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %26, i8 0, i64 24, i1 false)
  br label %28

28:                                               ; preds = %25, %.thread37
  %.03639 = phi ptr [ %6, %25 ], [ %.03640, %.thread37 ]
  %29 = getelementptr inbounds i8, ptr %.03639, i64 48
  store ptr %0, ptr %29, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %.03639, i64 40
  store i64 0, ptr %30, align 8, !tbaa !18
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %.03639, i8 0, i64 16, i1 false)
  br label %31

31:                                               ; preds = %.thread41, %.thread, %5, %28
  %.031 = phi ptr [ %.03639, %28 ], [ null, %5 ], [ null, %.thread ], [ null, %.thread41 ]
  ret ptr %.031
}

; 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_fheap_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!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 56}
!12 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !13, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72}
!13 = !{!"long", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 40}
!16 = !{!12, !7, i64 32}
!17 = !{!12, !7, i64 48}
!18 = !{!12, !13, i64 40}


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