; LLVM IR from wichue/nethello :: src/net/SocketBase.ll (ZN3chw8SockUtil13send_tcp_dataEiPcj)

; 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"

%"class.chw::LogContextCapture" = type { %"class.std::shared_ptr", ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__FUNCTION__._ZN3chw8SockUtil13send_tcp_dataEiPcj = external hidden unnamed_addr constant [14 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [19 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; 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 noundef nonnull align 8 dereferenceable(144) ptr @_ZN3chw9getLoggerEv() #1

declare void @_ZN3chw17LogContextCaptureC1ERNS_6LoggerENS_8LogLevelEPKcS5_iS5_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(144), i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare noundef i32 @_ZN3chw12get_uv_errorEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA19_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(19)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIPKcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3chw8SockUtil13send_tcp_dataEiPcj(i32 noundef %0, ptr noundef %1, i32 noundef %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"class.chw::LogContextCapture", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca %"class.chw::LogContextCapture", align 8
  %20 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %21 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %21, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %123, %83, %3
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp ult i32 %23, %24
  br i1 %25, label %26, label %124

26:                                               ; preds = %22
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = call i64 @send(i32 noundef %27, ptr noundef %31, i64 noundef %33, i32 noundef 16384)
  %35 = trunc i64 %34 to i32
  store i32 %35, ptr %9, align 4, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %38, label %85

38:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %39 = call noundef i32 @_ZN3chw12get_uv_errorEb(i1 noundef zeroext true)
  store i32 %39, ptr %12, align 4, !tbaa !5
  %40 = load i32, ptr %12, align 4, !tbaa !5
  %41 = icmp eq i32 %40, -11
  br i1 %41, label %42, label %48

42:                                               ; preds = %38
  %43 = load i32, ptr %11, align 4, !tbaa !5
  %44 = add i32 %43, 1
  store i32 %44, ptr %11, align 4, !tbaa !5
  %45 = icmp ult i32 %43, 10000
  br i1 %45, label %46, label %48

46:                                               ; preds = %42
  %47 = call i32 @usleep(i32 noundef 1000)
  store i32 2, ptr %13, align 4
  br label %83, !llvm.loop !11

48:                                               ; preds = %42, %38
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #4
  %49 = call noundef nonnull align 8 dereferenceable(144) ptr @_ZN3chw9getLoggerEv()
  call void @_ZN3chw17LogContextCaptureC1ERNS_6LoggerENS_8LogLevelEPKcS5_iS5_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 8 dereferenceable(144) %49, i32 noundef 4, ptr noundef @.str.1, ptr noundef @__FUNCTION__._ZN3chw8SockUtil13send_tcp_dataEiPcj, i32 noundef 1251, ptr noundef @.str)
  %50 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA17_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 1 dereferenceable(17) @.str.36)
          to label %51 unwind label %74

51:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %52 = load i32, ptr %12, align 4, !tbaa !5
  %53 = invoke noundef ptr @_ZN3chw11uv_strerrorEi(i32 noundef %52)
          to label %54 unwind label %78

54:                                               ; preds = %51
  store ptr %53, ptr %17, align 8, !tbaa !9
  %55 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIPKcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %50, ptr noundef nonnull align 8 dereferenceable(8) %17)
          to label %56 unwind label %78

56:                                               ; preds = %54
  %57 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA14_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %55, ptr noundef nonnull align 1 dereferenceable(14) @.str.37)
          to label %58 unwind label %78

58:                                               ; preds = %56
  %59 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 4 dereferenceable(4) %11)
          to label %60 unwind label %78

60:                                               ; preds = %58
  %61 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA6_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %59, ptr noundef nonnull align 1 dereferenceable(6) @.str.38)
          to label %62 unwind label %78

62:                                               ; preds = %60
  %63 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %61, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %64 unwind label %78

64:                                               ; preds = %62
  %65 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA19_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %63, ptr noundef nonnull align 1 dereferenceable(19) @.str.39)
          to label %66 unwind label %78

66:                                               ; preds = %64
  %67 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %65, ptr noundef nonnull align 4 dereferenceable(4) %8)
          to label %68 unwind label %78

68:                                               ; preds = %66
  %69 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA5_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %67, ptr noundef nonnull align 1 dereferenceable(5) @.str.40)
          to label %70 unwind label %78

70:                                               ; preds = %68
  %71 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRiEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %69, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %72 unwind label %78

72:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  %73 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %73, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %83

74:                                               ; preds = %48
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %15, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %16, align 4
  br label %82

78:                                               ; preds = %70, %68, %66, %64, %62, %60, %58, %56, %54, %51
  %79 = landingpad { ptr, i32 }
          cleanup
  %80 = extractvalue { ptr, i32 } %79, 0
  store ptr %80, ptr %15, align 8
  %81 = extractvalue { ptr, i32 } %79, 1
  store i32 %81, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %82

82:                                               ; preds = %78, %74
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %128

83:                                               ; preds = %72, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %84 = load i32, ptr %13, align 4
  switch i32 %84, label %126 [
    i32 2, label %22
  ]

85:                                               ; preds = %26
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = icmp sgt i32 %86, 0
  br i1 %87, label %88, label %95

88:                                               ; preds = %85
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = load i32, ptr %8, align 4, !tbaa !5
  %91 = add i32 %90, %89
  store i32 %91, ptr %8, align 4, !tbaa !5
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = load i32, ptr %10, align 4, !tbaa !5
  %94 = sub i32 %93, %92
  store i32 %94, ptr %10, align 4, !tbaa !5
  br label %122

95:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %96 = call noundef i32 @_ZN3chw12get_uv_errorEb(i1 noundef zeroext true)
  store i32 %96, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %19) #4
  %97 = call noundef nonnull align 8 dereferenceable(144) ptr @_ZN3chw9getLoggerEv()
  call void @_ZN3chw17LogContextCaptureC1ERNS_6LoggerENS_8LogLevelEPKcS5_iS5_(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 8 dereferenceable(144) %97, i32 noundef 4, ptr noundef @.str.1, ptr noundef @__FUNCTION__._ZN3chw8SockUtil13send_tcp_dataEiPcj, i32 noundef 1259, ptr noundef @.str)
  %98 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA19_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 1 dereferenceable(19) @.str.41)
          to label %99 unwind label %113

99:                                               ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %100 = load i32, ptr %18, align 4, !tbaa !5
  %101 = invoke noundef ptr @_ZN3chw11uv_strerrorEi(i32 noundef %100)
          to label %102 unwind label %117

102:                                              ; preds = %99
  store ptr %101, ptr %20, align 8, !tbaa !9
  %103 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIPKcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %98, ptr noundef nonnull align 8 dereferenceable(8) %20)
          to label %104 unwind label %117

104:                                              ; preds = %102
  %105 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA6_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %103, ptr noundef nonnull align 1 dereferenceable(6) @.str.38)
          to label %106 unwind label %117

106:                                              ; preds = %104
  %107 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %105, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %108 unwind label %117

108:                                              ; preds = %106
  %109 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA5_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %107, ptr noundef nonnull align 1 dereferenceable(5) @.str.40)
          to label %110 unwind label %117

110:                                              ; preds = %108
  %111 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRiEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %109, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %112 unwind label %117

112:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %19) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #4
  store i32 0, ptr %4, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %126

113:                                              ; preds = %95
  %114 = landingpad { ptr, i32 }
          cleanup
  %115 = extractvalue { ptr, i32 } %114, 0
  store ptr %115, ptr %15, align 8
  %116 = extractvalue { ptr, i32 } %114, 1
  store i32 %116, ptr %16, align 4
  br label %121

117:                                              ; preds = %110, %108, %106, %104, %102, %99
  %118 = landingpad { ptr, i32 }
          cleanup
  %119 = extractvalue { ptr, i32 } %118, 0
  store ptr %119, ptr %15, align 8
  %120 = extractvalue { ptr, i32 } %118, 1
  store i32 %120, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  br label %121

121:                                              ; preds = %117, %113
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %19) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %128

122:                                              ; preds = %88
  br label %123

123:                                              ; preds = %122
  br label %22, !llvm.loop !11

124:                                              ; preds = %22
  %125 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %125, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %126

126:                                              ; preds = %124, %112, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %127 = load i32, ptr %4, align 4
  ret i32 %127

128:                                              ; preds = %121, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %129

129:                                              ; preds = %128
  %130 = load ptr, ptr %15, align 8
  %131 = load i32, ptr %16, align 4
  %132 = insertvalue { ptr, i32 } poison, ptr %130, 0
  %133 = insertvalue { ptr, i32 } %132, i32 %131, 1
  resume { ptr, i32 } %133
}

declare i64 @send(i32 noundef, ptr noundef, i64 noundef, i32 noundef) #1

declare i32 @usleep(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA17_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(17)) #3 align 2

declare noundef ptr @_ZN3chw11uv_strerrorEi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA14_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(14)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA6_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(6)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA5_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(5)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRiEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { 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 #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.chw::LogContextCapture" = type { %"class.std::shared_ptr", ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__FUNCTION__._ZN3chw8SockUtil13send_tcp_dataEiPcj = external hidden unnamed_addr constant [14 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [19 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; 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 noundef nonnull align 8 dereferenceable(144) ptr @_ZN3chw9getLoggerEv() local_unnamed_addr #1

declare void @_ZN3chw17LogContextCaptureC1ERNS_6LoggerENS_8LogLevelEPKcS5_iS5_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(144), i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

declare noundef i32 @_ZN3chw12get_uv_errorEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA19_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(19)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIPKcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3chw8SockUtil13send_tcp_dataEiPcj(i32 noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.chw::LogContextCapture", align 8
  %9 = alloca ptr, align 8
  %10 = alloca %"class.chw::LogContextCapture", align 8
  %11 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %2, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %.not82 = icmp eq i32 %2, 0
  br i1 %.not82, label %.loopexit, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %3, %.outer
  %.020.ph63 = phi i32 [ %60, %.outer ], [ %2, %3 ]
  %12 = phi i32 [ %59, %.outer ], [ 0, %3 ]
  %.us-phi5962 = phi i32 [ %.us-phi, %.outer ], [ 0, %3 ]
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %1, i64 %13
  %15 = zext i32 %.020.ph63 to i64
  %16 = tail call i64 @send(i32 noundef %0, ptr noundef %14, i64 noundef %15, i32 noundef 16384)
  %17 = trunc i64 %16 to i32
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %.lr.ph50.preheader, label %.split.us

.lr.ph50.preheader:                               ; preds = %.lr.ph.split.us
  %umax = tail call i32 @llvm.umax.i32(i32 %.us-phi5962, i32 10000)
  br label %.lr.ph50

.lr.ph50:                                         ; preds = %.lr.ph50.preheader, %23
  %19 = phi i32 [ %24, %23 ], [ %.us-phi5962, %.lr.ph50.preheader ]
  %20 = tail call noundef i32 @_ZN3chw12get_uv_errorEb(i1 noundef zeroext true)
  %21 = icmp eq i32 %20, -11
  br i1 %21, label %22, label %.split42

22:                                               ; preds = %.lr.ph50
  %exitcond.not = icmp eq i32 %19, %umax
  br i1 %exitcond.not, label %.split42.split.loop.exit90, label %23

23:                                               ; preds = %22
  %24 = add i32 %19, 1
  %25 = tail call i32 @usleep(i32 noundef 1000)
  %26 = tail call i64 @send(i32 noundef %0, ptr noundef %14, i64 noundef %15, i32 noundef 16384)
  %27 = trunc i64 %26 to i32
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %.lr.ph50, label %.split.us

.split42.split.loop.exit90:                       ; preds = %22
  %29 = add i32 %umax, 1
  br label %.split42

.split42:                                         ; preds = %.lr.ph50, %.split42.split.loop.exit90
  %30 = phi i32 [ %29, %.split42.split.loop.exit90 ], [ %19, %.lr.ph50 ]
  store i32 %12, ptr %6, align 4, !tbaa !5
  store i32 %30, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #5
  %31 = tail call noundef nonnull align 8 dereferenceable(144) ptr @_ZN3chw9getLoggerEv()
  call void @_ZN3chw17LogContextCaptureC1ERNS_6LoggerENS_8LogLevelEPKcS5_iS5_(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(144) %31, i32 noundef 4, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__._ZN3chw8SockUtil13send_tcp_dataEiPcj, i32 noundef 1251, ptr noundef nonnull @.str)
  %32 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA17_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 1 dereferenceable(17) @.str.36)
          to label %33 unwind label %54

33:                                               ; preds = %.split42
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %34 = invoke noundef ptr @_ZN3chw11uv_strerrorEi(i32 noundef %20)
          to label %35 unwind label %56

35:                                               ; preds = %33
  store ptr %34, ptr %9, align 8, !tbaa !9
  %36 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIPKcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %32, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %37 unwind label %56

37:                                               ; preds = %35
  %38 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA14_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %36, ptr noundef nonnull align 1 dereferenceable(14) @.str.37)
          to label %39 unwind label %56

39:                                               ; preds = %37
  %40 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %38, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %41 unwind label %56

41:                                               ; preds = %39
  %42 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA6_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %40, ptr noundef nonnull align 1 dereferenceable(6) @.str.38)
          to label %43 unwind label %56

43:                                               ; preds = %41
  %44 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %42, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %45 unwind label %56

45:                                               ; preds = %43
  %46 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA19_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %44, ptr noundef nonnull align 1 dereferenceable(19) @.str.39)
          to label %47 unwind label %56

47:                                               ; preds = %45
  %48 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %46, ptr noundef nonnull align 4 dereferenceable(4) %6)
          to label %49 unwind label %56

49:                                               ; preds = %47
  %50 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA5_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %48, ptr noundef nonnull align 1 dereferenceable(5) @.str.40)
          to label %51 unwind label %56

51:                                               ; preds = %49
  %52 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRiEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %50, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %.thread unwind label %56

.thread:                                          ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  %53 = load i32, ptr %6, align 4, !tbaa !5
  br label %.loopexit

54:                                               ; preds = %.split42
  %55 = landingpad { ptr, i32 }
          cleanup
  br label %58

56:                                               ; preds = %51, %49, %47, %45, %43, %41, %39, %37, %35, %33
  %57 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  br label %58

58:                                               ; preds = %56, %54
  %.pn25 = phi { ptr, i32 } [ %57, %56 ], [ %55, %54 ]
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  br label %84

.split.us:                                        ; preds = %23, %.lr.ph.split.us
  %.us-phi = phi i32 [ %.us-phi5962, %.lr.ph.split.us ], [ %24, %23 ]
  %.us-phi40 = phi i32 [ %17, %.lr.ph.split.us ], [ %27, %23 ]
  %.not = icmp eq i32 %.us-phi40, 0
  br i1 %.not, label %62, label %.outer

.outer:                                           ; preds = %.split.us
  %59 = add i32 %12, %.us-phi40
  %60 = sub i32 %.020.ph63, %.us-phi40
  %61 = icmp ult i32 %59, %2
  br i1 %61, label %.lr.ph.split.us, label %.loopexit, !llvm.loop !11

62:                                               ; preds = %.split.us
  %63 = tail call noundef i32 @_ZN3chw12get_uv_errorEb(i1 noundef zeroext true)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #5
  %64 = tail call noundef nonnull align 8 dereferenceable(144) ptr @_ZN3chw9getLoggerEv()
  call void @_ZN3chw17LogContextCaptureC1ERNS_6LoggerENS_8LogLevelEPKcS5_iS5_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(144) %64, i32 noundef 4, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__._ZN3chw8SockUtil13send_tcp_dataEiPcj, i32 noundef 1259, ptr noundef nonnull @.str)
  %65 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA19_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 1 dereferenceable(19) @.str.41)
          to label %66 unwind label %79

66:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  %67 = invoke noundef ptr @_ZN3chw11uv_strerrorEi(i32 noundef %63)
          to label %68 unwind label %81

68:                                               ; preds = %66
  store ptr %67, ptr %11, align 8, !tbaa !9
  %69 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIPKcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %65, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %70 unwind label %81

70:                                               ; preds = %68
  %71 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA6_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %69, ptr noundef nonnull align 1 dereferenceable(6) @.str.38)
          to label %72 unwind label %81

72:                                               ; preds = %70
  %73 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %71, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %74 unwind label %81

74:                                               ; preds = %72
  %75 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA5_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %73, ptr noundef nonnull align 1 dereferenceable(5) @.str.40)
          to label %76 unwind label %81

76:                                               ; preds = %74
  %77 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRiEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24) %75, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %78 unwind label %81

78:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  br label %.loopexit

79:                                               ; preds = %62
  %80 = landingpad { ptr, i32 }
          cleanup
  br label %83

81:                                               ; preds = %76, %74, %72, %70, %68, %66
  %82 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  br label %83

83:                                               ; preds = %81, %79
  %.pn = phi { ptr, i32 } [ %82, %81 ], [ %80, %79 ]
  call void @_ZN3chw17LogContextCaptureD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  br label %84

.loopexit:                                        ; preds = %.outer, %3, %.thread, %78
  %.2 = phi i32 [ 0, %78 ], [ %53, %.thread ], [ 0, %3 ], [ %59, %.outer ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  ret i32 %.2

84:                                               ; preds = %83, %58
  %.pn25.pn = phi { ptr, i32 } [ %.pn25, %58 ], [ %.pn, %83 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  resume { ptr, i32 } %.pn25.pn
}

declare i64 @send(i32 noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @usleep(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA17_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(17)) local_unnamed_addr #3 align 2

declare noundef ptr @_ZN3chw11uv_strerrorEi(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA14_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(14)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRjEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA6_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(6)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRA5_KcEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 1 dereferenceable(5)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN3chw17LogContextCapturelsIRiEERS0_OT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass