; LLVM IR from pandax381/microps :: tcp (tcp_open_rfc793)

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

%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.tcp_pcb = type { i32, i32, %struct.ip_endpoint, %struct.ip_endpoint, %struct.anon, i32, %struct.anon.0, i32, i16, i16, [65535 x i8], %struct.sched_ctx, %struct.queue_head, %struct.timeval, ptr, %struct.queue_head }
%struct.ip_endpoint = type { i32, i16 }
%struct.anon = type { i32, i32, i16, i16, i32, i32 }
%struct.anon.0 = type { i32, i16, i16 }
%struct.sched_ctx = type { %union.pthread_cond_t, i32, i32 }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.timeval = type { i64, i64 }
%struct.queue_head = type { ptr, ptr, i32 }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@mutex = external hidden global %union.pthread_mutex_t, align 8
@__func__.tcp_open_rfc793 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tcp_open_rfc793(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca [22 x i8], align 16
  %10 = alloca [22 x i8], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 22, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 22, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %14 = call i32 @mutex_lock(ptr noundef @mutex)
  %15 = call ptr @tcp_pcb_alloc()
  store ptr %15, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %22, label %18

18:                                               ; preds = %3
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %19, i32 noundef 69, ptr noundef @.str.1, i32 noundef 902, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.5)
  %21 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %154

22:                                               ; preds = %3
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.tcp_pcb, ptr %23, i32 0, i32 1
  store i32 1, ptr %24, align 4, !tbaa !11
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %45, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds [22 x i8], ptr %9, i64 0, i64 0
  %31 = call ptr @ip_endpoint_ntop(ptr noundef %29, ptr noundef %30, i64 noundef 22)
  %32 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %28, i32 noundef 68, ptr noundef @.str.1, i32 noundef 908, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.6, ptr noundef %31)
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.tcp_pcb, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 4 %35, i64 8, i1 false), !tbaa.struct !21
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %42

38:                                               ; preds = %27
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.tcp_pcb, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %40, ptr align 4 %41, i64 8, i1 false), !tbaa.struct !21
  br label %42

42:                                               ; preds = %38, %27
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tcp_pcb, ptr %43, i32 0, i32 0
  store i32 2, ptr %44, align 8, !tbaa !23
  br label %93

45:                                               ; preds = %22
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds [22 x i8], ptr %9, i64 0, i64 0
  %49 = call ptr @ip_endpoint_ntop(ptr noundef %47, ptr noundef %48, i64 noundef 22)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds [22 x i8], ptr %10, i64 0, i64 0
  %52 = call ptr @ip_endpoint_ntop(ptr noundef %50, ptr noundef %51, i64 noundef 22)
  %53 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %46, i32 noundef 68, ptr noundef @.str.1, i32 noundef 916, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.7, ptr noundef %49, ptr noundef %52)
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.tcp_pcb, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %55, ptr align 4 %56, i64 8, i1 false), !tbaa.struct !21
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.tcp_pcb, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %58, ptr align 4 %59, i64 8, i1 false), !tbaa.struct !21
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.tcp_pcb, ptr %60, i32 0, i32 6
  %62 = getelementptr inbounds %struct.anon.0, ptr %61, i32 0, i32 1
  store i16 -1, ptr %62, align 4, !tbaa !24
  %63 = call i64 @random() #7
  %64 = trunc i64 %63 to i32
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.tcp_pcb, ptr %65, i32 0, i32 5
  store i32 %64, ptr %66, align 4, !tbaa !25
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = call i64 @tcp_output(ptr noundef %67, i8 noundef zeroext 2, ptr noundef null, i64 noundef 0)
  %69 = icmp eq i64 %68, -1
  br i1 %69, label %70, label %77

70:                                               ; preds = %45
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %71, i32 noundef 69, ptr noundef @.str.1, i32 noundef 922, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.8)
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.tcp_pcb, ptr %73, i32 0, i32 0
  store i32 1, ptr %74, align 8, !tbaa !23
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  call void @tcp_pcb_release(ptr noundef %75)
  %76 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %154

77:                                               ; preds = %45
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.tcp_pcb, ptr %78, i32 0, i32 5
  %80 = load i32, ptr %79, align 4, !tbaa !25
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.tcp_pcb, ptr %81, i32 0, i32 4
  %83 = getelementptr inbounds %struct.anon, ptr %82, i32 0, i32 1
  store i32 %80, ptr %83, align 4, !tbaa !26
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.tcp_pcb, ptr %84, i32 0, i32 5
  %86 = load i32, ptr %85, align 4, !tbaa !25
  %87 = add i32 %86, 1
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.tcp_pcb, ptr %88, i32 0, i32 4
  %90 = getelementptr inbounds %struct.anon, ptr %89, i32 0, i32 0
  store i32 %87, ptr %90, align 8, !tbaa !27
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.tcp_pcb, ptr %91, i32 0, i32 0
  store i32 3, ptr %92, align 8, !tbaa !23
  br label %93

93:                                               ; preds = %77, %42
  br label %94

94:                                               ; preds = %128, %93
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.tcp_pcb, ptr %95, i32 0, i32 0
  %97 = load i32, ptr %96, align 8, !tbaa !23
  store i32 %97, ptr %11, align 4, !tbaa !9
  br label %98

98:                                               ; preds = %117, %94
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.tcp_pcb, ptr %99, i32 0, i32 0
  %101 = load i32, ptr %100, align 8, !tbaa !23
  %102 = load i32, ptr %11, align 4, !tbaa !9
  %103 = icmp eq i32 %101, %102
  br i1 %103, label %104, label %118

104:                                              ; preds = %98
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.tcp_pcb, ptr %105, i32 0, i32 11
  %107 = call i32 @sched_sleep(ptr noundef %106, ptr noundef @mutex, ptr noundef null)
  %108 = icmp eq i32 %107, -1
  br i1 %108, label %109, label %117

109:                                              ; preds = %104
  %110 = load ptr, ptr @stderr, align 8, !tbaa !5
  %111 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %110, i32 noundef 68, ptr noundef @.str.1, i32 noundef 937, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.9)
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.tcp_pcb, ptr %112, i32 0, i32 0
  store i32 1, ptr %113, align 8, !tbaa !23
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  call void @tcp_pcb_release(ptr noundef %114)
  %115 = call i32 @mutex_unlock(ptr noundef @mutex)
  %116 = call ptr @__errno_location() #8
  store i32 4, ptr %116, align 4, !tbaa !9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %154

117:                                              ; preds = %104
  br label %98, !llvm.loop !28

118:                                              ; preds = %98
  %119 = load ptr, ptr %8, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.tcp_pcb, ptr %119, i32 0, i32 0
  %121 = load i32, ptr %120, align 8, !tbaa !23
  %122 = icmp ne i32 %121, 5
  br i1 %122, label %123, label %139

123:                                              ; preds = %118
  %124 = load ptr, ptr %8, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.tcp_pcb, ptr %124, i32 0, i32 0
  %126 = load i32, ptr %125, align 8, !tbaa !23
  %127 = icmp eq i32 %126, 4
  br i1 %127, label %128, label %129

128:                                              ; preds = %123
  br label %94

129:                                              ; preds = %123
  %130 = load ptr, ptr @stderr, align 8, !tbaa !5
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.tcp_pcb, ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !23
  %134 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %130, i32 noundef 69, ptr noundef @.str.1, i32 noundef 949, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.10, i32 noundef %133)
  %135 = load ptr, ptr %8, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.tcp_pcb, ptr %135, i32 0, i32 0
  store i32 1, ptr %136, align 8, !tbaa !23
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  call void @tcp_pcb_release(ptr noundef %137)
  %138 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %154

139:                                              ; preds = %118
  %140 = load ptr, ptr %8, align 8, !tbaa !5
  %141 = call i32 @tcp_pcb_id(ptr noundef %140)
  store i32 %141, ptr %12, align 4, !tbaa !9
  %142 = load ptr, ptr @stderr, align 8, !tbaa !5
  %143 = load ptr, ptr %8, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.tcp_pcb, ptr %143, i32 0, i32 2
  %145 = getelementptr inbounds [22 x i8], ptr %9, i64 0, i64 0
  %146 = call ptr @ip_endpoint_ntop(ptr noundef %144, ptr noundef %145, i64 noundef 22)
  %147 = load ptr, ptr %8, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.tcp_pcb, ptr %147, i32 0, i32 3
  %149 = getelementptr inbounds [22 x i8], ptr %10, i64 0, i64 0
  %150 = call ptr @ip_endpoint_ntop(ptr noundef %148, ptr noundef %149, i64 noundef 22)
  %151 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %142, i32 noundef 68, ptr noundef @.str.1, i32 noundef 957, ptr noundef @__func__.tcp_open_rfc793, ptr noundef @.str.11, ptr noundef %146, ptr noundef %150)
  %152 = call i32 @mutex_unlock(ptr noundef @mutex)
  %153 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %153, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %154

154:                                              ; preds = %139, %129, %109, %70, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 22, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 22, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %155 = load i32, ptr %4, align 4
  ret i32 %155
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mutex_lock(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden ptr @tcp_pcb_alloc() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mutex_unlock(ptr noundef) #4

declare ptr @ip_endpoint_ntop(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind
declare i64 @random() #5

; Function Attrs: nounwind uwtable
declare hidden i64 @tcp_output(ptr noundef, i8 noundef zeroext, ptr noundef, i64 noundef) #3

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

declare i32 @sched_sleep(ptr noundef, ptr noundef, ptr noundef) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { inlinehint 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 #5 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }

!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 4}
!12 = !{!"tcp_pcb", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 16, !15, i64 24, !10, i64 44, !16, i64 48, !10, i64 56, !14, i64 60, !14, i64 62, !7, i64 64, !17, i64 65600, !18, i64 65656, !19, i64 65680, !6, i64 65696, !18, i64 65704}
!13 = !{!"ip_endpoint", !10, i64 0, !14, i64 4}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !10, i64 0, !10, i64 4, !14, i64 8, !14, i64 10, !10, i64 12, !10, i64 16}
!16 = !{!"", !10, i64 0, !14, i64 4, !14, i64 6}
!17 = !{!"sched_ctx", !7, i64 0, !10, i64 48, !10, i64 52}
!18 = !{!"queue_head", !6, i64 0, !6, i64 8, !10, i64 16}
!19 = !{!"timeval", !20, i64 0, !20, i64 8}
!20 = !{!"long", !7, i64 0}
!21 = !{i64 0, i64 4, !9, i64 4, i64 2, !22}
!22 = !{!14, !14, i64 0}
!23 = !{!12, !10, i64 0}
!24 = !{!12, !14, i64 52}
!25 = !{!12, !10, i64 44}
!26 = !{!12, !10, i64 28}
!27 = !{!12, !10, i64 24}
!28 = distinct !{!28, !29}
!29 = !{!"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"

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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@mutex = external hidden global %union.pthread_mutex_t, align 8
@__func__.tcp_open_rfc793 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1

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

declare i32 @lprintf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tcp_open_rfc793(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca [22 x i8], align 16
  %5 = alloca [22 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 22, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 22, ptr nonnull %5) #6
  %6 = tail call i32 @mutex_lock(ptr noundef nonnull @mutex)
  %7 = tail call ptr @tcp_pcb_alloc()
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %12

8:                                                ; preds = %3
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %9, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 902, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.5) #6
  %11 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %72

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 1, ptr %13, align 4, !tbaa !9
  %.not44 = icmp eq i32 %2, 0
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = call ptr @ip_endpoint_ntop(ptr noundef %0, ptr noundef nonnull %4, i64 noundef 22) #6
  br i1 %.not44, label %16, label %23

16:                                               ; preds = %12
  %17 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %14, i32 noundef 68, ptr noundef nonnull @.str.1, i32 noundef 908, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.6, ptr noundef %15) #6
  %18 = getelementptr inbounds i8, ptr %7, i64 8
  %19 = load i64, ptr %0, align 4
  store i64 %19, ptr %18, align 8
  %.not45 = icmp eq ptr %1, null
  br i1 %.not45, label %45, label %20

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %7, i64 16
  %22 = load i64, ptr %1, align 4
  store i64 %22, ptr %21, align 8
  br label %45

23:                                               ; preds = %12
  %24 = call ptr @ip_endpoint_ntop(ptr noundef %1, ptr noundef nonnull %5, i64 noundef 22) #6
  %25 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %14, i32 noundef 68, ptr noundef nonnull @.str.1, i32 noundef 916, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.7, ptr noundef %15, ptr noundef %24) #6
  %26 = getelementptr inbounds i8, ptr %7, i64 8
  %27 = load i64, ptr %0, align 4
  store i64 %27, ptr %26, align 8
  %28 = getelementptr inbounds i8, ptr %7, i64 16
  %29 = load i64, ptr %1, align 4
  store i64 %29, ptr %28, align 8
  %30 = getelementptr inbounds i8, ptr %7, i64 52
  store i16 -1, ptr %30, align 4, !tbaa !20
  %31 = call i64 @random() #6
  %32 = trunc i64 %31 to i32
  %33 = getelementptr inbounds i8, ptr %7, i64 44
  store i32 %32, ptr %33, align 4, !tbaa !21
  %34 = call i64 @tcp_output(ptr noundef nonnull %7, i8 noundef zeroext 2, ptr noundef null, i64 noundef 0)
  %35 = icmp eq i64 %34, -1
  br i1 %35, label %36, label %40

36:                                               ; preds = %23
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %37, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 922, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.8) #6
  store i32 1, ptr %7, align 8, !tbaa !22
  call void @tcp_pcb_release(ptr noundef nonnull %7)
  %39 = call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %72

40:                                               ; preds = %23
  %41 = load i32, ptr %33, align 4, !tbaa !21
  %42 = getelementptr inbounds i8, ptr %7, i64 24
  %43 = getelementptr inbounds i8, ptr %7, i64 28
  store i32 %41, ptr %43, align 4, !tbaa !23
  %44 = add i32 %41, 1
  store i32 %44, ptr %42, align 8, !tbaa !24
  br label %45

45:                                               ; preds = %16, %20, %40
  %storemerge = phi i32 [ 3, %40 ], [ 2, %20 ], [ 2, %16 ]
  store i32 %storemerge, ptr %7, align 8, !tbaa !22
  %46 = getelementptr inbounds i8, ptr %7, i64 65600
  br label %47

47:                                               ; preds = %58, %45
  %48 = phi i32 [ %.pr, %58 ], [ %storemerge, %45 ]
  br label %50

thread-pre-split:                                 ; preds = %50
  %.pr = load i32, ptr %7, align 8, !tbaa !22
  %49 = icmp eq i32 %.pr, %48
  br i1 %49, label %50, label %58

50:                                               ; preds = %47, %thread-pre-split
  %51 = call i32 @sched_sleep(ptr noundef nonnull %46, ptr noundef nonnull @mutex, ptr noundef null) #6
  %52 = icmp eq i32 %51, -1
  br i1 %52, label %53, label %thread-pre-split, !llvm.loop !25

53:                                               ; preds = %50
  %54 = load ptr, ptr @stderr, align 8, !tbaa !5
  %55 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %54, i32 noundef 68, ptr noundef nonnull @.str.1, i32 noundef 937, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.9) #6
  store i32 1, ptr %7, align 8, !tbaa !22
  call void @tcp_pcb_release(ptr noundef nonnull %7)
  %56 = call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  %57 = tail call ptr @__errno_location() #7
  store i32 4, ptr %57, align 4, !tbaa !27
  br label %72

58:                                               ; preds = %thread-pre-split
  switch i32 %.pr, label %59 [
    i32 5, label %63
    i32 4, label %47
  ]

59:                                               ; preds = %58
  %60 = load ptr, ptr @stderr, align 8, !tbaa !5
  %61 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %60, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 949, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.10, i32 noundef %.pr) #6
  store i32 1, ptr %7, align 8, !tbaa !22
  call void @tcp_pcb_release(ptr noundef nonnull %7)
  %62 = call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %72

63:                                               ; preds = %58
  %64 = call i32 @tcp_pcb_id(ptr noundef nonnull %7)
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %7, i64 8
  %67 = call ptr @ip_endpoint_ntop(ptr noundef nonnull %66, ptr noundef nonnull %4, i64 noundef 22) #6
  %68 = getelementptr inbounds i8, ptr %7, i64 16
  %69 = call ptr @ip_endpoint_ntop(ptr noundef nonnull %68, ptr noundef nonnull %5, i64 noundef 22) #6
  %70 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %65, i32 noundef 68, ptr noundef nonnull @.str.1, i32 noundef 957, ptr noundef nonnull @__func__.tcp_open_rfc793, ptr noundef nonnull @.str.11, ptr noundef %67, ptr noundef %69) #6
  %71 = call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %72

72:                                               ; preds = %63, %59, %53, %36, %8
  %.0 = phi i32 [ -1, %36 ], [ -1, %53 ], [ -1, %59 ], [ %64, %63 ], [ -1, %8 ]
  call void @llvm.lifetime.end.p0(i64 22, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 22, ptr nonnull %4) #6
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mutex_lock(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden ptr @tcp_pcb_alloc() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mutex_unlock(ptr noundef) local_unnamed_addr #3

declare ptr @ip_endpoint_ntop(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i64 @random() local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i64 @tcp_output(ptr noundef, i8 noundef zeroext, ptr noundef, i64 noundef) local_unnamed_addr #2

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

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

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

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

attributes #0 = { mustprogress 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 = { inlinehint 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 "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 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 4}
!10 = !{!"tcp_pcb", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 16, !14, i64 24, !11, i64 44, !15, i64 48, !11, i64 56, !13, i64 60, !13, i64 62, !7, i64 64, !16, i64 65600, !17, i64 65656, !18, i64 65680, !6, i64 65696, !17, i64 65704}
!11 = !{!"int", !7, i64 0}
!12 = !{!"ip_endpoint", !11, i64 0, !13, i64 4}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 10, !11, i64 12, !11, i64 16}
!15 = !{!"", !11, i64 0, !13, i64 4, !13, i64 6}
!16 = !{!"sched_ctx", !7, i64 0, !11, i64 48, !11, i64 52}
!17 = !{!"queue_head", !6, i64 0, !6, i64 8, !11, i64 16}
!18 = !{!"timeval", !19, i64 0, !19, i64 8}
!19 = !{!"long", !7, i64 0}
!20 = !{!10, !13, i64 52}
!21 = !{!10, !11, i64 44}
!22 = !{!10, !11, i64 0}
!23 = !{!10, !11, i64 28}
!24 = !{!10, !11, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass