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

; 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 }
%struct.net_iface = type { ptr, ptr, i32 }
%struct.net_device = type { ptr, ptr, i32, [16 x i8], i16, i16, i16, i16, i16, [16 x i8], %union.anon, ptr, ptr }
%union.anon = type { [16 x i8] }

@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
@.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.12 = external hidden unnamed_addr constant [14 x i8], align 1
@__func__.tcp_send = external hidden unnamed_addr constant [9 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [19 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

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

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

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

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

; 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) #1

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

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

declare ptr @ip_route_get_iface(i32 noundef) #1

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

20:                                               ; preds = %3
  %21 = load ptr, ptr @stderr, align 8, !tbaa !9
  %22 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %21, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1214, ptr noundef @__func__.tcp_send, ptr noundef @.str.12)
  %23 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

24:                                               ; preds = %3
  br label %25

25:                                               ; preds = %98, %24
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.tcp_pcb, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !13
  switch i32 %28, label %164 [
    i32 1, label %29
    i32 2, label %33
    i32 3, label %37
    i32 4, label %37
    i32 5, label %41
    i32 10, label %41
    i32 6, label %160
    i32 7, label %160
    i32 8, label %160
    i32 11, label %160
    i32 9, label %160
  ]

29:                                               ; preds = %25
  %30 = load ptr, ptr @stderr, align 8, !tbaa !9
  %31 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %30, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1221, ptr noundef @__func__.tcp_send, ptr noundef @.str.23)
  %32 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

33:                                               ; preds = %25
  %34 = load ptr, ptr @stderr, align 8, !tbaa !9
  %35 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %34, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1226, ptr noundef @__func__.tcp_send, ptr noundef @.str.24)
  %36 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

37:                                               ; preds = %25, %25
  %38 = load ptr, ptr @stderr, align 8, !tbaa !9
  %39 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %38, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1232, ptr noundef @__func__.tcp_send, ptr noundef @.str.25)
  %40 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

41:                                               ; preds = %25, %25
  %42 = load ptr, ptr %8, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.tcp_pcb, ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds %struct.ip_endpoint, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !22
  %46 = call ptr @ip_route_get_iface(i32 noundef %45)
  store ptr %46, ptr %10, align 8, !tbaa !9
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = icmp ne ptr %47, null
  br i1 %48, label %53, label %49

49:                                               ; preds = %41
  %50 = load ptr, ptr @stderr, align 8, !tbaa !9
  %51 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %50, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1239, ptr noundef @__func__.tcp_send, ptr noundef @.str.26)
  %52 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

53:                                               ; preds = %41
  %54 = load ptr, ptr %10, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.net_iface, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = getelementptr inbounds %struct.net_device, ptr %56, i32 0, i32 5
  %58 = load i16, ptr %57, align 2, !tbaa !25
  %59 = zext i16 %58 to i64
  %60 = sub i64 %59, 40
  store i64 %60, ptr %11, align 8, !tbaa !11
  br label %61

61:                                               ; preds = %147, %53
  %62 = load i64, ptr %9, align 8, !tbaa !11
  %63 = load i64, ptr %7, align 8, !tbaa !11
  %64 = icmp slt i64 %62, %63
  br i1 %64, label %65, label %159

65:                                               ; preds = %61
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.tcp_pcb, ptr %66, i32 0, i32 4
  %68 = getelementptr inbounds %struct.anon, ptr %67, i32 0, i32 2
  %69 = load i16, ptr %68, align 8, !tbaa !27
  %70 = zext i16 %69 to i32
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.tcp_pcb, ptr %71, i32 0, i32 4
  %73 = getelementptr inbounds %struct.anon, ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !28
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.tcp_pcb, ptr %75, i32 0, i32 4
  %77 = getelementptr inbounds %struct.anon, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !29
  %79 = sub i32 %74, %78
  %80 = sub i32 %70, %79
  %81 = zext i32 %80 to i64
  store i64 %81, ptr %12, align 8, !tbaa !11
  %82 = load i64, ptr %12, align 8, !tbaa !11
  %83 = icmp ne i64 %82, 0
  br i1 %83, label %99, label %84

84:                                               ; preds = %65
  %85 = load ptr, ptr %8, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.tcp_pcb, ptr %85, i32 0, i32 11
  %87 = call i32 @sched_sleep(ptr noundef %86, ptr noundef @mutex, ptr noundef null)
  %88 = icmp eq i32 %87, -1
  br i1 %88, label %89, label %98

89:                                               ; preds = %84
  %90 = load ptr, ptr @stderr, align 8, !tbaa !9
  %91 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %90, i32 noundef 68, ptr noundef @.str.1, i32 noundef 1248, ptr noundef @__func__.tcp_send, ptr noundef @.str.9)
  %92 = load i64, ptr %9, align 8, !tbaa !11
  %93 = icmp ne i64 %92, 0
  br i1 %93, label %97, label %94

94:                                               ; preds = %89
  %95 = call i32 @mutex_unlock(ptr noundef @mutex)
  %96 = call ptr @__errno_location() #6
  store i32 4, ptr %96, align 4, !tbaa !5
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

97:                                               ; preds = %89
  br label %159

98:                                               ; preds = %84
  br label %25

99:                                               ; preds = %65
  %100 = load i64, ptr %11, align 8, !tbaa !11
  %101 = load i64, ptr %7, align 8, !tbaa !11
  %102 = load i64, ptr %9, align 8, !tbaa !11
  %103 = sub i64 %101, %102
  %104 = icmp ult i64 %100, %103
  br i1 %104, label %105, label %107

105:                                              ; preds = %99
  %106 = load i64, ptr %11, align 8, !tbaa !11
  br label %111

107:                                              ; preds = %99
  %108 = load i64, ptr %7, align 8, !tbaa !11
  %109 = load i64, ptr %9, align 8, !tbaa !11
  %110 = sub i64 %108, %109
  br label %111

111:                                              ; preds = %107, %105
  %112 = phi i64 [ %106, %105 ], [ %110, %107 ]
  %113 = load i64, ptr %12, align 8, !tbaa !11
  %114 = icmp ult i64 %112, %113
  br i1 %114, label %115, label %129

115:                                              ; preds = %111
  %116 = load i64, ptr %11, align 8, !tbaa !11
  %117 = load i64, ptr %7, align 8, !tbaa !11
  %118 = load i64, ptr %9, align 8, !tbaa !11
  %119 = sub i64 %117, %118
  %120 = icmp ult i64 %116, %119
  br i1 %120, label %121, label %123

121:                                              ; preds = %115
  %122 = load i64, ptr %11, align 8, !tbaa !11
  br label %127

123:                                              ; preds = %115
  %124 = load i64, ptr %7, align 8, !tbaa !11
  %125 = load i64, ptr %9, align 8, !tbaa !11
  %126 = sub i64 %124, %125
  br label %127

127:                                              ; preds = %123, %121
  %128 = phi i64 [ %122, %121 ], [ %126, %123 ]
  br label %131

129:                                              ; preds = %111
  %130 = load i64, ptr %12, align 8, !tbaa !11
  br label %131

131:                                              ; preds = %129, %127
  %132 = phi i64 [ %128, %127 ], [ %130, %129 ]
  store i64 %132, ptr %13, align 8, !tbaa !11
  %133 = load ptr, ptr %8, align 8, !tbaa !9
  %134 = load ptr, ptr %6, align 8, !tbaa !9
  %135 = load i64, ptr %9, align 8, !tbaa !11
  %136 = getelementptr inbounds i8, ptr %134, i64 %135
  %137 = load i64, ptr %13, align 8, !tbaa !11
  %138 = call i64 @tcp_output(ptr noundef %133, i8 noundef zeroext 24, ptr noundef %136, i64 noundef %137)
  %139 = icmp eq i64 %138, -1
  br i1 %139, label %140, label %147

140:                                              ; preds = %131
  %141 = load ptr, ptr @stderr, align 8, !tbaa !9
  %142 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %141, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1260, ptr noundef @__func__.tcp_send, ptr noundef @.str.8)
  %143 = load ptr, ptr %8, align 8, !tbaa !9
  %144 = getelementptr inbounds %struct.tcp_pcb, ptr %143, i32 0, i32 0
  store i32 1, ptr %144, align 8, !tbaa !13
  %145 = load ptr, ptr %8, align 8, !tbaa !9
  call void @tcp_pcb_release(ptr noundef %145)
  %146 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

147:                                              ; preds = %131
  %148 = load i64, ptr %13, align 8, !tbaa !11
  %149 = load ptr, ptr %8, align 8, !tbaa !9
  %150 = getelementptr inbounds %struct.tcp_pcb, ptr %149, i32 0, i32 4
  %151 = getelementptr inbounds %struct.anon, ptr %150, i32 0, i32 0
  %152 = load i32, ptr %151, align 8, !tbaa !28
  %153 = zext i32 %152 to i64
  %154 = add i64 %153, %148
  %155 = trunc i64 %154 to i32
  store i32 %155, ptr %151, align 8, !tbaa !28
  %156 = load i64, ptr %13, align 8, !tbaa !11
  %157 = load i64, ptr %9, align 8, !tbaa !11
  %158 = add i64 %157, %156
  store i64 %158, ptr %9, align 8, !tbaa !11
  br label %61, !llvm.loop !30

159:                                              ; preds = %97, %61
  br label %171

160:                                              ; preds = %25, %25, %25, %25, %25
  %161 = load ptr, ptr @stderr, align 8, !tbaa !9
  %162 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %161, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1275, ptr noundef @__func__.tcp_send, ptr noundef @.str.27)
  %163 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

164:                                              ; preds = %25
  %165 = load ptr, ptr @stderr, align 8, !tbaa !9
  %166 = load ptr, ptr %8, align 8, !tbaa !9
  %167 = getelementptr inbounds %struct.tcp_pcb, ptr %166, i32 0, i32 0
  %168 = load i32, ptr %167, align 8, !tbaa !13
  %169 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %165, i32 noundef 69, ptr noundef @.str.1, i32 noundef 1279, ptr noundef @__func__.tcp_send, ptr noundef @.str.28, i32 noundef %168)
  %170 = call i32 @mutex_unlock(ptr noundef @mutex)
  store i64 -1, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

171:                                              ; preds = %159
  %172 = call i32 @mutex_unlock(ptr noundef @mutex)
  %173 = load i64, ptr %9, align 8, !tbaa !11
  store i64 %173, ptr %4, align 8
  store i32 1, ptr %14, align 4
  br label %174

174:                                              ; preds = %171, %164, %160, %140, %94, %49, %37, %33, %29, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %175 = load i64, ptr %4, align 8
  ret i64 %175
}

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 = { 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 #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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"tcp_pcb", !6, i64 0, !6, i64 4, !15, i64 8, !15, i64 16, !17, i64 24, !6, i64 44, !18, i64 48, !6, i64 56, !16, i64 60, !16, i64 62, !7, i64 64, !19, i64 65600, !20, i64 65656, !21, i64 65680, !10, i64 65696, !20, i64 65704}
!15 = !{!"ip_endpoint", !6, i64 0, !16, i64 4}
!16 = !{!"short", !7, i64 0}
!17 = !{!"", !6, i64 0, !6, i64 4, !16, i64 8, !16, i64 10, !6, i64 12, !6, i64 16}
!18 = !{!"", !6, i64 0, !16, i64 4, !16, i64 6}
!19 = !{!"sched_ctx", !7, i64 0, !6, i64 48, !6, i64 52}
!20 = !{!"queue_head", !10, i64 0, !10, i64 8, !6, i64 16}
!21 = !{!"timeval", !12, i64 0, !12, i64 8}
!22 = !{!14, !6, i64 8}
!23 = !{!24, !10, i64 8}
!24 = !{!"net_iface", !10, i64 0, !10, i64 8, !6, i64 16}
!25 = !{!26, !16, i64 38}
!26 = !{!"net_device", !10, i64 0, !10, i64 8, !6, i64 16, !7, i64 20, !16, i64 36, !16, i64 38, !16, i64 40, !16, i64 42, !16, i64 44, !7, i64 46, !7, i64 62, !10, i64 80, !10, i64 88}
!27 = !{!14, !16, i64 32}
!28 = !{!14, !6, i64 24}
!29 = !{!14, !6, i64 28}
!30 = distinct !{!30, !31}
!31 = !{!"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
@.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.12 = external hidden unnamed_addr constant [14 x i8], align 1
@__func__.tcp_send = external hidden unnamed_addr constant [9 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [19 x i8], align 1

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

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

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

; 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 #0

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

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

declare ptr @ip_route_get_iface(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @tcp_send(i32 noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = tail call i32 @mutex_lock(ptr noundef nonnull @mutex)
  %5 = tail call ptr @tcp_pcb_get(i32 noundef %0)
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %11, label %.preheader

.preheader:                                       ; preds = %3
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = getelementptr inbounds i8, ptr %5, i64 24
  %8 = getelementptr inbounds i8, ptr %5, i64 32
  %9 = getelementptr inbounds i8, ptr %5, i64 28
  %10 = getelementptr inbounds i8, ptr %5, i64 65600
  br label %15

11:                                               ; preds = %3
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %12, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1214, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.12) #5
  %14 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

15:                                               ; preds = %.preheader, %49
  %.040 = phi i64 [ %.159, %49 ], [ 0, %.preheader ]
  %16 = load i32, ptr %5, align 8, !tbaa !9
  switch i32 %16, label %79 [
    i32 1, label %17
    i32 2, label %21
    i32 3, label %25
    i32 4, label %25
    i32 5, label %29
    i32 10, label %29
    i32 6, label %75
    i32 7, label %75
    i32 8, label %75
    i32 11, label %75
    i32 9, label %75
  ]

17:                                               ; preds = %15
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %18, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1221, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.23) #5
  %20 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

21:                                               ; preds = %15
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %22, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1226, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.24) #5
  %24 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

25:                                               ; preds = %15, %15
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %26, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1232, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.25) #5
  %28 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

29:                                               ; preds = %15, %15
  %30 = load i32, ptr %6, align 8, !tbaa !20
  %31 = tail call ptr @ip_route_get_iface(i32 noundef %30) #5
  %.not45 = icmp eq ptr %31, null
  br i1 %.not45, label %32, label %36

32:                                               ; preds = %29
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %33, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1239, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.26) #5
  %35 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

36:                                               ; preds = %29
  %37 = getelementptr inbounds i8, ptr %31, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %38, i64 38
  %40 = load i16, ptr %39, align 2, !tbaa !23
  %41 = zext i16 %40 to i64
  %42 = add nsw i64 %41, -40
  %43 = icmp slt i64 %.040, %2
  br i1 %43, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %36
  %.pre = load i32, ptr %7, align 8, !tbaa !25
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %69
  %44 = phi i32 [ %72, %69 ], [ %.pre, %.lr.ph.preheader ]
  %.159 = phi i64 [ %73, %69 ], [ %.040, %.lr.ph.preheader ]
  %45 = load i16, ptr %8, align 8, !tbaa !26
  %46 = zext i16 %45 to i32
  %47 = load i32, ptr %9, align 4, !tbaa !27
  %.neg = sub i32 %47, %44
  %48 = add i32 %.neg, %46
  %.not46 = icmp eq i32 %48, 0
  br i1 %.not46, label %49, label %58

49:                                               ; preds = %.lr.ph
  %50 = tail call i32 @sched_sleep(ptr noundef nonnull %10, ptr noundef nonnull @mutex, ptr noundef null) #5
  %51 = icmp eq i32 %50, -1
  br i1 %51, label %52, label %15

52:                                               ; preds = %49
  %53 = load ptr, ptr @stderr, align 8, !tbaa !5
  %54 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %53, i32 noundef 68, ptr noundef nonnull @.str.1, i32 noundef 1248, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.9) #5
  %.not47 = icmp eq i64 %.159, 0
  br i1 %.not47, label %55, label %.loopexit

55:                                               ; preds = %52
  %56 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  %57 = tail call ptr @__errno_location() #6
  store i32 4, ptr %57, align 4, !tbaa !28
  br label %84

58:                                               ; preds = %.lr.ph
  %59 = zext i32 %48 to i64
  %60 = sub i64 %2, %.159
  %61 = tail call i64 @llvm.umin.i64(i64 %42, i64 %60)
  %. = tail call i64 @llvm.umin.i64(i64 %61, i64 %59)
  %62 = getelementptr inbounds i8, ptr %1, i64 %.159
  %63 = tail call i64 @tcp_output(ptr noundef nonnull %5, i8 noundef zeroext 24, ptr noundef %62, i64 noundef %.)
  %64 = icmp eq i64 %63, -1
  br i1 %64, label %65, label %69

65:                                               ; preds = %58
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %66, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1260, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.8) #5
  store i32 1, ptr %5, align 8, !tbaa !9
  tail call void @tcp_pcb_release(ptr noundef nonnull %5)
  %68 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

69:                                               ; preds = %58
  %70 = load i32, ptr %7, align 8, !tbaa !25
  %71 = trunc nuw i64 %. to i32
  %72 = add i32 %70, %71
  store i32 %72, ptr %7, align 8, !tbaa !25
  %73 = add i64 %., %.159
  %74 = icmp slt i64 %73, %2
  br i1 %74, label %.lr.ph, label %.loopexit, !llvm.loop !29

75:                                               ; preds = %15, %15, %15, %15, %15
  %76 = load ptr, ptr @stderr, align 8, !tbaa !5
  %77 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %76, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1275, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.27) #5
  %78 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

79:                                               ; preds = %15
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  %81 = tail call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %80, i32 noundef 69, ptr noundef nonnull @.str.1, i32 noundef 1279, ptr noundef nonnull @__func__.tcp_send, ptr noundef nonnull @.str.28, i32 noundef %16) #5
  %82 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

.loopexit:                                        ; preds = %36, %69, %52
  %.150 = phi i64 [ %.159, %52 ], [ %73, %69 ], [ %.040, %36 ]
  %83 = tail call i32 @mutex_unlock(ptr noundef nonnull @mutex)
  br label %84

84:                                               ; preds = %.loopexit, %79, %75, %65, %55, %32, %25, %21, %17, %11
  %.0 = phi i64 [ -1, %79 ], [ -1, %75 ], [ -1, %65 ], [ %.150, %.loopexit ], [ -1, %55 ], [ -1, %32 ], [ -1, %25 ], [ -1, %21 ], [ -1, %17 ], [ -1, %11 ]
  ret i64 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #4

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 = { 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 #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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { 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 0}
!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, !11, i64 8}
!21 = !{!22, !6, i64 8}
!22 = !{!"net_iface", !6, i64 0, !6, i64 8, !11, i64 16}
!23 = !{!24, !13, i64 38}
!24 = !{!"net_device", !6, i64 0, !6, i64 8, !11, i64 16, !7, i64 20, !13, i64 36, !13, i64 38, !13, i64 40, !13, i64 42, !13, i64 44, !7, i64 46, !7, i64 62, !6, i64 80, !6, i64 88}
!25 = !{!10, !11, i64 24}
!26 = !{!10, !13, i64 32}
!27 = !{!10, !11, i64 28}
!28 = !{!11, !11, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


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