; 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_chain_s = type { ptr, ptr }
%struct.mln_buf_s = type { ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, ptr, i8 }

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_ipc_master_send_prepare(ptr noundef nonnull %0, i32 noundef %1, ptr noundef nonnull %2, i64 noundef %3, ptr noundef nonnull %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %20 = load i64, ptr %10, align 8, !tbaa !11
  %21 = add i64 4, %20
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mln_fork_s, ptr %23, i32 0, i32 3
  store ptr %24, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %25 = load ptr, ptr %17, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mln_tcp_conn_t, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  store ptr %27, ptr %18, align 8, !tbaa !5
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = add i64 %29, 4
  store i64 %30, ptr %16, align 8, !tbaa !11
  %31 = load ptr, ptr %18, align 8, !tbaa !5
  %32 = call ptr @mln_chain_new(ptr noundef %31)
  store ptr %32, ptr %14, align 8, !tbaa !5
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %36

35:                                               ; preds = %5
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %100

36:                                               ; preds = %5
  %37 = load ptr, ptr %18, align 8, !tbaa !5
  %38 = call ptr @mln_buf_new(ptr noundef %37)
  store ptr %38, ptr %15, align 8, !tbaa !5
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %43

41:                                               ; preds = %36
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  call void @mln_chain_pool_release(ptr noundef %42)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %100

43:                                               ; preds = %36
  %44 = load ptr, ptr %15, align 8, !tbaa !5
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mln_chain_s, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !15
  %47 = load ptr, ptr %18, align 8, !tbaa !5
  %48 = load i64, ptr %16, align 8, !tbaa !11
  %49 = call ptr @mln_alloc_m(ptr noundef %47, i64 noundef %48)
  store ptr %49, ptr %13, align 8, !tbaa !5
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %54

52:                                               ; preds = %43
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  call void @mln_chain_pool_release(ptr noundef %53)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %100

54:                                               ; preds = %43
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %15, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_buf_s, ptr %56, i32 0, i32 3
  store ptr %55, ptr %57, align 8, !tbaa !17
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mln_buf_s, ptr %58, i32 0, i32 1
  store ptr %55, ptr %59, align 8, !tbaa !19
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mln_buf_s, ptr %60, i32 0, i32 0
  store ptr %55, ptr %61, align 8, !tbaa !20
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = load i64, ptr %16, align 8, !tbaa !11
  %64 = getelementptr inbounds i8, ptr %62, i64 %63
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mln_buf_s, ptr %65, i32 0, i32 4
  store ptr %64, ptr %66, align 8, !tbaa !21
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.mln_buf_s, ptr %67, i32 0, i32 2
  store ptr %64, ptr %68, align 8, !tbaa !22
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.mln_buf_s, ptr %69, i32 0, i32 10
  %71 = load i8, ptr %70, align 8
  %72 = and i8 %71, -5
  %73 = or i8 %72, 4
  store i8 %73, ptr %70, align 8
  %74 = load ptr, ptr %15, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mln_buf_s, ptr %74, i32 0, i32 10
  %76 = load i8, ptr %75, align 8
  %77 = and i8 %76, -65
  %78 = or i8 %77, 64
  store i8 %78, ptr %75, align 8
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.mln_buf_s, ptr %79, i32 0, i32 10
  %81 = load i8, ptr %80, align 8
  %82 = and i8 %81, 127
  %83 = or i8 %82, -128
  store i8 %83, ptr %80, align 8
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %84, ptr align 4 %12, i64 4, i1 false)
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i64 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %86, ptr align 4 %8, i64 4, i1 false)
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 4
  %89 = getelementptr inbounds i8, ptr %88, i64 4
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = load i64, ptr %10, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %89, ptr align 1 %90, i64 %91, i1 false)
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load ptr, ptr %14, align 8, !tbaa !5
  call void @mln_tcp_conn_append(ptr noundef %92, ptr noundef %93, i32 noundef 1)
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = load ptr, ptr %17, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.mln_tcp_conn_t, ptr %95, i32 0, i32 7
  %97 = load i32, ptr %96, align 8, !tbaa !23
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = call i32 @mln_event_fd_set(ptr noundef %94, i32 noundef %97, i32 noundef 90, i32 noundef -1, ptr noundef %98, ptr noundef @mln_ipc_fd_handler_master_send)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %100

100:                                              ; preds = %54, %52, %41, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %101 = load i32, ptr %6, align 4
  ret i32 %101
}

declare ptr @mln_chain_new(ptr noundef) #1

declare ptr @mln_buf_new(ptr noundef) #1

declare void @mln_chain_pool_release(ptr noundef) #1

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare void @mln_tcp_conn_append(ptr noundef, ptr noundef, i32 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nocallback nofree 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56}
!15 = !{!16, !6, i64 0}
!16 = !{!"mln_chain_s", !6, i64 0, !6, i64 8}
!17 = !{!18, !6, i64 24}
!18 = !{!"mln_buf_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !6, i64 72, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80}
!19 = !{!18, !6, i64 8}
!20 = !{!18, !6, i64 0}
!21 = !{!18, !6, i64 32}
!22 = !{!18, !6, i64 16}
!23 = !{!14, !10, 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"

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 range(i32 -1, 1) i32 @mln_ipc_master_send_prepare(ptr noundef nonnull %0, i32 noundef %1, ptr nocapture noundef nonnull readonly %2, i64 noundef %3, ptr noundef nonnull %4) local_unnamed_addr #1 {
  %6 = trunc i64 %3 to i32
  %7 = add i32 %6, 4
  %8 = getelementptr inbounds i8, ptr %4, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = zext i32 %7 to i64
  %11 = add nuw nsw i64 %10, 4
  %12 = tail call ptr @mln_chain_new(ptr noundef %9) #3
  %13 = icmp eq ptr %12, null
  br i1 %13, label %36, label %14

14:                                               ; preds = %5
  %15 = tail call ptr @mln_buf_new(ptr noundef %9) #3
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  tail call void @mln_chain_pool_release(ptr noundef nonnull %12) #3
  br label %36

18:                                               ; preds = %14
  store ptr %15, ptr %12, align 8, !tbaa !11
  %19 = tail call ptr @mln_alloc_m(ptr noundef %9, i64 noundef %11) #3
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  tail call void @mln_chain_pool_release(ptr noundef nonnull %12) #3
  br label %36

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %15, i64 24
  store ptr %19, ptr %23, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %19, ptr %24, align 8, !tbaa !16
  store ptr %19, ptr %15, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %19, i64 %11
  %26 = getelementptr inbounds i8, ptr %15, i64 32
  store ptr %25, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %15, i64 16
  store ptr %25, ptr %27, align 8, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %15, i64 80
  %29 = load i8, ptr %28, align 8
  %30 = or i8 %29, -60
  store i8 %30, ptr %28, align 8
  store i32 %7, ptr %19, align 1
  %31 = getelementptr inbounds i8, ptr %19, i64 4
  store i32 %1, ptr %31, align 1
  %32 = getelementptr inbounds i8, ptr %19, i64 8
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %32, ptr nonnull align 1 %2, i64 %3, i1 false)
  tail call void @mln_tcp_conn_append(ptr noundef nonnull %8, ptr noundef nonnull %12, i32 noundef 1) #3
  %33 = getelementptr inbounds i8, ptr %4, i64 80
  %34 = load i32, ptr %33, align 8, !tbaa !20
  %35 = tail call i32 @mln_event_fd_set(ptr noundef nonnull %0, i32 noundef %34, i32 noundef 90, i32 noundef -1, ptr noundef nonnull %4, ptr noundef nonnull @mln_ipc_fd_handler_master_send) #3
  br label %36

36:                                               ; preds = %5, %22, %21, %17
  %.0 = phi i32 [ -1, %17 ], [ -1, %21 ], [ 0, %22 ], [ -1, %5 ]
  ret i32 %.0
}

declare ptr @mln_chain_new(ptr noundef) local_unnamed_addr #0

declare ptr @mln_buf_new(ptr noundef) local_unnamed_addr #0

declare void @mln_chain_pool_release(ptr noundef) local_unnamed_addr #0

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @mln_ipc_fd_handler_master_send(ptr noundef, i32 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 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"mln_chain_s", !7, i64 0, !7, i64 8}
!13 = !{!14, !7, i64 24}
!14 = !{!"mln_buf_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !7, i64 72, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80, !10, i64 80}
!15 = !{!"long", !8, i64 0}
!16 = !{!14, !7, i64 8}
!17 = !{!14, !7, i64 0}
!18 = !{!14, !7, i64 32}
!19 = !{!14, !7, i64 16}
!20 = !{!6, !10, i64 56}


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