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

; 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_framework_attr = type { i32, ptr, ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_framework_init(ptr noundef nonnull %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = call i32 @mln_conf_load()
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i32 -1, ptr %2, align 4
  br label %75

9:                                                ; preds = %1
  %10 = call ptr @mln_conf_hook_set(ptr noundef @mln_log_reload, ptr noundef null)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  store i32 -1, ptr %2, align 4
  br label %75

13:                                               ; preds = %9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mln_framework_attr, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %25

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mln_framework_attr, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call i32 %21()
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %18
  store i32 -1, ptr %2, align 4
  br label %75

25:                                               ; preds = %18, %13
  %26 = call ptr @mln_get_framework_status()
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %69

28:                                               ; preds = %25
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mln_framework_attr, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !12
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.mln_framework_attr, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = call i32 @mln_boot_params(i32 noundef %31, ptr noundef %34)
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %28
  store i32 -1, ptr %2, align 4
  br label %75

38:                                               ; preds = %28
  %39 = call i32 @mln_sys_limit_modify()
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 -1, ptr %2, align 4
  br label %75

42:                                               ; preds = %38
  %43 = call i32 @mln_daemon()
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str) #4
  store i32 -1, ptr %2, align 4
  br label %75

48:                                               ; preds = %42
  %49 = call i32 @mln_fork_prepare()
  %50 = icmp slt i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  store i32 -1, ptr %2, align 4
  br label %75

52:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %53 = call i32 @mln_fork()
  store i32 %53, ptr %4, align 4, !tbaa !14
  %54 = load i32, ptr %4, align 4, !tbaa !14
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %66

57:                                               ; preds = %52
  %58 = load i32, ptr %4, align 4, !tbaa !14
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %57
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mln_master_routine(ptr noundef %61)
  br label %63

62:                                               ; preds = %57
  br label %63

63:                                               ; preds = %62, %60
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mln_worker_routine(ptr noundef %64)
  br label %65

65:                                               ; preds = %63
  store i32 0, ptr %5, align 4
  br label %66

66:                                               ; preds = %65, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %67 = load i32, ptr %5, align 4
  switch i32 %67, label %77 [
    i32 0, label %68
    i32 1, label %75
  ]

68:                                               ; preds = %66
  br label %74

69:                                               ; preds = %25
  %70 = call i32 @mln_log_init(ptr noundef null)
  %71 = icmp slt i32 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %69
  store i32 -1, ptr %2, align 4
  br label %75

73:                                               ; preds = %69
  br label %74

74:                                               ; preds = %73, %68
  store i32 0, ptr %2, align 4
  br label %75

75:                                               ; preds = %74, %72, %66, %51, %45, %41, %37, %24, %12, %8
  %76 = load i32, ptr %2, align 4
  ret i32 %76

77:                                               ; preds = %66
  unreachable
}

declare i32 @mln_conf_load() #1

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

declare i32 @mln_log_reload(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @mln_get_framework_status() #0

declare i32 @mln_boot_params(i32 noundef, ptr noundef) #1

declare i32 @mln_sys_limit_modify() #1

declare i32 @mln_daemon() #1

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

declare i32 @mln_fork_prepare() #1

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

declare i32 @mln_fork() #1

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

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

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

declare i32 @mln_log_init(ptr noundef) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"mln_framework_attr", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!11, !11, 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mln_framework_init(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = tail call i32 @mln_conf_load() #3
  %3 = icmp slt i32 %2, 0
  br i1 %3, label %42, label %4

4:                                                ; preds = %1
  %5 = tail call ptr @mln_conf_hook_set(ptr noundef nonnull @mln_log_reload, ptr noundef null) #3
  %6 = icmp eq ptr %5, null
  br i1 %6, label %42, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %13, label %10

10:                                               ; preds = %7
  %11 = tail call i32 %9() #3
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %42, label %13

13:                                               ; preds = %10, %7
  %14 = tail call ptr @mln_get_framework_status()
  %.not12 = icmp eq ptr %14, null
  br i1 %.not12, label %38, label %15

15:                                               ; preds = %13
  %16 = load i32, ptr %0, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = tail call i32 @mln_boot_params(i32 noundef %16, ptr noundef %18) #3
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %42, label %21

21:                                               ; preds = %15
  %22 = tail call i32 @mln_sys_limit_modify() #3
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %42, label %24

24:                                               ; preds = %21
  %25 = tail call i32 @mln_daemon() #3
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load ptr, ptr @stderr, align 8, !tbaa !13
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str) #4
  br label %42

30:                                               ; preds = %24
  %31 = tail call i32 @mln_fork_prepare() #3
  %32 = icmp slt i32 %31, 0
  br i1 %32, label %42, label %33

33:                                               ; preds = %30
  %34 = tail call i32 @mln_fork() #3
  %35 = icmp slt i32 %34, 0
  br i1 %35, label %42, label %36

36:                                               ; preds = %33
  %.not13 = icmp eq i32 %34, 0
  br i1 %.not13, label %.thread, label %37

37:                                               ; preds = %36
  tail call void @mln_master_routine(ptr noundef nonnull %0)
  br label %.thread

.thread:                                          ; preds = %37, %36
  tail call void @mln_worker_routine(ptr noundef nonnull %0)
  br label %41

38:                                               ; preds = %13
  %39 = tail call i32 @mln_log_init(ptr noundef null) #3
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %42, label %41

41:                                               ; preds = %.thread, %38
  br label %42

42:                                               ; preds = %33, %38, %30, %21, %15, %10, %4, %1, %41, %27
  %.1 = phi i32 [ -1, %27 ], [ 0, %41 ], [ -1, %1 ], [ -1, %4 ], [ -1, %10 ], [ -1, %15 ], [ -1, %21 ], [ -1, %30 ], [ -1, %38 ], [ -1, %33 ]
  ret i32 %.1
}

declare i32 @mln_conf_load() local_unnamed_addr #1

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

declare i32 @mln_log_reload(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @mln_get_framework_status() local_unnamed_addr #0

declare i32 @mln_boot_params(i32 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @mln_sys_limit_modify() local_unnamed_addr #1

declare i32 @mln_daemon() local_unnamed_addr #1

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

declare i32 @mln_fork_prepare() local_unnamed_addr #1

declare i32 @mln_fork() local_unnamed_addr #1

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

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

declare i32 @mln_log_init(ptr noundef) local_unnamed_addr #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 = { "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 = { nounwind }
attributes #4 = { 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, !10, i64 16}
!6 = !{!"mln_framework_attr", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass