; LLVM IR from tezc/sc :: socket (sc_sock)

; 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.addrinfo = type { i32, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.sc_sock = type { %struct.sc_sock_fd, i8, i32, [128 x i8] }
%struct.sc_sock_fd = type { i32, i32, 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 willreturn memory(none)
declare ptr @__errno_location() #2

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 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 uwtable
declare dso_local i32 @sc_sock_set_blocking(ptr noundef, i1 noundef zeroext) #4

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sc_sock_connect(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr 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 ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca %struct.addrinfo, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  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 ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.sc_sock, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %25, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr %19) #6
  call void @llvm.memset.p0.i64(ptr align 8 %19, i8 0, i64 48, i1 false)
  %26 = getelementptr inbounds %struct.addrinfo, ptr %19, i32 0, i32 2
  store i32 1, ptr %26, align 8
  %27 = load i32, ptr %12, align 4, !tbaa !14
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %33

29:                                               ; preds = %5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = call i32 @sc_sock_connect_unix(ptr noundef %30, ptr noundef %31)
  store i32 %32, ptr %6, align 4
  store i32 1, ptr %20, align 4
  br label %174

33:                                               ; preds = %5
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call i32 @getaddrinfo(ptr noundef %34, ptr noundef %35, ptr noundef %19, ptr noundef %17)
  store i32 %36, ptr %13, align 4, !tbaa !14
  %37 = load i32, ptr %13, align 4, !tbaa !14
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %33
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load i32, ptr %13, align 4, !tbaa !14
  call void @sc_sock_errstr(ptr noundef %40, i32 noundef %41)
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %20, align 4
  br label %174

42:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  store i32 0, ptr %21, align 4, !tbaa !14
  br label %43

43:                                               ; preds = %160, %42
  %44 = load i32, ptr %21, align 4, !tbaa !14
  %45 = icmp slt i32 %44, 2
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  store i32 2, ptr %20, align 4
  br label %163

47:                                               ; preds = %43
  %48 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %48, ptr %18, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %155, %47
  %50 = load ptr, ptr %18, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %159

52:                                               ; preds = %49
  %53 = load i32, ptr %21, align 4, !tbaa !14
  %54 = icmp eq i32 %53, 0
  %55 = zext i1 %54 to i32
  %56 = load ptr, ptr %18, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.addrinfo, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !15
  %59 = load i32, ptr %12, align 4, !tbaa !14
  %60 = icmp eq i32 %58, %59
  %61 = zext i1 %60 to i32
  %62 = xor i32 %55, %61
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %52
  br label %155

65:                                               ; preds = %52
  %66 = load ptr, ptr %18, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.addrinfo, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !15
  %69 = load ptr, ptr %18, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.addrinfo, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !17
  %72 = load ptr, ptr %18, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.addrinfo, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !18
  %75 = call i32 @socket(i32 noundef %68, i32 noundef %71, i32 noundef %74) #6
  store i32 %75, ptr %15, align 4, !tbaa !14
  %76 = load i32, ptr %15, align 4, !tbaa !14
  %77 = icmp eq i32 %76, -1
  br i1 %77, label %78, label %79

78:                                               ; preds = %65
  br label %155

79:                                               ; preds = %65
  %80 = load ptr, ptr %18, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.addrinfo, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !15
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.sc_sock, ptr %83, i32 0, i32 2
  store i32 %82, ptr %84, align 4, !tbaa !9
  %85 = load i32, ptr %15, align 4, !tbaa !14
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.sc_sock, ptr %86, i32 0, i32 0
  %88 = getelementptr inbounds %struct.sc_sock_fd, ptr %87, i32 0, i32 0
  store i32 %85, ptr %88, align 4, !tbaa !19
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sc_sock, ptr %90, i32 0, i32 1
  %92 = load i8, ptr %91, align 4, !tbaa !20, !range !21, !noundef !22
  %93 = trunc i8 %92 to i1
  %94 = call i32 @sc_sock_set_blocking(ptr noundef %89, i1 noundef zeroext %93)
  store i32 %94, ptr %13, align 4, !tbaa !14
  %95 = load i32, ptr %13, align 4, !tbaa !14
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %79
  store i32 8, ptr %20, align 4
  br label %163

98:                                               ; preds = %79
  store i32 1, ptr %22, align 4, !tbaa !14
  store ptr %22, ptr %16, align 8, !tbaa !5
  %99 = load i32, ptr %15, align 4, !tbaa !14
  %100 = load ptr, ptr %16, align 8, !tbaa !5
  %101 = call i32 @setsockopt(i32 noundef %99, i32 noundef 1, i32 noundef 2, ptr noundef %100, i32 noundef 4) #6
  store i32 %101, ptr %13, align 4, !tbaa !14
  %102 = load i32, ptr %13, align 4, !tbaa !14
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %98
  store i32 8, ptr %20, align 4
  br label %163

105:                                              ; preds = %98
  %106 = load i32, ptr %15, align 4, !tbaa !14
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  %108 = call i32 @setsockopt(i32 noundef %106, i32 noundef 6, i32 noundef 1, ptr noundef %107, i32 noundef 4) #6
  store i32 %108, ptr %13, align 4, !tbaa !14
  %109 = load i32, ptr %13, align 4, !tbaa !14
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %105
  store i32 8, ptr %20, align 4
  br label %163

112:                                              ; preds = %105
  %113 = load ptr, ptr %10, align 8, !tbaa !5
  %114 = icmp ne ptr %113, null
  br i1 %114, label %118, label %115

115:                                              ; preds = %112
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = icmp ne ptr %116, null
  br i1 %117, label %118, label %127

118:                                              ; preds = %115, %112
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = load ptr, ptr %11, align 8, !tbaa !5
  %122 = call i32 @sc_sock_bind_src(ptr noundef %119, ptr noundef %120, ptr noundef %121)
  store i32 %122, ptr %13, align 4, !tbaa !14
  %123 = load i32, ptr %13, align 4, !tbaa !14
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %126

125:                                              ; preds = %118
  store i32 9, ptr %20, align 4
  br label %163

126:                                              ; preds = %118
  br label %127

127:                                              ; preds = %126, %115
  %128 = load i32, ptr %15, align 4, !tbaa !14
  %129 = load ptr, ptr %18, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.addrinfo, ptr %129, i32 0, i32 5
  %131 = load ptr, ptr %130, align 8, !tbaa !23
  %132 = load ptr, ptr %18, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.addrinfo, ptr %132, i32 0, i32 4
  %134 = load i32, ptr %133, align 8, !tbaa !24
  %135 = call i32 @connect(i32 noundef %128, ptr noundef %131, i32 noundef %134)
  store i32 %135, ptr %13, align 4, !tbaa !14
  %136 = load i32, ptr %13, align 4, !tbaa !14
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %154

138:                                              ; preds = %127
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.sc_sock, ptr %139, i32 0, i32 1
  %141 = load i8, ptr %140, align 4, !tbaa !20, !range !21, !noundef !22
  %142 = trunc i8 %141 to i1
  br i1 %142, label %151, label %143

143:                                              ; preds = %138
  %144 = call i32 @sc_sock_err()
  %145 = icmp eq i32 %144, 115
  br i1 %145, label %149, label %146

146:                                              ; preds = %143
  %147 = call i32 @sc_sock_err()
  %148 = icmp eq i32 %147, 11
  br i1 %148, label %149, label %151

149:                                              ; preds = %146, %143
  %150 = call ptr @__errno_location() #7
  store i32 11, ptr %150, align 4, !tbaa !14
  store i32 -1, ptr %14, align 4, !tbaa !14
  store i32 10, ptr %20, align 4
  br label %163

151:                                              ; preds = %146, %138
  %152 = load ptr, ptr %7, align 8, !tbaa !5
  %153 = call i32 @sc_sock_close(ptr noundef %152)
  br label %155

154:                                              ; preds = %127
  store i32 10, ptr %20, align 4
  br label %163

155:                                              ; preds = %151, %78, %64
  %156 = load ptr, ptr %18, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.addrinfo, ptr %156, i32 0, i32 7
  %158 = load ptr, ptr %157, align 8, !tbaa !25
  store ptr %158, ptr %18, align 8, !tbaa !5
  br label %49, !llvm.loop !26

159:                                              ; preds = %49
  br label %160

160:                                              ; preds = %159
  %161 = load i32, ptr %21, align 4, !tbaa !14
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %21, align 4, !tbaa !14
  br label %43, !llvm.loop !28

163:                                              ; preds = %154, %149, %125, %111, %104, %97, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  %164 = load i32, ptr %20, align 4
  switch i32 %164, label %174 [
    i32 2, label %165
    i32 8, label %166
    i32 9, label %168
    i32 10, label %171
  ]

165:                                              ; preds = %163
  br label %166

166:                                              ; preds = %165, %163
  %167 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sc_sock_errstr(ptr noundef %167, i32 noundef 0)
  br label %168

168:                                              ; preds = %166, %163
  store i32 -1, ptr %14, align 4, !tbaa !14
  %169 = load ptr, ptr %7, align 8, !tbaa !5
  %170 = call i32 @sc_sock_close(ptr noundef %169)
  br label %171

171:                                              ; preds = %168, %163
  %172 = load ptr, ptr %17, align 8, !tbaa !5
  call void @freeaddrinfo(ptr noundef %172) #6
  %173 = load i32, ptr %14, align 4, !tbaa !14
  store i32 %173, ptr %6, align 4
  store i32 1, ptr %20, align 4
  br label %174

174:                                              ; preds = %171, %163, %39, %29
  call void @llvm.lifetime.end.p0(i64 48, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, 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
  %175 = load i32, ptr %6, align 4
  ret i32 %175
}

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

declare i32 @getaddrinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @sc_sock_err() #4

; Function Attrs: nounwind
declare void @freeaddrinfo(ptr noundef) #3

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"sc_sock", !11, i64 0, !13, i64 12, !12, i64 16, !7, i64 20}
!11 = !{!"sc_sock_fd", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !12, i64 4}
!16 = !{!"addrinfo", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!16, !12, i64 8}
!18 = !{!16, !12, i64 12}
!19 = !{!10, !12, i64 0}
!20 = !{!10, !13, i64 12}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!16, !6, i64 24}
!24 = !{!16, !12, i64 16}
!25 = !{!16, !6, i64 40}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


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

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

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

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

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, 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
declare dso_local i32 @sc_sock_set_blocking(ptr noundef, i1 noundef zeroext) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
declare hidden void @sc_sock_errstr(ptr noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sc_sock_connect(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #4 {
  %6 = alloca ptr, align 8
  %7 = alloca %struct.addrinfo, align 8
  %8 = alloca i32, align 4
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  store ptr null, ptr %6, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %7) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %7, i8 0, i64 48, i1 false)
  %11 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 1, ptr %11, align 8
  %12 = icmp eq i32 %10, 1
  br i1 %12, label %13, label %15

13:                                               ; preds = %5
  %14 = tail call i32 @sc_sock_connect_unix(ptr noundef nonnull %0, ptr noundef %1)
  br label %107

15:                                               ; preds = %5
  %16 = call i32 @getaddrinfo(ptr noundef %1, ptr noundef %2, ptr noundef nonnull %7, ptr noundef nonnull %6) #6
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %.preheader71, label %22

.preheader71:                                     ; preds = %15
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = icmp ne ptr %3, null
  %19 = icmp ne ptr %4, null
  %or.cond = or i1 %18, %19
  %20 = load ptr, ptr %6, align 8, !tbaa !12
  %21 = icmp eq ptr %20, null
  br i1 %21, label %.loopexit, label %.lr.ph

22:                                               ; preds = %15
  call void @sc_sock_errstr(ptr noundef nonnull %0, i32 noundef %16)
  br label %107

.lr.ph:                                           ; preds = %.preheader71, %63
  %.05175 = phi ptr [ %.051, %63 ], [ %20, %.preheader71 ]
  %23 = getelementptr inbounds i8, ptr %.05175, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = icmp eq i32 %24, %10
  br i1 %25, label %26, label %63

26:                                               ; preds = %.lr.ph
  %27 = getelementptr inbounds i8, ptr %.05175, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %.05175, i64 12
  %30 = load i32, ptr %29, align 4, !tbaa !17
  %31 = call i32 @socket(i32 noundef %10, i32 noundef %28, i32 noundef %30) #6
  %32 = icmp eq i32 %31, -1
  br i1 %32, label %63, label %33

33:                                               ; preds = %26
  %34 = load i32, ptr %23, align 4, !tbaa !14
  store i32 %34, ptr %9, align 4, !tbaa !5
  store i32 %31, ptr %0, align 4, !tbaa !18
  %35 = load i8, ptr %17, align 4, !tbaa !19, !range !20, !noundef !21
  %36 = trunc nuw i8 %35 to i1
  %37 = call i32 @sc_sock_set_blocking(ptr noundef nonnull %0, i1 noundef zeroext %36)
  %.not59 = icmp eq i32 %37, 0
  br i1 %.not59, label %38, label %.loopexit

38:                                               ; preds = %33
  store i32 1, ptr %8, align 4, !tbaa !22
  %39 = call i32 @setsockopt(i32 noundef %31, i32 noundef 1, i32 noundef 2, ptr noundef nonnull %8, i32 noundef 4) #6
  %.not60 = icmp eq i32 %39, 0
  br i1 %.not60, label %40, label %.loopexit

40:                                               ; preds = %38
  %41 = call i32 @setsockopt(i32 noundef %31, i32 noundef 6, i32 noundef 1, ptr noundef nonnull %8, i32 noundef 4) #6
  %.not61 = icmp eq i32 %41, 0
  br i1 %.not61, label %42, label %.loopexit

42:                                               ; preds = %40
  br i1 %or.cond, label %43, label %45

43:                                               ; preds = %42
  %44 = call i32 @sc_sock_bind_src(ptr noundef nonnull %0, ptr noundef %3, ptr noundef %4)
  %.not62 = icmp eq i32 %44, 0
  br i1 %.not62, label %45, label %.loopexit70

45:                                               ; preds = %43, %42
  %46 = getelementptr inbounds i8, ptr %.05175, i64 24
  %47 = load ptr, ptr %46, align 8, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %.05175, i64 16
  %49 = load i32, ptr %48, align 8, !tbaa !24
  %50 = call i32 @connect(i32 noundef %31, ptr noundef %47, i32 noundef %49) #6
  %.not63 = icmp eq i32 %50, 0
  br i1 %.not63, label %.thread67, label %51

51:                                               ; preds = %45
  %52 = load i8, ptr %17, align 4, !tbaa !19, !range !20, !noundef !21
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %61, label %54

54:                                               ; preds = %51
  %55 = call i32 @sc_sock_err()
  %56 = icmp eq i32 %55, 115
  br i1 %56, label %.loopexit79, label %57

57:                                               ; preds = %54
  %58 = call i32 @sc_sock_err()
  %59 = icmp eq i32 %58, 11
  br i1 %59, label %.loopexit79, label %61

.loopexit79:                                      ; preds = %57, %54, %98, %95
  %60 = tail call ptr @__errno_location() #7
  store i32 11, ptr %60, align 4, !tbaa !22
  br label %.thread67

61:                                               ; preds = %57, %51
  %62 = call i32 @sc_sock_close(ptr noundef nonnull %0)
  br label %63

63:                                               ; preds = %26, %.lr.ph, %61
  %64 = getelementptr inbounds i8, ptr %.05175, i64 40
  %.051 = load ptr, ptr %64, align 8, !tbaa !12
  %.not57 = icmp eq ptr %.051, null
  br i1 %.not57, label %._crit_edge, label %.lr.ph, !llvm.loop !25

._crit_edge:                                      ; preds = %63
  %.05173.1.pre = load ptr, ptr %6, align 8, !tbaa !12
  %.not5774.1 = icmp eq ptr %.05173.1.pre, null
  br i1 %.not5774.1, label %.loopexit, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %._crit_edge, %103
  %.05175.1 = phi ptr [ %.051.1, %103 ], [ %.05173.1.pre, %._crit_edge ]
  %65 = getelementptr inbounds i8, ptr %.05175.1, i64 4
  %66 = load i32, ptr %65, align 4, !tbaa !14
  %.not85 = icmp eq i32 %66, %10
  br i1 %.not85, label %103, label %67

67:                                               ; preds = %.lr.ph.1
  %68 = getelementptr inbounds i8, ptr %.05175.1, i64 8
  %69 = load i32, ptr %68, align 8, !tbaa !16
  %70 = getelementptr inbounds i8, ptr %.05175.1, i64 12
  %71 = load i32, ptr %70, align 4, !tbaa !17
  %72 = call i32 @socket(i32 noundef %66, i32 noundef %69, i32 noundef %71) #6
  %73 = icmp eq i32 %72, -1
  br i1 %73, label %103, label %74

74:                                               ; preds = %67
  %75 = load i32, ptr %65, align 4, !tbaa !14
  store i32 %75, ptr %9, align 4, !tbaa !5
  store i32 %72, ptr %0, align 4, !tbaa !18
  %76 = load i8, ptr %17, align 4, !tbaa !19, !range !20, !noundef !21
  %77 = trunc nuw i8 %76 to i1
  %78 = call i32 @sc_sock_set_blocking(ptr noundef nonnull %0, i1 noundef zeroext %77)
  %.not59.1 = icmp eq i32 %78, 0
  br i1 %.not59.1, label %79, label %.loopexit

79:                                               ; preds = %74
  store i32 1, ptr %8, align 4, !tbaa !22
  %80 = call i32 @setsockopt(i32 noundef %72, i32 noundef 1, i32 noundef 2, ptr noundef nonnull %8, i32 noundef 4) #6
  %.not60.1 = icmp eq i32 %80, 0
  br i1 %.not60.1, label %81, label %.loopexit

81:                                               ; preds = %79
  %82 = call i32 @setsockopt(i32 noundef %72, i32 noundef 6, i32 noundef 1, ptr noundef nonnull %8, i32 noundef 4) #6
  %.not61.1 = icmp eq i32 %82, 0
  br i1 %.not61.1, label %83, label %.loopexit

83:                                               ; preds = %81
  br i1 %or.cond, label %84, label %86

84:                                               ; preds = %83
  %85 = call i32 @sc_sock_bind_src(ptr noundef nonnull %0, ptr noundef %3, ptr noundef %4)
  %.not62.1 = icmp eq i32 %85, 0
  br i1 %.not62.1, label %86, label %.loopexit70

86:                                               ; preds = %84, %83
  %87 = getelementptr inbounds i8, ptr %.05175.1, i64 24
  %88 = load ptr, ptr %87, align 8, !tbaa !23
  %89 = getelementptr inbounds i8, ptr %.05175.1, i64 16
  %90 = load i32, ptr %89, align 8, !tbaa !24
  %91 = call i32 @connect(i32 noundef %72, ptr noundef %88, i32 noundef %90) #6
  %.not63.1 = icmp eq i32 %91, 0
  br i1 %.not63.1, label %.thread67, label %92

92:                                               ; preds = %86
  %93 = load i8, ptr %17, align 4, !tbaa !19, !range !20, !noundef !21
  %94 = trunc nuw i8 %93 to i1
  br i1 %94, label %101, label %95

95:                                               ; preds = %92
  %96 = call i32 @sc_sock_err()
  %97 = icmp eq i32 %96, 115
  br i1 %97, label %.loopexit79, label %98

98:                                               ; preds = %95
  %99 = call i32 @sc_sock_err()
  %100 = icmp eq i32 %99, 11
  br i1 %100, label %.loopexit79, label %101

101:                                              ; preds = %98, %92
  %102 = call i32 @sc_sock_close(ptr noundef nonnull %0)
  br label %103

103:                                              ; preds = %101, %67, %.lr.ph.1
  %104 = getelementptr inbounds i8, ptr %.05175.1, i64 40
  %.051.1 = load ptr, ptr %104, align 8, !tbaa !12
  %.not57.1 = icmp eq ptr %.051.1, null
  br i1 %.not57.1, label %.loopexit, label %.lr.ph.1, !llvm.loop !25

.loopexit:                                        ; preds = %33, %38, %40, %74, %79, %81, %103, %._crit_edge, %.preheader71
  call void @sc_sock_errstr(ptr noundef %0, i32 noundef 0)
  br label %.loopexit70

.loopexit70:                                      ; preds = %43, %84, %.loopexit
  %105 = call i32 @sc_sock_close(ptr noundef %0)
  br label %.thread67

.thread67:                                        ; preds = %45, %86, %.loopexit79, %.loopexit70
  %.1 = phi i32 [ -1, %.loopexit70 ], [ -1, %.loopexit79 ], [ 0, %86 ], [ 0, %45 ]
  %106 = load ptr, ptr %6, align 8, !tbaa !12
  call void @freeaddrinfo(ptr noundef %106) #6
  br label %107

107:                                              ; preds = %.thread67, %22, %13
  %.052 = phi i32 [ %14, %13 ], [ -1, %22 ], [ %.1, %.thread67 ]
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  ret i32 %.052
}

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

declare i32 @getaddrinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden i32 @sc_sock_err() local_unnamed_addr #4

; Function Attrs: nounwind
declare void @freeaddrinfo(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { 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 #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 = { "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, !8, i64 16}
!6 = !{!"sc_sock", !7, i64 0, !11, i64 12, !8, i64 16, !9, i64 20}
!7 = !{!"sc_sock_fd", !8, i64 0, !8, i64 4, !8, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"_Bool", !9, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!15, !8, i64 4}
!15 = !{!"addrinfo", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !13, i64 24, !13, i64 32, !13, i64 40}
!16 = !{!15, !8, i64 8}
!17 = !{!15, !8, i64 12}
!18 = !{!6, !8, i64 0}
!19 = !{!6, !11, i64 12}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!8, !8, i64 0}
!23 = !{!15, !13, i64 24}
!24 = !{!15, !8, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass