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

@worker_list_head = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [66 x i8], align 1
@__FUNCTION__.mln_fork_master_events_set = external hidden unnamed_addr constant [27 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [28 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
define dso_local void @mln_fork_master_events_set(ptr noundef nonnull %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %4 = load ptr, ptr @worker_list_head, align 8, !tbaa !5
  store ptr %4, ptr %3, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %19, %1
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %23

8:                                                ; preds = %5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mln_fork_s, ptr %10, i32 0, i32 3
  %12 = getelementptr inbounds %struct.mln_tcp_conn_t, ptr %11, i32 0, i32 7
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call i32 @mln_event_fd_set(ptr noundef %9, i32 noundef %13, i32 noundef 17, i32 noundef -1, ptr noundef %14, ptr noundef @mln_ipc_fd_handler_master)
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %8
  call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef @.str, ptr noundef @__FUNCTION__.mln_fork_master_events_set, i32 noundef 464, ptr noundef @.str.20)
  call void @abort() #5
  unreachable

18:                                               ; preds = %8
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mln_fork_s, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  store ptr %22, ptr %3, align 8, !tbaa !5
  br label %5, !llvm.loop !15

23:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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

; Function Attrs: nounwind uwtable
declare dso_local void @mln_ipc_fd_handler_master(ptr noundef, i32 noundef, ptr 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, !12, i64 80}
!10 = !{!"mln_fork_s", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !13, i64 112, !6, i64 120, !12, i64 128, !12, i64 132}
!11 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@worker_list_head = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [66 x i8], align 1
@__FUNCTION__.mln_fork_master_events_set = external hidden unnamed_addr constant [27 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [28 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
define dso_local void @mln_fork_master_events_set(ptr noundef nonnull %0) local_unnamed_addr #2 {
  %.05 = load ptr, ptr @worker_list_head, align 8, !tbaa !5
  %.not6 = icmp eq ptr %.05, null
  br i1 %.not6, label %._crit_edge, label %.lr.ph

2:                                                ; preds = %.lr.ph
  %3 = getelementptr inbounds i8, ptr %.07, i64 8
  %.0 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

.lr.ph:                                           ; preds = %1, %2
  %.07 = phi ptr [ %.0, %2 ], [ %.05, %1 ]
  %4 = getelementptr inbounds i8, ptr %.07, i64 80
  %5 = load i32, ptr %4, align 8, !tbaa !11
  %6 = tail call i32 @mln_event_fd_set(ptr noundef nonnull %0, i32 noundef %5, i32 noundef 17, i32 noundef -1, ptr noundef nonnull %.07, ptr noundef nonnull @mln_ipc_fd_handler_master) #3
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %8, label %2

8:                                                ; preds = %.lr.ph
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_mln_sys_log(i32 noundef 4, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.mln_fork_master_events_set, i32 noundef 464, ptr noundef nonnull @.str.20) #3
  tail call void @abort() #4
  unreachable

._crit_edge:                                      ; preds = %2, %1
  ret void
}

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
declare dso_local void @mln_ipc_fd_handler_master(ptr noundef, i32 noundef, ptr noundef) #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !14, i64 80}
!12 = !{!"mln_fork_s", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 88, !14, i64 92, !14, i64 96, !14, i64 100, !14, i64 104, !15, i64 112, !6, i64 120, !14, i64 128, !14, i64 132}
!13 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 56}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long", !7, i64 0}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass