; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (net_sockets)

; 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_storage = type { i16, [118 x i8], i64 }
%struct.mbedtls_net_context = type { i32 }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.sockaddr_in6 = type { i16, i16, i32, %struct.in6_addr, i32 }
%struct.in6_addr = type { %union.anon }
%union.anon = type { [4 x i32] }

; 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) #2

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

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

; Function Attrs: nounwind
declare i32 @setsockopt(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @bind(i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_net_accept(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.sockaddr_storage, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca [1 x i8], align 1
  %19 = alloca %struct.sockaddr_storage, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 128, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 4, ptr %16, align 4, !tbaa !11
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mbedtls_net_context, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = call i32 @getsockopt(i32 noundef %25, i32 noundef 1, i32 noundef 3, ptr noundef %13, ptr noundef %16) #6
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %34, label %28

28:                                               ; preds = %5
  %29 = load i32, ptr %13, align 4, !tbaa !11
  %30 = icmp ne i32 %29, 1
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = load i32, ptr %13, align 4, !tbaa !11
  %33 = icmp ne i32 %32, 2
  br i1 %33, label %34, label %35

34:                                               ; preds = %31, %5
  store i32 -74, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %156

35:                                               ; preds = %31, %28
  %36 = load i32, ptr %13, align 4, !tbaa !11
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %45

38:                                               ; preds = %35
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mbedtls_net_context, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = call i32 @accept(i32 noundef %41, ptr noundef %14, ptr noundef %15)
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mbedtls_net_context, ptr %43, i32 0, i32 0
  store i32 %42, ptr %44, align 4, !tbaa !13
  store i32 %42, ptr %12, align 4, !tbaa !11
  br label %52

45:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #6
  call void @llvm.memset.p0.i64(ptr align 1 %18, i8 0, i64 1, i1 false)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mbedtls_net_context, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = getelementptr inbounds [1 x i8], ptr %18, i64 0, i64 0
  %50 = call i64 @recvfrom(i32 noundef %48, ptr noundef %49, i64 noundef 1, i32 noundef 2, ptr noundef %14, ptr noundef %15)
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #6
  br label %52

52:                                               ; preds = %45, %38
  %53 = load i32, ptr %12, align 4, !tbaa !11
  %54 = icmp slt i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %52
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = call i32 @net_would_block(ptr noundef %56)
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %55
  store i32 -26880, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %156

60:                                               ; preds = %55
  store i32 -74, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %156

61:                                               ; preds = %52
  %62 = load i32, ptr %13, align 4, !tbaa !11
  %63 = icmp ne i32 %62, 1
  br i1 %63, label %64, label %112

64:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 128, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 1, ptr %20, align 4, !tbaa !11
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mbedtls_net_context, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 4, !tbaa !13
  %68 = load i32, ptr %15, align 4, !tbaa !11
  %69 = call i32 @connect(i32 noundef %67, ptr noundef %14, i32 noundef %68)
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %64
  store i32 -74, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

72:                                               ; preds = %64
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.mbedtls_net_context, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 4, !tbaa !13
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.mbedtls_net_context, ptr %76, i32 0, i32 0
  store i32 %75, ptr %77, align 4, !tbaa !13
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mbedtls_net_context, ptr %78, i32 0, i32 0
  store i32 -1, ptr %79, align 4, !tbaa !13
  store i32 128, ptr %15, align 4, !tbaa !11
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.mbedtls_net_context, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !13
  %83 = call i32 @getsockname(i32 noundef %82, ptr noundef %19, ptr noundef %15) #6
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %99, label %85

85:                                               ; preds = %72
  %86 = getelementptr inbounds %struct.sockaddr_storage, ptr %19, i32 0, i32 0
  %87 = load i16, ptr %86, align 8, !tbaa !15
  %88 = zext i16 %87 to i32
  %89 = call i32 @socket(i32 noundef %88, i32 noundef 2, i32 noundef 17) #6
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mbedtls_net_context, ptr %90, i32 0, i32 0
  store i32 %89, ptr %91, align 4, !tbaa !13
  %92 = icmp slt i32 %89, 0
  br i1 %92, label %99, label %93

93:                                               ; preds = %85
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.mbedtls_net_context, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %95, align 4, !tbaa !13
  %97 = call i32 @setsockopt(i32 noundef %96, i32 noundef 1, i32 noundef 2, ptr noundef %20, i32 noundef 4) #6
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %93, %85, %72
  store i32 -66, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

100:                                              ; preds = %93
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.mbedtls_net_context, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 4, !tbaa !13
  %104 = load i32, ptr %15, align 4, !tbaa !11
  %105 = call i32 @bind(i32 noundef %103, ptr noundef %19, i32 noundef %104) #6
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %108

107:                                              ; preds = %100
  store i32 -70, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %109

108:                                              ; preds = %100
  store i32 0, ptr %17, align 4
  br label %109

109:                                              ; preds = %108, %107, %99, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %19) #6
  %110 = load i32, ptr %17, align 4
  switch i32 %110, label %156 [
    i32 0, label %111
  ]

111:                                              ; preds = %109
  br label %112

112:                                              ; preds = %111, %61
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  %114 = icmp ne ptr %113, null
  br i1 %114, label %115, label %155

115:                                              ; preds = %112
  %116 = getelementptr inbounds %struct.sockaddr_storage, ptr %14, i32 0, i32 0
  %117 = load i16, ptr %116, align 8, !tbaa !15
  %118 = zext i16 %117 to i32
  %119 = icmp eq i32 %118, 2
  br i1 %119, label %120, label %137

120:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  store ptr %14, ptr %21, align 8, !tbaa !5
  %121 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 4, ptr %121, align 8, !tbaa !9
  %122 = load i64, ptr %10, align 8, !tbaa !9
  %123 = load ptr, ptr %11, align 8, !tbaa !5
  %124 = load i64, ptr %123, align 8, !tbaa !9
  %125 = icmp ult i64 %122, %124
  br i1 %125, label %126, label %127

126:                                              ; preds = %120
  store i32 -67, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %134

127:                                              ; preds = %120
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  %129 = load ptr, ptr %21, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.sockaddr_in, ptr %129, i32 0, i32 2
  %131 = getelementptr inbounds %struct.in_addr, ptr %130, i32 0, i32 0
  %132 = load ptr, ptr %11, align 8, !tbaa !5
  %133 = load i64, ptr %132, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %128, ptr align 4 %131, i64 %133, i1 false)
  store i32 0, ptr %17, align 4
  br label %134

134:                                              ; preds = %127, %126
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  %135 = load i32, ptr %17, align 4
  switch i32 %135, label %156 [
    i32 0, label %136
  ]

136:                                              ; preds = %134
  br label %154

137:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  store ptr %14, ptr %22, align 8, !tbaa !5
  %138 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 16, ptr %138, align 8, !tbaa !9
  %139 = load i64, ptr %10, align 8, !tbaa !9
  %140 = load ptr, ptr %11, align 8, !tbaa !5
  %141 = load i64, ptr %140, align 8, !tbaa !9
  %142 = icmp ult i64 %139, %141
  br i1 %142, label %143, label %144

143:                                              ; preds = %137
  store i32 -67, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %151

144:                                              ; preds = %137
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  %146 = load ptr, ptr %22, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.sockaddr_in6, ptr %146, i32 0, i32 3
  %148 = getelementptr inbounds %struct.in6_addr, ptr %147, i32 0, i32 0
  %149 = load ptr, ptr %11, align 8, !tbaa !5
  %150 = load i64, ptr %149, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %145, ptr align 4 %148, i64 %150, i1 false)
  store i32 0, ptr %17, align 4
  br label %151

151:                                              ; preds = %144, %143
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  %152 = load i32, ptr %17, align 4
  switch i32 %152, label %156 [
    i32 0, label %153
  ]

153:                                              ; preds = %151
  br label %154

154:                                              ; preds = %153, %136
  br label %155

155:                                              ; preds = %154, %112
  store i32 0, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %156

156:                                              ; preds = %155, %151, %134, %109, %60, %59, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %157 = load i32, ptr %6, align 4
  ret i32 %157
}

; Function Attrs: nounwind
declare i32 @getsockopt(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #2

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

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

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

; Function Attrs: nounwind
declare i32 @getsockname(i32 noundef, ptr noundef, ptr noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"", !12, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"sockaddr_storage", !17, i64 0, !7, i64 2, !10, i64 120}
!17 = !{!"short", !7, i64 0}


; 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_storage = type { i16, [118 x i8], i64 }

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

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) 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) #0

; Function Attrs: nounwind
declare i32 @setsockopt(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @bind(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_net_accept(ptr noundef %0, ptr nocapture noundef %1, ptr noundef writeonly %2, i64 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #3 {
  %6 = alloca i32, align 4
  %7 = alloca %struct.sockaddr_storage, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [1 x i8], align 1
  %11 = alloca %struct.sockaddr_storage, align 8
  %12 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  store i32 128, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #5
  store i32 4, ptr %9, align 4, !tbaa !5
  %13 = load i32, ptr %0, align 4, !tbaa !9
  %14 = call i32 @getsockopt(i32 noundef %13, i32 noundef 1, i32 noundef 3, ptr noundef nonnull %6, ptr noundef nonnull %9) #5
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %63

15:                                               ; preds = %5
  %16 = load i32, ptr %6, align 4
  %17 = add i32 %16, -3
  %or.cond = icmp ult i32 %17, -2
  br i1 %or.cond, label %63, label %18

18:                                               ; preds = %15
  %19 = icmp eq i32 %16, 1
  br i1 %19, label %20, label %23

20:                                               ; preds = %18
  %21 = load i32, ptr %0, align 4, !tbaa !9
  %22 = call i32 @accept(i32 noundef %21, ptr noundef nonnull %7, ptr noundef nonnull %8) #5
  store i32 %22, ptr %1, align 4, !tbaa !9
  br label %27

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #5
  store i8 0, ptr %10, align 1
  %24 = load i32, ptr %0, align 4, !tbaa !9
  %25 = call i64 @recvfrom(i32 noundef %24, ptr noundef nonnull %10, i64 noundef 1, i32 noundef 2, ptr noundef nonnull %7, ptr noundef nonnull %8) #5
  %26 = trunc i64 %25 to i32
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #5
  br label %27

27:                                               ; preds = %23, %20
  %.033 = phi i32 [ %22, %20 ], [ %26, %23 ]
  %28 = icmp slt i32 %.033, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %27
  %30 = call i32 @net_would_block(ptr noundef nonnull %0)
  %.not45 = icmp eq i32 %30, 0
  %. = select i1 %.not45, i32 -74, i32 -26880
  br label %63

31:                                               ; preds = %27
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %.not39 = icmp eq i32 %32, 1
  br i1 %.not39, label %52, label %33

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #5
  store i32 1, ptr %12, align 4, !tbaa !5
  %34 = load i32, ptr %0, align 4, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = call i32 @connect(i32 noundef %34, ptr noundef nonnull %7, i32 noundef %35) #5
  %.not40 = icmp eq i32 %36, 0
  br i1 %.not40, label %37, label %.thread

37:                                               ; preds = %33
  %38 = load i32, ptr %0, align 4, !tbaa !9
  store i32 %38, ptr %1, align 4, !tbaa !9
  store i32 -1, ptr %0, align 4, !tbaa !9
  store i32 128, ptr %8, align 4, !tbaa !5
  %39 = load i32, ptr %1, align 4, !tbaa !9
  %40 = call i32 @getsockname(i32 noundef %39, ptr noundef nonnull %11, ptr noundef nonnull %8) #5
  %.not41 = icmp eq i32 %40, 0
  br i1 %.not41, label %41, label %.thread

41:                                               ; preds = %37
  %42 = load i16, ptr %11, align 8, !tbaa !11
  %43 = zext i16 %42 to i32
  %44 = call i32 @socket(i32 noundef %43, i32 noundef 2, i32 noundef 17) #5
  store i32 %44, ptr %0, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %.thread, label %46

46:                                               ; preds = %41
  %47 = call i32 @setsockopt(i32 noundef %44, i32 noundef 1, i32 noundef 2, ptr noundef nonnull %12, i32 noundef 4) #5
  %.not42 = icmp eq i32 %47, 0
  br i1 %.not42, label %48, label %.thread

.thread:                                          ; preds = %33, %46, %41, %37
  %.0.ph = phi i32 [ -66, %37 ], [ -66, %41 ], [ -66, %46 ], [ -74, %33 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %11) #5
  br label %63

48:                                               ; preds = %46
  %49 = load i32, ptr %0, align 4, !tbaa !9
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = call i32 @bind(i32 noundef %49, ptr noundef nonnull %11, i32 noundef %50) #5
  %.not43 = icmp eq i32 %51, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %11) #5
  br i1 %.not43, label %52, label %63

52:                                               ; preds = %48, %31
  %.not44 = icmp eq ptr %2, null
  br i1 %.not44, label %63, label %53

53:                                               ; preds = %52
  %54 = load i16, ptr %7, align 8, !tbaa !11
  %55 = icmp eq i16 %54, 2
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  store i64 4, ptr %4, align 8, !tbaa !15
  %57 = icmp ugt i64 %3, 3
  br i1 %57, label %.thread50, label %63

.thread50:                                        ; preds = %56
  %58 = getelementptr inbounds i8, ptr %7, i64 4
  %59 = load i32, ptr %58, align 4
  store i32 %59, ptr %2, align 1
  br label %63

60:                                               ; preds = %53
  store i64 16, ptr %4, align 8, !tbaa !15
  %61 = icmp ugt i64 %3, 15
  br i1 %61, label %.thread52, label %63

.thread52:                                        ; preds = %60
  %62 = getelementptr inbounds i8, ptr %7, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %62, i64 16, i1 false)
  br label %63

63:                                               ; preds = %52, %.thread50, %.thread52, %60, %56, %.thread, %29, %5, %15, %48
  %.4 = phi i32 [ -70, %48 ], [ -74, %15 ], [ -74, %5 ], [ %., %29 ], [ %.0.ph, %.thread ], [ -67, %56 ], [ -67, %60 ], [ 0, %.thread52 ], [ 0, %.thread50 ], [ 0, %52 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  ret i32 %.4
}

; Function Attrs: nounwind
declare i32 @getsockopt(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind
declare i32 @getsockname(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"sockaddr_storage", !13, i64 0, !7, i64 2, !14, i64 120}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}


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