; LLVM IR from mbheinen/bpa-ipf-tsp :: ipc (ipc_inet)

; 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, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.hostent = type { ptr, ptr, i32, i32, ptr }

@save_socknum = external hidden global i32, align 4
@sock = external hidden global i32, align 4
@.str.7 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [46 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: nounwind
declare i32 @gethostname(ptr noundef, i64 noundef) #1

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

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

declare void @perror(ptr noundef) #2

declare ptr @gethostbyname(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) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) #5

declare void @ipc_inet_socket_setup(i32 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 @create_socket1(ptr noundef %0) #6 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.sockaddr_in, align 4
  %6 = alloca %struct.hostent, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [128 x i8], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 128, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 127, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store ptr %13, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds [128 x i8], ptr %10, i64 0, i64 0
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %18, ptr %12, align 4, !tbaa !9
  store i32 %18, ptr @save_socknum, align 4, !tbaa !9
  %19 = call i32 @socket(i32 noundef 2, i32 noundef 1, i32 noundef 0) #7
  store i32 %19, ptr @sock, align 4, !tbaa !9
  %20 = icmp eq i32 %19, -1
  br i1 %20, label %21, label %23

21:                                               ; preds = %1
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  call void @perror(ptr noundef @.str.8)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

23:                                               ; preds = %1
  %24 = load i32, ptr @sock, align 4, !tbaa !9
  call void @ipc_inet_socket_setup(i32 noundef %24)
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call i32 @gethostname(ptr noundef %25, i64 noundef %27) #7
  store i32 %28, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %23
  call void @perror(ptr noundef @.str.9)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

32:                                               ; preds = %23
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = call ptr @gethostbyname(ptr noundef %33)
  store ptr %34, ptr %7, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  call void @perror(ptr noundef @.str.10)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

37:                                               ; preds = %32
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %38, i64 32, i1 false)
  call void @llvm.memset.p0.i64(ptr align 4 %5, i8 0, i64 16, i1 false)
  %39 = getelementptr inbounds %struct.hostent, ptr %6, i32 0, i32 2
  %40 = load i32, ptr %39, align 8, !tbaa !11
  %41 = trunc i32 %40 to i16
  %42 = getelementptr inbounds %struct.sockaddr_in, ptr %5, i32 0, i32 0
  store i16 %41, ptr %42, align 4, !tbaa !13
  %43 = getelementptr inbounds %struct.sockaddr_in, ptr %5, i32 0, i32 2
  %44 = getelementptr inbounds %struct.hostent, ptr %6, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = getelementptr inbounds ptr, ptr %45, i64 0
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %43, ptr align 4 %47, i64 4, i1 false), !tbaa.struct !18
  store i32 -1, ptr %4, align 4, !tbaa !9
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = icmp slt i32 %48, 1024
  br i1 %49, label %53, label %50

50:                                               ; preds = %37
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = icmp sgt i32 %51, 5000
  br i1 %52, label %53, label %57

53:                                               ; preds = %50, %37
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %54)
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %78

57:                                               ; preds = %50
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = trunc i32 %58 to i16
  %60 = call zeroext i16 @__bswap_16(i16 noundef zeroext %59)
  %61 = getelementptr inbounds %struct.sockaddr_in, ptr %5, i32 0, i32 1
  store i16 %60, ptr %61, align 2, !tbaa !19
  %62 = load i32, ptr @sock, align 4, !tbaa !9
  %63 = call i32 @bind(i32 noundef %62, ptr noundef %5, i32 noundef 16) #7
  store i32 %63, ptr %4, align 4, !tbaa !9
  %64 = icmp slt i32 %63, 0
  br i1 %64, label %65, label %71

65:                                               ; preds = %57
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %66)
  %68 = load i32, ptr %4, align 4, !tbaa !9
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %68)
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %77

71:                                               ; preds = %57
  %72 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %72, ptr @save_socknum, align 4, !tbaa !9
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %73)
  %75 = load i32, ptr @save_socknum, align 4, !tbaa !9
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef %75)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

77:                                               ; preds = %65
  br label %78

78:                                               ; preds = %77, %53
  %79 = load i32, ptr %4, align 4, !tbaa !9
  %80 = icmp slt i32 %79, 0
  br i1 %80, label %81, label %107

81:                                               ; preds = %78
  store i32 0, ptr %12, align 4, !tbaa !9
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = trunc i32 %82 to i16
  %84 = call zeroext i16 @__bswap_16(i16 noundef zeroext %83)
  %85 = getelementptr inbounds %struct.sockaddr_in, ptr %5, i32 0, i32 1
  store i16 %84, ptr %85, align 2, !tbaa !19
  %86 = load i32, ptr @sock, align 4, !tbaa !9
  %87 = call i32 @bind(i32 noundef %86, ptr noundef %5, i32 noundef 16) #7
  store i32 %87, ptr %4, align 4, !tbaa !9
  %88 = icmp slt i32 %87, 0
  br i1 %88, label %89, label %94

89:                                               ; preds = %81
  %90 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  %92 = load i32, ptr %4, align 4, !tbaa !9
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %92)
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

94:                                               ; preds = %81
  %95 = load i32, ptr @sock, align 4, !tbaa !9
  %96 = load ptr, ptr %14, align 8, !tbaa !5
  %97 = call i32 @getsockname(i32 noundef %95, ptr noundef %5, ptr noundef %96) #7
  %98 = getelementptr inbounds %struct.sockaddr_in, ptr %5, i32 0, i32 1
  %99 = load i16, ptr %98, align 2, !tbaa !19
  %100 = call zeroext i16 @__bswap_16(i16 noundef zeroext %99)
  %101 = zext i16 %100 to i32
  store i32 %101, ptr @save_socknum, align 4, !tbaa !9
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  store i32 %101, ptr %102, align 4, !tbaa !9
  %103 = load i32, ptr %4, align 4, !tbaa !9
  %104 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %103)
  %105 = load i32, ptr @save_socknum, align 4, !tbaa !9
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef %105)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

107:                                              ; preds = %78
  store i32 0, ptr %2, align 4
  store i32 1, ptr %15, align 4
  br label %108

108:                                              ; preds = %107, %94, %89, %71, %36, %31, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  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 128, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  %109 = load i32, ptr %2, align 4
  ret i32 %109
}

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

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

attributes #0 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 #7 = { nounwind }

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

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


; 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, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }

@save_socknum = external hidden local_unnamed_addr global i32, align 4
@sock = external hidden local_unnamed_addr global i32, align 4
@.str.7 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [46 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

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

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

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

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #2

declare ptr @gethostbyname(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) local_unnamed_addr #5

declare void @ipc_inet_socket_setup(i32 noundef) local_unnamed_addr #3

; 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 range(i32 -1, 1) i32 @create_socket1(ptr nocapture noundef %0) local_unnamed_addr #6 {
  %2 = alloca %struct.sockaddr_in, align 4
  %3 = alloca [128 x i8], align 16
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %5 = load i32, ptr %0, align 4, !tbaa !5
  store i32 %5, ptr @save_socknum, align 4, !tbaa !5
  %6 = tail call i32 @socket(i32 noundef 2, i32 noundef 1, i32 noundef 0) #7
  store i32 %6, ptr @sock, align 4, !tbaa !5
  %7 = icmp eq i32 %6, -1
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  tail call void @perror(ptr noundef nonnull @.str.8) #8
  br label %59

10:                                               ; preds = %1
  tail call void @ipc_inet_socket_setup(i32 noundef %6) #7
  %11 = call i32 @gethostname(ptr noundef nonnull %3, i64 noundef 127) #7
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %13, label %12

12:                                               ; preds = %10
  call void @perror(ptr noundef nonnull @.str.9) #8
  br label %59

13:                                               ; preds = %10
  %14 = call ptr @gethostbyname(ptr noundef nonnull %3) #7
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  call void @perror(ptr noundef nonnull @.str.10) #8
  br label %59

17:                                               ; preds = %13
  %.sroa.3.0..0.12.sroa_idx = getelementptr inbounds i8, ptr %14, i64 16
  %.sroa.3.0.copyload = load i32, ptr %.sroa.3.0..0.12.sroa_idx, align 8
  %.sroa.413.0..0.12.sroa_idx = getelementptr inbounds i8, ptr %14, i64 24
  %.sroa.413.0.copyload = load ptr, ptr %.sroa.413.0..0.12.sroa_idx, align 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  %18 = trunc i32 %.sroa.3.0.copyload to i16
  store i16 %18, ptr %2, align 4, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %2, i64 4
  %20 = load ptr, ptr %.sroa.413.0.copyload, align 8, !tbaa !13
  %21 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %21, ptr %19, align 4, !tbaa !5
  %22 = add i32 %5, -5001
  %or.cond = icmp ult i32 %22, -3977
  br i1 %or.cond, label %23, label %25

23:                                               ; preds = %17
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %5)
  br label %39

25:                                               ; preds = %17
  %26 = trunc nuw nsw i32 %5 to i16
  %27 = call zeroext i16 @__bswap_16(i16 noundef zeroext %26)
  %28 = getelementptr inbounds i8, ptr %2, i64 2
  store i16 %27, ptr %28, align 2, !tbaa !15
  %29 = load i32, ptr @sock, align 4, !tbaa !5
  %30 = call i32 @bind(i32 noundef %29, ptr noundef nonnull %2, i32 noundef 16) #7
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %25
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %5)
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %30)
  br label %39

35:                                               ; preds = %25
  store i32 %5, ptr @save_socknum, align 4, !tbaa !5
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %30)
  %37 = load i32, ptr @save_socknum, align 4, !tbaa !5
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef %37)
  br label %59

39:                                               ; preds = %23, %32
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %41 = call zeroext i16 @__bswap_16(i16 noundef zeroext 0)
  %42 = getelementptr inbounds i8, ptr %2, i64 2
  store i16 %41, ptr %42, align 2, !tbaa !15
  %43 = load i32, ptr @sock, align 4, !tbaa !5
  %44 = call i32 @bind(i32 noundef %43, ptr noundef nonnull %2, i32 noundef 16) #7
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %50

46:                                               ; preds = %39
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %44)
  br label %59

50:                                               ; preds = %39
  %51 = load i32, ptr @sock, align 4, !tbaa !5
  %52 = call i32 @getsockname(i32 noundef %51, ptr noundef nonnull %2, ptr noundef nonnull %4) #7
  %53 = load i16, ptr %42, align 2, !tbaa !15
  %54 = call zeroext i16 @__bswap_16(i16 noundef zeroext %53)
  %55 = zext i16 %54 to i32
  store i32 %55, ptr @save_socknum, align 4, !tbaa !5
  store i32 %55, ptr %0, align 4, !tbaa !5
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %44)
  %57 = load i32, ptr @save_socknum, align 4, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef %57)
  br label %59

59:                                               ; preds = %50, %46, %35, %16, %12, %8
  %.0 = phi i32 [ -1, %8 ], [ -1, %12 ], [ -1, %16 ], [ -1, %46 ], [ 0, %50 ], [ 0, %35 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  ret i32 %.0
}

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

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

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 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { cold }

!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, !11, i64 0}
!10 = !{!"sockaddr_in", !11, i64 0, !11, i64 2, !12, i64 4, !7, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!"in_addr", !6, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!10, !11, i64 2}


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