; LLVM IR from pandax381/microps :: app (tcps)

; 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.sockaddr_in = type { i16, i16, i32 }

@__const.main.local = external hidden unnamed_addr constant %struct.sockaddr_in, align 4
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [62 x i8], align 1
@__func__.main = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@optarg = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@terminate = external hidden global i32, align 4
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca %struct.sockaddr_in, align 4
  %10 = alloca %struct.sockaddr_in, align 4
  %11 = alloca i32, align 4
  %12 = alloca [22 x i8], align 16
  %13 = alloca [1024 x i8], align 16
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 @__const.main.local, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 22, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 1024, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %16 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %16, label %54 [
    i32 3, label %17
    i32 2, label %32
  ]

17:                                               ; preds = %2
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 2
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds ptr, ptr %18, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.sockaddr_in, ptr %9, i32 0, i32 2
  %25 = call i32 @ip_addr_pton(ptr noundef %23, ptr noundef %24)
  %26 = icmp eq i32 %25, -1
  br i1 %26, label %27, label %31

27:                                               ; preds = %17
  %28 = load ptr, ptr @stderr, align 8, !tbaa !9
  %29 = load ptr, ptr @optarg, align 8, !tbaa !9
  %30 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %28, i32 noundef 69, ptr noundef @.str, i32 noundef 99, ptr noundef @__func__.main, ptr noundef @.str.1, ptr noundef %29)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

31:                                               ; preds = %17
  br label %32

32:                                               ; preds = %31, %2
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %33, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = call i64 @strtol(ptr noundef %38, ptr noundef null, i32 noundef 10) #6
  store i64 %39, ptr %8, align 8, !tbaa !11
  %40 = load i64, ptr %8, align 8, !tbaa !11
  %41 = icmp slt i64 %40, 0
  br i1 %41, label %45, label %42

42:                                               ; preds = %32
  %43 = load i64, ptr %8, align 8, !tbaa !11
  %44 = icmp sgt i64 %43, 65535
  br i1 %44, label %45, label %49

45:                                               ; preds = %42, %32
  %46 = load ptr, ptr @stderr, align 8, !tbaa !9
  %47 = load ptr, ptr @optarg, align 8, !tbaa !9
  %48 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %46, i32 noundef 69, ptr noundef @.str, i32 noundef 106, ptr noundef @__func__.main, ptr noundef @.str.2, ptr noundef %47)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

49:                                               ; preds = %42
  %50 = load i64, ptr %8, align 8, !tbaa !11
  %51 = trunc i64 %50 to i16
  %52 = call zeroext i16 @hton16(i16 noundef zeroext %51)
  %53 = getelementptr inbounds %struct.sockaddr_in, ptr %9, i32 0, i32 1
  store i16 %52, ptr %53, align 2, !tbaa !13
  br label %60

54:                                               ; preds = %2
  %55 = load ptr, ptr @stderr, align 8, !tbaa !9
  %56 = load ptr, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds ptr, ptr %56, i64 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.3, ptr noundef %58) #6
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

60:                                               ; preds = %49
  %61 = call i32 @setup()
  %62 = icmp eq i32 %61, -1
  br i1 %62, label %63, label %66

63:                                               ; preds = %60
  %64 = load ptr, ptr @stderr, align 8, !tbaa !9
  %65 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %64, i32 noundef 69, ptr noundef @.str, i32 noundef 119, ptr noundef @__func__.main, ptr noundef @.str.4)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

66:                                               ; preds = %60
  %67 = call i32 @sock_open(i32 noundef 2, i32 noundef 1, i32 noundef 0)
  store i32 %67, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = icmp eq i32 %68, -1
  br i1 %69, label %70, label %73

70:                                               ; preds = %66
  %71 = load ptr, ptr @stderr, align 8, !tbaa !9
  %72 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %71, i32 noundef 69, ptr noundef @.str, i32 noundef 127, ptr noundef @__func__.main, ptr noundef @.str.5)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

73:                                               ; preds = %66
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = call i32 @sock_bind(i32 noundef %74, ptr noundef %9, i32 noundef 8)
  %76 = icmp eq i32 %75, -1
  br i1 %76, label %77, label %80

77:                                               ; preds = %73
  %78 = load ptr, ptr @stderr, align 8, !tbaa !9
  %79 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %78, i32 noundef 69, ptr noundef @.str, i32 noundef 131, ptr noundef @__func__.main, ptr noundef @.str.6)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

80:                                               ; preds = %73
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = call i32 @sock_listen(i32 noundef %81, i32 noundef 1)
  %83 = icmp eq i32 %82, -1
  br i1 %83, label %84, label %87

84:                                               ; preds = %80
  %85 = load ptr, ptr @stderr, align 8, !tbaa !9
  %86 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %85, i32 noundef 69, ptr noundef @.str, i32 noundef 135, ptr noundef @__func__.main, ptr noundef @.str.7)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

87:                                               ; preds = %80
  store i32 4, ptr %11, align 4, !tbaa !5
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = call i32 @sock_accept(i32 noundef %88, ptr noundef %10, ptr noundef %11)
  store i32 %89, ptr %7, align 4, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = icmp eq i32 %90, -1
  br i1 %91, label %92, label %95

92:                                               ; preds = %87
  %93 = load ptr, ptr @stderr, align 8, !tbaa !9
  %94 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %93, i32 noundef 69, ptr noundef @.str, i32 noundef 141, ptr noundef @__func__.main, ptr noundef @.str.8)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

95:                                               ; preds = %87
  %96 = load ptr, ptr @stderr, align 8, !tbaa !9
  %97 = getelementptr inbounds [22 x i8], ptr %12, i64 0, i64 0
  %98 = call ptr @sockaddr_ntop(ptr noundef %10, ptr noundef %97, i64 noundef 22)
  %99 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %96, i32 noundef 73, ptr noundef @.str, i32 noundef 144, ptr noundef @__func__.main, ptr noundef @.str.9, ptr noundef %98)
  br label %100

100:                                              ; preds = %139, %114, %95
  %101 = load volatile i32, ptr @terminate, align 4, !tbaa !5
  %102 = icmp ne i32 %101, 0
  %103 = xor i1 %102, true
  br i1 %103, label %104, label %140

104:                                              ; preds = %100
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = getelementptr inbounds [1024 x i8], ptr %13, i64 0, i64 0
  %107 = call i64 @sock_recv(i32 noundef %105, ptr noundef %106, i64 noundef 1024)
  store i64 %107, ptr %14, align 8, !tbaa !11
  %108 = load i64, ptr %14, align 8, !tbaa !11
  %109 = icmp eq i64 %108, -1
  br i1 %109, label %110, label %118

110:                                              ; preds = %104
  %111 = call ptr @__errno_location() #7
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = icmp eq i32 %112, 4
  br i1 %113, label %114, label %115

114:                                              ; preds = %110
  br label %100, !llvm.loop !16

115:                                              ; preds = %110
  %116 = load ptr, ptr @stderr, align 8, !tbaa !9
  %117 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %116, i32 noundef 69, ptr noundef @.str, i32 noundef 151, ptr noundef @__func__.main, ptr noundef @.str.10)
  br label %140

118:                                              ; preds = %104
  %119 = load i64, ptr %14, align 8, !tbaa !11
  %120 = icmp eq i64 %119, 0
  br i1 %120, label %121, label %124

121:                                              ; preds = %118
  %122 = load ptr, ptr @stderr, align 8, !tbaa !9
  %123 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %122, i32 noundef 68, ptr noundef @.str, i32 noundef 155, ptr noundef @__func__.main, ptr noundef @.str.11)
  br label %140

124:                                              ; preds = %118
  %125 = load ptr, ptr @stderr, align 8, !tbaa !9
  %126 = load i64, ptr %14, align 8, !tbaa !11
  %127 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %125, i32 noundef 73, ptr noundef @.str, i32 noundef 158, ptr noundef @__func__.main, ptr noundef @.str.12, i64 noundef %126)
  %128 = load ptr, ptr @stderr, align 8, !tbaa !9
  %129 = getelementptr inbounds [1024 x i8], ptr %13, i64 0, i64 0
  %130 = load i64, ptr %14, align 8, !tbaa !11
  call void @hexdump(ptr noundef %128, ptr noundef %129, i64 noundef %130)
  %131 = load i32, ptr %7, align 4, !tbaa !5
  %132 = getelementptr inbounds [1024 x i8], ptr %13, i64 0, i64 0
  %133 = load i64, ptr %14, align 8, !tbaa !11
  %134 = call i64 @sock_send(i32 noundef %131, ptr noundef %132, i64 noundef %133)
  %135 = icmp eq i64 %134, -1
  br i1 %135, label %136, label %139

136:                                              ; preds = %124
  %137 = load ptr, ptr @stderr, align 8, !tbaa !9
  %138 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %137, i32 noundef 69, ptr noundef @.str, i32 noundef 161, ptr noundef @__func__.main, ptr noundef @.str.13)
  br label %140

139:                                              ; preds = %124
  br label %100, !llvm.loop !16

140:                                              ; preds = %136, %121, %115, %100
  %141 = load i32, ptr %7, align 4, !tbaa !5
  %142 = call i32 @sock_close(i32 noundef %141)
  %143 = load i32, ptr %6, align 4, !tbaa !5
  %144 = call i32 @sock_close(i32 noundef %143)
  call void @net_shutdown()
  store i32 0, ptr %3, align 4
  store i32 1, ptr %15, align 4
  br label %145

145:                                              ; preds = %140, %92, %84, %77, %70, %63, %54, %45, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 22, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %146 = load i32, ptr %3, align 4
  ret i32 %146
}

; 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 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 i32 @ip_addr_pton(ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #4

declare zeroext i16 @hton16(i16 noundef zeroext) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @setup() #0

declare i32 @sock_open(i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @sock_bind(i32 noundef, ptr noundef, i32 noundef) #3

declare i32 @sock_listen(i32 noundef, i32 noundef) #3

declare i32 @sock_accept(i32 noundef, ptr noundef, ptr noundef) #3

declare ptr @sockaddr_ntop(ptr noundef, ptr noundef, i64 noundef) #3

declare i64 @sock_recv(i32 noundef, ptr noundef, i64 noundef) #3

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

declare void @hexdump(ptr noundef, ptr noundef, i64 noundef) #3

declare i64 @sock_send(i32 noundef, ptr noundef, i64 noundef) #3

declare i32 @sock_close(i32 noundef) #3

declare void @net_shutdown() #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 = !{!"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, !15, i64 2}
!14 = !{!"sockaddr_in", !15, i64 0, !15, i64 2, !6, i64 4}
!15 = !{!"short", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%struct.sockaddr_in = type { i16, i16, i32 }

@__const.main.local = external hidden unnamed_addr constant %struct.sockaddr_in, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [62 x i8], align 1
@__func__.main = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@optarg = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@terminate = external hidden global i32, align 4
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.sockaddr_in, align 8
  %4 = alloca %struct.sockaddr_in, align 4
  %5 = alloca i32, align 4
  %6 = alloca [22 x i8], align 16
  %7 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %8 = load i64, ptr @__const.main.local, align 4
  store i64 %8, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 22, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %7) #6
  switch i32 %0, label %35 [
    i32 3, label %9
    i32 2, label %19
  ]

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %3, i64 4
  %13 = call i32 @ip_addr_pton(ptr noundef %11, ptr noundef nonnull %12) #6
  %14 = icmp eq i32 %13, -1
  br i1 %14, label %15, label %19

15:                                               ; preds = %9
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = load ptr, ptr @optarg, align 8, !tbaa !5
  %18 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %16, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 99, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.1, ptr noundef %17) #6
  br label %93

19:                                               ; preds = %9, %2
  %20 = zext nneg i32 %0 to i64
  %21 = getelementptr ptr, ptr %1, i64 %20
  %22 = getelementptr i8, ptr %21, i64 -8
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = call i64 @strtol(ptr nocapture noundef %23, ptr noundef null, i32 noundef 10) #6
  %or.cond = icmp ugt i64 %24, 65535
  br i1 %or.cond, label %25, label %29

25:                                               ; preds = %19
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = load ptr, ptr @optarg, align 8, !tbaa !5
  %28 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %26, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 106, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.2, ptr noundef %27) #6
  br label %93

29:                                               ; preds = %19
  %30 = trunc nuw i64 %24 to i16
  %31 = call zeroext i16 @hton16(i16 noundef zeroext %30) #6
  %32 = getelementptr inbounds i8, ptr %3, i64 2
  store i16 %31, ptr %32, align 2, !tbaa !9
  %33 = call i32 @setup()
  %34 = icmp eq i32 %33, -1
  br i1 %34, label %39, label %42

35:                                               ; preds = %2
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = load ptr, ptr %1, align 8, !tbaa !5
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.3, ptr noundef %37) #7
  br label %93

39:                                               ; preds = %29
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %40, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 119, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.4) #6
  br label %93

42:                                               ; preds = %29
  %43 = call i32 @sock_open(i32 noundef 2, i32 noundef 1, i32 noundef 0) #6
  %44 = icmp eq i32 %43, -1
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %46, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 127, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.5) #6
  br label %93

48:                                               ; preds = %42
  %49 = call i32 @sock_bind(i32 noundef %43, ptr noundef nonnull %3, i32 noundef 8) #6
  %50 = icmp eq i32 %49, -1
  br i1 %50, label %51, label %54

51:                                               ; preds = %48
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %52, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 131, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.6) #6
  br label %93

54:                                               ; preds = %48
  %55 = call i32 @sock_listen(i32 noundef %43, i32 noundef 1) #6
  %56 = icmp eq i32 %55, -1
  br i1 %56, label %57, label %60

57:                                               ; preds = %54
  %58 = load ptr, ptr @stderr, align 8, !tbaa !5
  %59 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %58, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 135, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.7) #6
  br label %93

60:                                               ; preds = %54
  store i32 4, ptr %5, align 4, !tbaa !13
  %61 = call i32 @sock_accept(i32 noundef %43, ptr noundef nonnull %4, ptr noundef nonnull %5) #6
  %62 = icmp eq i32 %61, -1
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  br i1 %62, label %64, label %66

64:                                               ; preds = %60
  %65 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %63, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 141, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.8) #6
  br label %93

66:                                               ; preds = %60
  %67 = call ptr @sockaddr_ntop(ptr noundef nonnull %4, ptr noundef nonnull %6, i64 noundef 22) #6
  %68 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %63, i32 noundef 73, ptr noundef nonnull @.str, i32 noundef 144, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.9, ptr noundef %67) #6
  %69 = load volatile i32, ptr @terminate, align 4, !tbaa !13
  %.not29 = icmp eq i32 %69, 0
  br i1 %.not29, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %66, %.backedge
  %70 = call i64 @sock_recv(i32 noundef %61, ptr noundef nonnull %7, i64 noundef 1024) #6
  switch i64 %70, label %82 [
    i64 -1, label %71
    i64 0, label %79
  ]

71:                                               ; preds = %.lr.ph
  %72 = tail call ptr @__errno_location() #8
  %73 = load i32, ptr %72, align 4, !tbaa !13
  %74 = icmp eq i32 %73, 4
  br i1 %74, label %.backedge, label %76

.backedge:                                        ; preds = %71, %82
  %75 = load volatile i32, ptr @terminate, align 4, !tbaa !13
  %.not = icmp eq i32 %75, 0
  br i1 %.not, label %.lr.ph, label %.loopexit, !llvm.loop !14

76:                                               ; preds = %71
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %77, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 151, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.10) #6
  br label %.loopexit

79:                                               ; preds = %.lr.ph
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  %81 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %80, i32 noundef 68, ptr noundef nonnull @.str, i32 noundef 155, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.11) #6
  br label %.loopexit

82:                                               ; preds = %.lr.ph
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %83, i32 noundef 73, ptr noundef nonnull @.str, i32 noundef 158, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.12, i64 noundef %70) #6
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void @hexdump(ptr noundef %85, ptr noundef nonnull %7, i64 noundef %70) #6
  %86 = call i64 @sock_send(i32 noundef %61, ptr noundef nonnull %7, i64 noundef %70) #6
  %87 = icmp eq i64 %86, -1
  br i1 %87, label %88, label %.backedge

88:                                               ; preds = %82
  %89 = load ptr, ptr @stderr, align 8, !tbaa !5
  %90 = call i32 (ptr, i32, ptr, i32, ptr, ptr, ...) @lprintf(ptr noundef %89, i32 noundef 69, ptr noundef nonnull @.str, i32 noundef 161, ptr noundef nonnull @__func__.main, ptr noundef nonnull @.str.13) #6
  br label %.loopexit

.loopexit:                                        ; preds = %.backedge, %66, %88, %79, %76
  %91 = call i32 @sock_close(i32 noundef %61) #6
  %92 = call i32 @sock_close(i32 noundef %43) #6
  call void @net_shutdown() #6
  br label %93

93:                                               ; preds = %.loopexit, %64, %57, %51, %45, %39, %35, %25, %15
  %.0 = phi i32 [ -1, %35 ], [ -1, %25 ], [ -1, %39 ], [ -1, %45 ], [ -1, %51 ], [ -1, %57 ], [ -1, %64 ], [ 0, %.loopexit ], [ -1, %15 ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 22, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 %.0
}

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

declare i32 @ip_addr_pton(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #3

declare zeroext i16 @hton16(i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @setup() local_unnamed_addr #0

declare i32 @sock_open(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @sock_bind(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @sock_listen(i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @sock_accept(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @sockaddr_ntop(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i64 @sock_recv(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

declare void @hexdump(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i64 @sock_send(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @sock_close(i32 noundef) local_unnamed_addr #2

declare void @net_shutdown() local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync 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 = { mustprogress nofree nounwind willreturn "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 = { nofree 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 = { cold 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, !11, i64 2}
!10 = !{!"sockaddr_in", !11, i64 0, !11, i64 2, !12, i64 4}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass