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

; 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.mln_fileset_s = type { ptr, ptr, ptr, ptr, i64 }

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_fileset_init(i64 noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca %struct.mln_rbtree_attr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %7 = call noalias ptr @malloc(i64 noundef 40) #6
  store ptr %7, ptr %5, align 8, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !9
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %45

11:                                               ; preds = %1
  %12 = call ptr @mln_alloc_init(ptr noundef null, i64 noundef 0)
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.mln_fileset_s, ptr %13, i32 0, i32 0
  store ptr %12, ptr %14, align 8, !tbaa !11
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.mln_fileset_s, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %21

19:                                               ; preds = %11
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %20) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %45

21:                                               ; preds = %11
  %22 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 0
  store ptr null, ptr %22, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 1
  store ptr null, ptr %23, align 8, !tbaa !15
  %24 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 2
  store ptr null, ptr %24, align 8, !tbaa !16
  %25 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 3
  store ptr @mln_file_set_cmp, ptr %25, align 8, !tbaa !17
  %26 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 4
  store ptr @mln_file_free, ptr %26, align 8, !tbaa !18
  %27 = call ptr @mln_rbtree_new(ptr noundef %4)
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.mln_fileset_s, ptr %28, i32 0, i32 1
  store ptr %27, ptr %29, align 8, !tbaa !19
  %30 = icmp eq ptr %27, null
  br i1 %30, label %31, label %36

31:                                               ; preds = %21
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.mln_fileset_s, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  call void @mln_alloc_destroy(ptr noundef %34)
  %35 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %35) #5
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %45

36:                                               ; preds = %21
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.mln_fileset_s, ptr %37, i32 0, i32 3
  store ptr null, ptr %38, align 8, !tbaa !20
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.mln_fileset_s, ptr %39, i32 0, i32 2
  store ptr null, ptr %40, align 8, !tbaa !21
  %41 = load i64, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.mln_fileset_s, ptr %42, i32 0, i32 4
  store i64 %41, ptr %43, align 8, !tbaa !22
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %44, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %45

45:                                               ; preds = %36, %31, %19, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #5
  %46 = load ptr, ptr %2, align 8
  ret ptr %46
}

; 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

declare ptr @mln_alloc_init(ptr noundef, i64 noundef) #3

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

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

; Function Attrs: nounwind uwtable
declare hidden void @mln_file_free(ptr noundef) #0

declare ptr @mln_rbtree_new(ptr noundef) #3

declare void @mln_alloc_destroy(ptr noundef) #3

; 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 = { "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 "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 }
attributes #6 = { 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 = !{!"long", !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 0}
!12 = !{!"mln_fileset_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32}
!13 = !{!14, !10, i64 0}
!14 = !{!"mln_rbtree_attr", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !10, i64 16}
!17 = !{!14, !10, i64 24}
!18 = !{!14, !10, i64 32}
!19 = !{!12, !10, i64 8}
!20 = !{!12, !10, i64 24}
!21 = !{!12, !10, i64 16}
!22 = !{!12, !6, i64 32}


; 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.mln_rbtree_attr = type { ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @mln_fileset_init(i64 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.mln_rbtree_attr, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #6
  %3 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #7
  %4 = icmp eq ptr %3, null
  br i1 %4, label %19, label %5

5:                                                ; preds = %1
  %6 = tail call ptr @mln_alloc_init(ptr noundef null, i64 noundef 0) #6
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %5
  tail call void @free(ptr noundef nonnull %3) #6
  br label %19

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %2, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, i8 0, i64 24, i1 false)
  store ptr @mln_file_set_cmp, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %2, i64 32
  store ptr @mln_file_free, ptr %11, align 8, !tbaa !13
  %12 = call ptr @mln_rbtree_new(ptr noundef nonnull %2) #6
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %12, ptr %13, align 8, !tbaa !14
  %14 = icmp eq ptr %12, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %9
  call void @mln_alloc_destroy(ptr noundef nonnull %6) #6
  call void @free(ptr noundef nonnull %3) #6
  br label %19

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %3, i64 16
  %18 = getelementptr inbounds i8, ptr %3, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  store i64 %0, ptr %18, align 8, !tbaa !15
  br label %19

19:                                               ; preds = %1, %16, %15, %8
  %.0 = phi ptr [ null, %8 ], [ null, %15 ], [ %3, %16 ], [ null, %1 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #6
  ret ptr %.0
}

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

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

declare ptr @mln_alloc_init(ptr noundef, i64 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
declare hidden i32 @mln_file_set_cmp(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @mln_file_free(ptr noundef) #0

declare ptr @mln_rbtree_new(ptr noundef) local_unnamed_addr #3

declare void @mln_alloc_destroy(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) #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 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { 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, !7, i64 0}
!6 = !{!"mln_fileset_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !7, i64 24}
!12 = !{!"mln_rbtree_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!13 = !{!12, !7, i64 32}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !10, i64 32}


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