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

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

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@master_conn = external dso_local global %struct.mln_tcp_conn_t, align 8
@__FUNCTION__.mln_fork_spawn = external hidden unnamed_addr constant [15 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [17 x i8], align 1

declare void @_mln_sys_log(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #1

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #2

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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_fork_spawn(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #5 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [256 x i8], align 16
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  %13 = load ptr, ptr %7, align 8, !tbaa !9
  %14 = getelementptr inbounds ptr, ptr %13, i64 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 0, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_spawn, i32 noundef 265, ptr noundef @.str.17, ptr noundef %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !9
  %20 = call i32 @do_fork_core(i32 noundef 1, i32 noundef %16, ptr noundef %17, i32 noundef %18, ptr noundef %19)
  store i32 %20, ptr %10, align 4, !tbaa !5
  %21 = load i32, ptr %10, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %4
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %54

24:                                               ; preds = %4
  %25 = load i32, ptr %10, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %52

27:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 256, ptr %12) #7
  call void @llvm.memset.p0.i64(ptr align 16 %12, i8 0, i64 256, i1 false)
  %28 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  %29 = load i32, ptr getelementptr inbounds (%struct.mln_tcp_conn_t, ptr @master_conn, i32 0, i32 7), align 8, !tbaa !11
  %30 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %28, i64 noundef 255, ptr noundef @.str.18, i32 noundef %29) #7
  %31 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  store ptr %31, ptr %35, align 8, !tbaa !9
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %40

38:                                               ; preds = %27
  %39 = load ptr, ptr %9, align 8, !tbaa !9
  call void @mln_event_free(ptr noundef %39)
  br label %40

40:                                               ; preds = %38, %27
  call void @mln_log_destroy()
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = getelementptr inbounds ptr, ptr %41, i64 0
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = call i32 @execv(ptr noundef %43, ptr noundef %44) #7
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %51

47:                                               ; preds = %40
  %48 = call ptr @__errno_location() #8
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = call ptr @strerror(i32 noundef %49) #7
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_spawn, i32 noundef 281, ptr noundef @.str.19, ptr noundef %50)
  call void @exit(i32 noundef 1) #9
  unreachable

51:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 256, ptr %12) #7
  br label %52

52:                                               ; preds = %51, %24
  br label %53

53:                                               ; preds = %52
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %54

54:                                               ; preds = %53, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %55 = load i32, ptr %5, align 4
  ret i32 %55
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #1

declare void @mln_event_free(ptr noundef) #0

declare void @mln_log_destroy() #0

; Function Attrs: nounwind
declare i32 @execv(ptr noundef, ptr noundef) #1

attributes #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 = { 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 #2 = { nounwind willreturn memory(none) "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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { 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, !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, !6, i64 56}
!12 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !6, i64 56}


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

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@master_conn = external dso_local local_unnamed_addr global %struct.mln_tcp_conn_t, align 8
@__FUNCTION__.mln_fork_spawn = external hidden unnamed_addr constant [15 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [17 x i8], align 1

declare void @_mln_sys_log(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #2

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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mln_fork_spawn(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #5 {
  %5 = alloca [256 x i8], align 16
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 0, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_spawn, i32 noundef 265, ptr noundef nonnull @.str.17, ptr noundef %6) #8
  %7 = tail call i32 @do_fork_core(i32 noundef 1, i32 noundef %0, ptr noundef nonnull %1, i32 noundef %2, ptr noundef %3)
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %26, label %9

9:                                                ; preds = %4
  %10 = icmp eq i32 %7, 0
  br i1 %10, label %11, label %26

11:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %5) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %5, i8 0, i64 256, i1 false)
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @master_conn, i64 56), align 8, !tbaa !9
  %13 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 255, ptr noundef nonnull @.str.18, i32 noundef %12) #8
  %14 = zext i32 %2 to i64
  %15 = getelementptr inbounds ptr, ptr %1, i64 %14
  store ptr %5, ptr %15, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %17, label %16

16:                                               ; preds = %11
  call void @mln_event_free(ptr noundef nonnull %3) #8
  br label %17

17:                                               ; preds = %16, %11
  call void @mln_log_destroy() #8
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  %19 = call i32 @execv(ptr noundef %18, ptr noundef nonnull %1) #8
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %25

21:                                               ; preds = %17
  %22 = tail call ptr @__errno_location() #9
  %23 = load i32, ptr %22, align 4, !tbaa !12
  %24 = call ptr @strerror(i32 noundef %23) #8
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_spawn, i32 noundef 281, ptr noundef nonnull @.str.19, ptr noundef %24) #8
  call void @exit(i32 noundef 1) #10
  unreachable

25:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %5) #8
  br label %26

26:                                               ; preds = %25, %9, %4
  %.0 = phi i32 [ -1, %4 ], [ 0, %9 ], [ 0, %25 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @do_fork_core(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #7

declare void @mln_event_free(ptr noundef) local_unnamed_addr #0

declare void @mln_log_destroy() local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare i32 @execv(ptr noundef, ptr noundef) local_unnamed_addr #7

attributes #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 = { 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 #2 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 56}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}


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