; 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_fork_s = type { ptr, ptr, ptr, %struct.mln_tcp_conn_t, i32, i32, i32, i32, i32, i64, ptr, i32, i32 }
%struct.mln_tcp_conn_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.mln_event_s = type { %union.pthread_mutex_t, %union.pthread_mutex_t, %union.pthread_mutex_t, ptr, ptr, i32, i32, %struct.fd_set, %struct.fd_set, %struct.fd_set, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.fd_set = type { [16 x i64] }

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@__FUNCTION__.mln_fork_socketpair_close_handler = external hidden unnamed_addr constant [34 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

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

; Function Attrs: noreturn nounwind
declare void @abort() #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_fork_spawn(i32 noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_fork_restart(ptr noundef) #3

declare i32 @mln_event_fd_set(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @mln_fork_socketpair_close_handler(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = call i32 @mln_event_fd_set(ptr noundef %12, i32 noundef %13, i32 noundef 128, i32 noundef -1, ptr noundef null, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mln_fork_s, ptr %15, i32 0, i32 11
  %17 = load i32, ptr %16, align 8, !tbaa !11
  store i32 %17, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mln_fork_s, ptr %18, i32 0, i32 12
  %20 = load i32, ptr %19, align 4, !tbaa !15
  store i32 %20, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mln_fork_s, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  store ptr %23, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mln_fork_s, ptr %24, i32 0, i32 5
  %26 = load i32, ptr %25, align 4, !tbaa !17
  store i32 %26, ptr %10, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %64

29:                                               ; preds = %3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mln_fork_destroy(ptr noundef %30, i32 noundef 0)
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %51

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = call i32 @mln_fork_restart(ptr noundef %34)
  store i32 %35, ptr %11, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 672, ptr noundef @.str.23)
  call void @abort() #5
  unreachable

39:                                               ; preds = %33
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %48

42:                                               ; preds = %39
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mln_event_s, ptr %43, i32 0, i32 5
  %45 = load i32, ptr %44, align 8
  %46 = and i32 %45, -2
  %47 = or i32 %46, 1
  store i32 %47, ptr %44, align 8
  br label %49

48:                                               ; preds = %39
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 1, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 677, ptr noundef @.str.24)
  br label %49

49:                                               ; preds = %48, %42
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %63

51:                                               ; preds = %29
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = call i32 @mln_fork_spawn(i32 noundef %52, ptr noundef %53, i32 noundef %54, ptr noundef %55)
  %57 = icmp slt i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %51
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 681, ptr noundef @.str.25)
  call void @abort() #5
  unreachable

59:                                               ; preds = %51
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds ptr, ptr %60, i64 0
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 1, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 684, ptr noundef @.str.26, ptr noundef %62)
  br label %63

63:                                               ; preds = %59, %50
  br label %66

64:                                               ; preds = %3
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mln_fork_destroy(ptr noundef %65, i32 noundef 1)
  br label %66

66:                                               ; preds = %64, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 128}
!12 = !{!"mln_fork_s", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !14, i64 112, !6, i64 120, !10, i64 128, !10, i64 132}
!13 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !10, i64 132}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !10, i64 92}


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

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@__FUNCTION__.mln_fork_socketpair_close_handler = external hidden unnamed_addr constant [34 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [21 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: noreturn nounwind
declare void @abort() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_fork_spawn(i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_fork_restart(ptr noundef) local_unnamed_addr #2

declare i32 @mln_event_fd_set(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @mln_fork_socketpair_close_handler(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = tail call i32 @mln_event_fd_set(ptr noundef nonnull %0, i32 noundef %2, i32 noundef 128, i32 noundef -1, ptr noundef null, ptr noundef null) #3
  %5 = getelementptr inbounds i8, ptr %1, i64 132
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %1, i64 92
  %10 = load i32, ptr %9, align 4, !tbaa !14
  %11 = icmp eq i32 %6, 1
  br i1 %11, label %12, label %33

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %1, i64 128
  %14 = load i32, ptr %13, align 8, !tbaa !15
  tail call void @mln_fork_destroy(ptr noundef nonnull %1, i32 noundef 0)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %27

16:                                               ; preds = %12
  %17 = tail call i32 @mln_fork_restart(ptr noundef nonnull %0)
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 672, ptr noundef nonnull @.str.23) #3
  tail call void @abort() #4
  unreachable

20:                                               ; preds = %16
  %21 = icmp eq i32 %17, 0
  br i1 %21, label %22, label %26

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %0, i64 136
  %24 = load i32, ptr %23, align 8
  %25 = or i32 %24, 1
  store i32 %25, ptr %23, align 8
  br label %34

26:                                               ; preds = %20
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 1, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 677, ptr noundef nonnull @.str.24) #3
  br label %34

27:                                               ; preds = %12
  %28 = tail call i32 @mln_fork_spawn(i32 noundef 1, ptr noundef %8, i32 noundef %10, ptr noundef nonnull %0)
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 681, ptr noundef nonnull @.str.25) #3
  tail call void @abort() #4
  unreachable

31:                                               ; preds = %27
  %32 = load ptr, ptr %8, align 8, !tbaa !16
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 1, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_socketpair_close_handler, i32 noundef 684, ptr noundef nonnull @.str.26, ptr noundef %32) #3
  br label %34

33:                                               ; preds = %3
  tail call void @mln_fork_destroy(ptr noundef nonnull %1, i32 noundef 1)
  br label %34

34:                                               ; preds = %26, %22, %31, %33
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @mln_fork_destroy(ptr noundef, i32 noundef) local_unnamed_addr #2

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 = { 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { 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, !11, i64 132}
!6 = !{!"mln_fork_s", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !12, i64 112, !7, i64 120, !11, i64 128, !11, i64 132}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !11, i64 56}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !11, i64 92}
!15 = !{!6, !11, i64 128}
!16 = !{!7, !7, i64 0}


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