; LLVM IR from cruppstahl/upscaledb :: src/1os/os_posix.ll (ZN9upscaledb6Socket7connectEPKctj)

; 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.timeval = type { i64, i64 }
%struct.hostent = type { ptr, ptr, i32, i32, ptr }
%"class.upscaledb::Socket" = type { i32 }

@.str.2 = external hidden unnamed_addr constant [74 x i8], align 1
@_ZTIN9upscaledb9ExceptionE = external dso_local constant { ptr, ptr }, align 8
@__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj = external hidden unnamed_addr constant [8 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [43 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #1 align 2

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

declare void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

declare void @_ZN9upscaledb7dbg_logEPKcz(ptr noundef, ...) #2

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #4

declare i32 @close(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9upscaledb6Socket7connectEPKctj(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef %1, i16 noundef zeroext %2, i32 noundef %3) #5 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca %struct.sockaddr_in, align 4
  %14 = alloca %struct.timeval, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i16 %2, ptr %7, align 2, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  %15 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %16 = call i32 @socket(i32 noundef 2, i32 noundef 1, i32 noundef 0) #9
  store i32 %16, ptr %9, align 4, !tbaa !11
  %17 = load i32, ptr %9, align 4, !tbaa !11
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %32

19:                                               ; preds = %4
  br label %20

20:                                               ; preds = %19
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str.2, i32 noundef 418, ptr noundef @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %21 = call ptr @__errno_location() #10
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = call ptr @strerror(i32 noundef %22) #9
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.12, ptr noundef %23)
  br label %24

24:                                               ; preds = %20
  br label %25

25:                                               ; preds = %24
  %26 = call ptr @__cxa_allocate_exception(i64 4) #9
  invoke void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %26, i32 noundef -18)
          to label %27 unwind label %28

27:                                               ; preds = %25
  call void @__cxa_throw(ptr %26, ptr @_ZTIN9upscaledb9ExceptionE, ptr null) #11
  unreachable

28:                                               ; preds = %25
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %10, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %11, align 4
  call void @__cxa_free_exception(ptr %26) #9
  br label %114

32:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call ptr @gethostbyname(ptr noundef %33)
  store ptr %34, ptr %12, align 8, !tbaa !5
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %53, label %37

37:                                               ; preds = %32
  br label %38

38:                                               ; preds = %37
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str.2, i32 noundef 425, ptr noundef @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call ptr @__h_errno_location() #10
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = call ptr @hstrerror(i32 noundef %41) #9
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.13, ptr noundef %39, ptr noundef %42)
  br label %43

43:                                               ; preds = %38
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %9, align 4, !tbaa !11
  %46 = call i32 @close(i32 noundef %45)
  %47 = call ptr @__cxa_allocate_exception(i64 4) #9
  invoke void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %47, i32 noundef -400)
          to label %48 unwind label %49

48:                                               ; preds = %44
  call void @__cxa_throw(ptr %47, ptr @_ZTIN9upscaledb9ExceptionE, ptr null) #11
  unreachable

49:                                               ; preds = %44
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %10, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %11, align 4
  call void @__cxa_free_exception(ptr %47) #9
  br label %113

53:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #9
  call void @llvm.memset.p0.i64(ptr align 4 %13, i8 0, i64 16, i1 false)
  %54 = getelementptr inbounds %struct.sockaddr_in, ptr %13, i32 0, i32 0
  store i16 2, ptr %54, align 4, !tbaa !13
  %55 = getelementptr inbounds %struct.sockaddr_in, ptr %13, i32 0, i32 2
  %56 = getelementptr inbounds %struct.in_addr, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.hostent, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = getelementptr inbounds ptr, ptr %59, i64 0
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.hostent, ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !18
  %65 = sext i32 %64 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %56, ptr align 1 %61, i64 %65, i1 false)
  %66 = load i16, ptr %7, align 2, !tbaa !9
  %67 = call noundef zeroext i16 @_ZL10__bswap_16t(i16 noundef zeroext %66)
  %68 = getelementptr inbounds %struct.sockaddr_in, ptr %13, i32 0, i32 1
  store i16 %67, ptr %68, align 2, !tbaa !19
  %69 = load i32, ptr %9, align 4, !tbaa !11
  %70 = call i32 @connect(i32 noundef %69, ptr noundef %13, i32 noundef 16)
  %71 = icmp slt i32 %70, 0
  br i1 %71, label %72, label %90

72:                                               ; preds = %53
  br label %73

73:                                               ; preds = %72
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str.2, i32 noundef 437, ptr noundef @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load i16, ptr %7, align 2, !tbaa !9
  %76 = zext i16 %75 to i32
  %77 = call ptr @__errno_location() #10
  %78 = load i32, ptr %77, align 4, !tbaa !11
  %79 = call ptr @strerror(i32 noundef %78) #9
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.14, ptr noundef %74, i32 noundef %76, ptr noundef %79)
  br label %80

80:                                               ; preds = %73
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %9, align 4, !tbaa !11
  %83 = call i32 @close(i32 noundef %82)
  %84 = call ptr @__cxa_allocate_exception(i64 4) #9
  invoke void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %84, i32 noundef -400)
          to label %85 unwind label %86

85:                                               ; preds = %81
  call void @__cxa_throw(ptr %84, ptr @_ZTIN9upscaledb9ExceptionE, ptr null) #11
  unreachable

86:                                               ; preds = %81
  %87 = landingpad { ptr, i32 }
          cleanup
  %88 = extractvalue { ptr, i32 } %87, 0
  store ptr %88, ptr %10, align 8
  %89 = extractvalue { ptr, i32 } %87, 1
  store i32 %89, ptr %11, align 4
  call void @__cxa_free_exception(ptr %84) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #9
  br label %113

90:                                               ; preds = %53
  %91 = load i32, ptr %8, align 4, !tbaa !11
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %110

93:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #9
  %94 = load i32, ptr %8, align 4, !tbaa !11
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds %struct.timeval, ptr %14, i32 0, i32 0
  store i64 %95, ptr %96, align 8, !tbaa !20
  %97 = getelementptr inbounds %struct.timeval, ptr %14, i32 0, i32 1
  store i64 0, ptr %97, align 8, !tbaa !23
  %98 = load i32, ptr %9, align 4, !tbaa !11
  %99 = call i32 @setsockopt(i32 noundef %98, i32 noundef 1, i32 noundef 20, ptr noundef %14, i32 noundef 16) #9
  %100 = icmp slt i32 %99, 0
  br i1 %100, label %101, label %109

101:                                              ; preds = %93
  br label %102

102:                                              ; preds = %101
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef @.str.2, i32 noundef 448, ptr noundef @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %103 = load i32, ptr %8, align 4, !tbaa !11
  %104 = call ptr @__errno_location() #10
  %105 = load i32, ptr %104, align 4, !tbaa !11
  %106 = call ptr @strerror(i32 noundef %105) #9
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef @.str.15, i32 noundef %103, ptr noundef %106)
  br label %107

107:                                              ; preds = %102
  br label %108

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108, %93
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #9
  br label %110

110:                                              ; preds = %109, %90
  %111 = load i32, ptr %9, align 4, !tbaa !11
  %112 = getelementptr inbounds %"class.upscaledb::Socket", ptr %15, i32 0, i32 0
  store i32 %111, ptr %112, align 4, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  ret void

113:                                              ; preds = %86, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  br label %114

114:                                              ; preds = %113, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  br label %115

115:                                              ; preds = %114
  %116 = load ptr, ptr %10, align 8
  %117 = load i32, ptr %11, align 4
  %118 = insertvalue { ptr, i32 } poison, ptr %116, 0
  %119 = insertvalue { ptr, i32 } %118, i32 %117, 1
  resume { ptr, i32 } %119
}

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

declare ptr @gethostbyname(ptr noundef) #2

; Function Attrs: nounwind
declare ptr @hstrerror(i32 noundef) #4

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__h_errno_location() #3

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i16 @_ZL10__bswap_16t(i16 noundef zeroext) #8

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { inlinehint mustprogress 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 #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(none) }
attributes #11 = { noreturn }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS11sockaddr_in", !10, i64 0, !10, i64 2, !15, i64 4, !7, i64 8}
!15 = !{!"_ZTS7in_addr", !12, i64 0}
!16 = !{!17, !6, i64 24}
!17 = !{!"_ZTS7hostent", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24}
!18 = !{!17, !12, i64 20}
!19 = !{!14, !10, i64 2}
!20 = !{!21, !22, i64 0}
!21 = !{!"_ZTS7timeval", !22, i64 0, !22, i64 8}
!22 = !{!"long", !7, i64 0}
!23 = !{!21, !22, i64 8}
!24 = !{!25, !12, i64 0}
!25 = !{!"_ZTSN9upscaledb6SocketE", !12, 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_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.timeval = type { i64, i64 }

@.str.2 = external hidden unnamed_addr constant [74 x i8], align 1
@_ZTIN9upscaledb9ExceptionE = external dso_local constant { ptr, ptr }, align 8
@__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj = external hidden unnamed_addr constant [8 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [43 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #1 align 2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

declare void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN9upscaledb7dbg_logEPKcz(ptr noundef, ...) local_unnamed_addr #2

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #4

declare i32 @close(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9upscaledb6Socket7connectEPKctj(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %0, ptr noundef %1, i16 noundef zeroext %2, i32 noundef %3) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %struct.sockaddr_in, align 4
  %6 = alloca %struct.timeval, align 8
  %7 = tail call i32 @socket(i32 noundef 2, i32 noundef 1, i32 noundef 0) #9
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %9, label %14

9:                                                ; preds = %4
  tail call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str.2, i32 noundef 418, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %10 = tail call ptr @__errno_location() #10
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = tail call ptr @strerror(i32 noundef %11) #9
  tail call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.12, ptr noundef %12)
  %13 = tail call ptr @__cxa_allocate_exception(i64 4) #9
  tail call void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef -18)
  tail call void @__cxa_throw(ptr nonnull %13, ptr nonnull @_ZTIN9upscaledb9ExceptionE, ptr null) #11
  unreachable

14:                                               ; preds = %4
  %15 = tail call ptr @gethostbyname(ptr noundef %1)
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %16, label %22

16:                                               ; preds = %14
  tail call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str.2, i32 noundef 425, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %17 = tail call ptr @__h_errno_location() #10
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = tail call ptr @hstrerror(i32 noundef %18) #9
  tail call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.13, ptr noundef %1, ptr noundef %19)
  %20 = tail call i32 @close(i32 noundef %7)
  %21 = tail call ptr @__cxa_allocate_exception(i64 4) #9
  tail call void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %21, i32 noundef -400)
  tail call void @__cxa_throw(ptr nonnull %21, ptr nonnull @_ZTIN9upscaledb9ExceptionE, ptr null) #11
  unreachable

22:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #9
  %23 = getelementptr inbounds i8, ptr %5, i64 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %23, i8 0, i64 12, i1 false)
  store i16 2, ptr %5, align 4, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %5, i64 4
  %25 = getelementptr inbounds i8, ptr %15, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %15, i64 20
  %29 = load i32, ptr %28, align 4, !tbaa !17
  %30 = sext i32 %29 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %24, ptr align 1 %27, i64 %30, i1 false)
  %31 = tail call noundef zeroext i16 @_ZL10__bswap_16t(i16 noundef zeroext %2)
  %32 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 %31, ptr %32, align 2, !tbaa !18
  %33 = call i32 @connect(i32 noundef %7, ptr noundef nonnull %5, i32 noundef 16)
  %34 = icmp slt i32 %33, 0
  br i1 %34, label %35, label %42

35:                                               ; preds = %22
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str.2, i32 noundef 437, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %36 = zext i16 %2 to i32
  %37 = tail call ptr @__errno_location() #10
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = call ptr @strerror(i32 noundef %38) #9
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.14, ptr noundef %1, i32 noundef %36, ptr noundef %39)
  %40 = call i32 @close(i32 noundef %7)
  %41 = call ptr @__cxa_allocate_exception(i64 4) #9
  call void @_ZN9upscaledb9ExceptionC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %41, i32 noundef -400)
  call void @__cxa_throw(ptr nonnull %41, ptr nonnull @_ZTIN9upscaledb9ExceptionE, ptr null) #11
  unreachable

42:                                               ; preds = %22
  %.not19 = icmp eq i32 %3, 0
  br i1 %.not19, label %53, label %43

43:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #9
  %44 = zext i32 %3 to i64
  store i64 %44, ptr %6, align 8, !tbaa !19
  %45 = getelementptr inbounds i8, ptr %6, i64 8
  store i64 0, ptr %45, align 8, !tbaa !22
  %46 = call i32 @setsockopt(i32 noundef %7, i32 noundef 1, i32 noundef 20, ptr noundef nonnull %6, i32 noundef 16) #9
  %47 = icmp slt i32 %46, 0
  br i1 %47, label %48, label %52

48:                                               ; preds = %43
  call void @_ZN9upscaledb11dbg_prepareEiPKciS1_S1_(i32 noundef 1, ptr noundef nonnull @.str.2, i32 noundef 448, ptr noundef nonnull @__FUNCTION__._ZN9upscaledb6Socket7connectEPKctj, ptr noundef null)
  %49 = tail call ptr @__errno_location() #10
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = call ptr @strerror(i32 noundef %50) #9
  call void (ptr, ...) @_ZN9upscaledb7dbg_logEPKcz(ptr noundef nonnull @.str.15, i32 noundef %3, ptr noundef %51)
  br label %52

52:                                               ; preds = %48, %43
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #9
  br label %53

53:                                               ; preds = %52, %42
  store i32 %7, ptr %0, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #9
  ret void
}

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

declare ptr @gethostbyname(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare ptr @hstrerror(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__h_errno_location() 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) #6

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i16 @_ZL10__bswap_16t(i16 noundef zeroext) local_unnamed_addr #8

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

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

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

!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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS11sockaddr_in", !11, i64 0, !11, i64 2, !12, i64 4, !7, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!"_ZTS7in_addr", !6, i64 0}
!13 = !{!14, !15, i64 24}
!14 = !{!"_ZTS7hostent", !15, i64 0, !15, i64 8, !6, i64 16, !6, i64 20, !15, i64 24}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!14, !6, i64 20}
!18 = !{!10, !11, i64 2}
!19 = !{!20, !21, i64 0}
!20 = !{!"_ZTS7timeval", !21, i64 0, !21, i64 8}
!21 = !{!"long", !7, i64 0}
!22 = !{!20, !21, i64 8}
!23 = !{!24, !6, i64 0}
!24 = !{!"_ZTSN9upscaledb6SocketE", !6, i64 0}


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