; LLVM IR from kala13x/libxutils :: src/net (http)

; 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.XSocketInfo = type { [128 x i8], [256 x i8], i32, i32, i16 }
%struct.xhttp_ctx_ = type { i32, i32, ptr, i64 }
%struct.XLink = type { i32, [2048 x i8], [256 x i8], [256 x i8], [32 x i8], [32 x i8], [1024 x i8], [32 x i8] }
%struct.xhttp_ = type { ptr, i16, ptr, i32, %struct.XByteBuffer, i32, %struct.XMap, i16, i16, i64, i64, i64, i64, i64, i8, i8, i8, [256 x i8], [128 x i8], [2048 x i8] }
%struct.XByteBuffer = type { ptr, i64, i64, i16, i16, i32 }
%struct.XMap = type { ptr, ptr, ptr, i64, i64, i32 }

@.str.41 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [35 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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #1

declare zeroext i8 @xstrused(ptr noundef) #2

declare i64 @xstrncpy(ptr noundef, i64 noundef, ptr noundef) #2

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @XHTTP_SetAuthBasic(ptr noundef, ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @XHTTP_Connect(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.XSocketInfo, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [1024 x i8], align 16
  %13 = alloca %struct.xhttp_ctx_, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.XLink, ptr %15, i32 0, i32 7
  %17 = getelementptr inbounds [32 x i8], ptr %16, i64 0, i64 0
  %18 = call zeroext i8 @xstrused(ptr noundef %17)
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %25, label %20

20:                                               ; preds = %3
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.XLink, ptr %21, i32 0, i32 7
  %23 = getelementptr inbounds [32 x i8], ptr %22, i64 0, i64 0
  %24 = call i64 @xstrncpy(ptr noundef %23, i64 noundef 32, ptr noundef @.str.41)
  br label %25

25:                                               ; preds = %20, %3
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.XLink, ptr %26, i32 0, i32 7
  %28 = getelementptr inbounds [32 x i8], ptr %27, i64 0, i64 0
  %29 = call i32 @strncmp(ptr noundef %28, ptr noundef @.str.41, i64 noundef 4) #4
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %25
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i32 @XHTTP_StatusCb(ptr noundef %32, i32 noundef 7)
  store i32 %33, ptr %4, align 4
  br label %188

34:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 512, ptr %8, align 4, !tbaa !9
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.XLink, ptr %35, i32 0, i32 7
  %37 = getelementptr inbounds [32 x i8], ptr %36, i64 0, i64 0
  %38 = call i32 @strncmp(ptr noundef %37, ptr noundef @.str.42, i64 noundef 5) #4
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %43, label %40

40:                                               ; preds = %34
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = or i32 %41, 16
  store i32 %42, ptr %8, align 4, !tbaa !9
  call void @XSock_InitSSL()
  br label %43

43:                                               ; preds = %40, %34
  call void @llvm.lifetime.start.p0(i64 396, ptr %9) #5
  call void @XSock_InitInfo(ptr noundef %9)
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.xhttp_, ptr %44, i32 0, i32 17
  %46 = getelementptr inbounds [256 x i8], ptr %45, i64 0, i64 0
  %47 = call zeroext i8 @xstrused(ptr noundef %46)
  %48 = icmp ne i8 %47, 0
  br i1 %48, label %92, label %49

49:                                               ; preds = %43
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.XLink, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !11
  %53 = icmp sle i32 %52, 0
  br i1 %53, label %54, label %70

54:                                               ; preds = %49
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = call zeroext i8 @XFlags_IsSSL(i32 noundef %55)
  %57 = zext i8 %56 to i32
  %58 = icmp ne i32 %57, 0
  %59 = zext i1 %58 to i64
  %60 = select i1 %58, i32 443, i32 80
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.XLink, ptr %61, i32 0, i32 0
  store i32 %60, ptr %62, align 4, !tbaa !11
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.XLink, ptr %63, i32 0, i32 2
  %65 = getelementptr inbounds [256 x i8], ptr %64, i64 0, i64 0
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.XLink, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = call i64 (ptr, i64, ptr, ...) @xstrncat(ptr noundef %65, i64 noundef 256, ptr noundef @.str.43, i32 noundef %68)
  br label %70

70:                                               ; preds = %54, %49
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.XLink, ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds [256 x i8], ptr %72, i64 0, i64 0
  %74 = call i32 @XSock_GetAddrInfo(ptr noundef %9, ptr noundef %73)
  %75 = icmp slt i32 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %70
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = call i32 @XHTTP_StatusCb(ptr noundef %77, i32 noundef 14)
  store i32 %78, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %187

79:                                               ; preds = %70
  %80 = getelementptr inbounds %struct.XSocketInfo, ptr %9, i32 0, i32 4
  %81 = load i16, ptr %80, align 4, !tbaa !13
  %82 = icmp ne i16 %81, 0
  br i1 %82, label %89, label %83

83:                                               ; preds = %79
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.XLink, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !11
  %87 = trunc i32 %86 to i16
  %88 = getelementptr inbounds %struct.XSocketInfo, ptr %9, i32 0, i32 4
  store i16 %87, ptr %88, align 4, !tbaa !13
  br label %89

89:                                               ; preds = %83, %79
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = or i32 %90, 1
  store i32 %91, ptr %8, align 4, !tbaa !9
  br label %101

92:                                               ; preds = %43
  %93 = getelementptr inbounds %struct.XSocketInfo, ptr %9, i32 0, i32 0
  %94 = getelementptr inbounds [128 x i8], ptr %93, i64 0, i64 0
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.xhttp_, ptr %95, i32 0, i32 17
  %97 = getelementptr inbounds [256 x i8], ptr %96, i64 0, i64 0
  %98 = call i64 @xstrncpy(ptr noundef %94, i64 noundef 128, ptr noundef %97)
  %99 = load i32, ptr %8, align 4, !tbaa !9
  %100 = or i32 %99, 8
  store i32 %100, ptr %8, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %92, %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.XLink, ptr %103, i32 0, i32 4
  %105 = getelementptr inbounds [32 x i8], ptr %104, i64 0, i64 0
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.XLink, ptr %106, i32 0, i32 5
  %108 = getelementptr inbounds [32 x i8], ptr %107, i64 0, i64 0
  %109 = call i32 @XHTTP_SetAuthBasic(ptr noundef %102, ptr noundef %105, ptr noundef %108)
  store i32 %109, ptr %11, align 4, !tbaa !9
  %110 = load i32, ptr %11, align 4, !tbaa !9
  %111 = icmp slt i32 %110, 0
  br i1 %111, label %112, label %115

112:                                              ; preds = %101
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = call i32 @XHTTP_StatusCb(ptr noundef %113, i32 noundef 4)
  store i32 %114, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %186

115:                                              ; preds = %101
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.xhttp_, ptr %116, i32 0, i32 1
  %118 = load i16, ptr %117, align 8, !tbaa !16
  %119 = zext i16 %118 to i32
  %120 = and i32 %119, 8
  %121 = icmp eq i32 %120, 8
  br i1 %121, label %122, label %156

122:                                              ; preds = %115
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.xhttp_, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !21
  %126 = icmp ne ptr %125, null
  br i1 %126, label %127, label %156

127:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 1024, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #5
  %128 = load i32, ptr %8, align 4, !tbaa !9
  %129 = and i32 %128, 8
  %130 = icmp eq i32 %129, 8
  br i1 %130, label %131, label %137

131:                                              ; preds = %127
  %132 = getelementptr inbounds [1024 x i8], ptr %12, i64 0, i64 0
  %133 = getelementptr inbounds %struct.XSocketInfo, ptr %9, i32 0, i32 0
  %134 = getelementptr inbounds [128 x i8], ptr %133, i64 0, i64 0
  %135 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %132, i64 noundef 1024, ptr noundef @.str.44, ptr noundef %134)
  %136 = getelementptr inbounds %struct.xhttp_ctx_, ptr %13, i32 0, i32 3
  store i64 %135, ptr %136, align 8, !tbaa !22
  br label %146

137:                                              ; preds = %127
  %138 = getelementptr inbounds [1024 x i8], ptr %12, i64 0, i64 0
  %139 = getelementptr inbounds %struct.XSocketInfo, ptr %9, i32 0, i32 0
  %140 = getelementptr inbounds [128 x i8], ptr %139, i64 0, i64 0
  %141 = getelementptr inbounds %struct.XSocketInfo, ptr %9, i32 0, i32 4
  %142 = load i16, ptr %141, align 4, !tbaa !13
  %143 = zext i16 %142 to i32
  %144 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %138, i64 noundef 1024, ptr noundef @.str.45, ptr noundef %140, i32 noundef %143)
  %145 = getelementptr inbounds %struct.xhttp_ctx_, ptr %13, i32 0, i32 3
  store i64 %144, ptr %145, align 8, !tbaa !22
  br label %146

146:                                              ; preds = %137, %131
  %147 = getelementptr inbounds [1024 x i8], ptr %12, i64 0, i64 0
  %148 = getelementptr inbounds %struct.xhttp_ctx_, ptr %13, i32 0, i32 2
  store ptr %147, ptr %148, align 8, !tbaa !24
  %149 = getelementptr inbounds %struct.xhttp_ctx_, ptr %13, i32 0, i32 1
  store i32 8, ptr %149, align 4, !tbaa !25
  %150 = getelementptr inbounds %struct.xhttp_ctx_, ptr %13, i32 0, i32 0
  store i32 19, ptr %150, align 8, !tbaa !26
  %151 = load ptr, ptr %5, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.xhttp_, ptr %151, i32 0, i32 0
  %153 = load ptr, ptr %152, align 8, !tbaa !21
  %154 = load ptr, ptr %5, align 8, !tbaa !5
  %155 = call i32 %153(ptr noundef %154, ptr noundef %13)
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %12) #5
  br label %156

156:                                              ; preds = %146, %122, %115
  %157 = load ptr, ptr %6, align 8, !tbaa !5
  %158 = load i32, ptr %8, align 4, !tbaa !9
  %159 = call i32 @XSock_Open(ptr noundef %157, i32 noundef %158, ptr noundef %9)
  %160 = icmp eq i32 %159, -1
  br i1 %160, label %161, label %164

161:                                              ; preds = %156
  %162 = load ptr, ptr %5, align 8, !tbaa !5
  %163 = call i32 @XHTTP_StatusCb(ptr noundef %162, i32 noundef 13)
  store i32 %163, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %186

164:                                              ; preds = %156
  %165 = load ptr, ptr %5, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.xhttp_, ptr %165, i32 0, i32 13
  %167 = load i64, ptr %166, align 8, !tbaa !27
  %168 = icmp ne i64 %167, 0
  br i1 %168, label %169, label %185

169:                                              ; preds = %164
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %170 = load ptr, ptr %6, align 8, !tbaa !5
  %171 = load ptr, ptr %5, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.xhttp_, ptr %171, i32 0, i32 13
  %173 = load i64, ptr %172, align 8, !tbaa !27
  %174 = trunc i64 %173 to i32
  %175 = call i32 @XSock_TimeOutR(ptr noundef %170, i32 noundef %174, i32 noundef 0)
  store i32 %175, ptr %14, align 4, !tbaa !9
  %176 = load i32, ptr %14, align 4, !tbaa !9
  %177 = icmp eq i32 %176, -1
  br i1 %177, label %178, label %181

178:                                              ; preds = %169
  %179 = load ptr, ptr %5, align 8, !tbaa !5
  %180 = call i32 @XHTTP_StatusCb(ptr noundef %179, i32 noundef 8)
  store i32 %180, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %182

181:                                              ; preds = %169
  store i32 0, ptr %10, align 4
  br label %182

182:                                              ; preds = %181, %178
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %183 = load i32, ptr %10, align 4
  switch i32 %183, label %186 [
    i32 0, label %184
  ]

184:                                              ; preds = %182
  br label %185

185:                                              ; preds = %184, %164
  store i32 18, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %186

186:                                              ; preds = %185, %182, %161, %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %187

187:                                              ; preds = %186, %76
  call void @llvm.lifetime.end.p0(i64 396, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %188

188:                                              ; preds = %187, %31
  %189 = load i32, ptr %4, align 4
  ret i32 %189
}

declare void @XSock_InitSSL() #2

declare void @XSock_InitInfo(ptr noundef) #2

declare zeroext i8 @XFlags_IsSSL(i32 noundef) #2

declare i64 @xstrncat(ptr noundef, i64 noundef, ptr noundef, ...) #2

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind willreturn memory(read) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"XLink", !10, i64 0, !7, i64 4, !7, i64 2052, !7, i64 2308, !7, i64 2564, !7, i64 2596, !7, i64 2628, !7, i64 3652}
!13 = !{!14, !15, i64 392}
!14 = !{!"XSocketInfo", !7, i64 0, !7, i64 128, !10, i64 384, !10, i64 388, !15, i64 392}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !15, i64 8}
!17 = !{!"xhttp_", !6, i64 0, !15, i64 8, !6, i64 16, !10, i64 24, !18, i64 32, !10, i64 64, !20, i64 72, !15, i64 120, !15, i64 122, !19, i64 128, !19, i64 136, !19, i64 144, !19, i64 152, !19, i64 160, !7, i64 168, !7, i64 169, !7, i64 170, !7, i64 171, !7, i64 427, !7, i64 555}
!18 = !{!"XByteBuffer", !6, i64 0, !19, i64 8, !19, i64 16, !15, i64 24, !15, i64 26, !10, i64 28}
!19 = !{!"long", !7, i64 0}
!20 = !{!"XMap", !6, i64 0, !6, i64 8, !6, i64 16, !19, i64 24, !19, i64 32, !10, i64 40}
!21 = !{!17, !6, i64 0}
!22 = !{!23, !19, i64 16}
!23 = !{!"xhttp_ctx_", !10, i64 0, !10, i64 4, !6, i64 8, !19, i64 16}
!24 = !{!23, !6, i64 8}
!25 = !{!23, !10, i64 4}
!26 = !{!23, !10, i64 0}
!27 = !{!17, !19, i64 160}


; 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.XSocketInfo = type { [128 x i8], [256 x i8], i32, i32, i16 }
%struct.xhttp_ctx_ = type { i32, i32, ptr, i64 }

@.str.41 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [35 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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #1

declare zeroext i8 @xstrused(ptr noundef) local_unnamed_addr #2

declare i64 @xstrncpy(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @XHTTP_Connect(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca %struct.XSocketInfo, align 4
  %5 = alloca [1024 x i8], align 16
  %6 = alloca %struct.xhttp_ctx_, align 8
  %7 = getelementptr inbounds i8, ptr %2, i64 3652
  %8 = tail call zeroext i8 @xstrused(ptr noundef nonnull %7) #4
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %9, label %11

9:                                                ; preds = %3
  %10 = tail call i64 @xstrncpy(ptr noundef nonnull %7, i64 noundef 32, ptr noundef nonnull @.str.41) #4
  br label %11

11:                                               ; preds = %9, %3
  %12 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.41, i64 noundef 4) #5
  %.not41 = icmp eq i32 %12, 0
  br i1 %.not41, label %15, label %13

13:                                               ; preds = %11
  %14 = tail call i32 @XHTTP_StatusCb(ptr noundef %0, i32 noundef 7)
  br label %84

15:                                               ; preds = %11
  %16 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.42, i64 noundef 5) #5
  %.not42 = icmp eq i32 %16, 0
  br i1 %.not42, label %17, label %18

17:                                               ; preds = %15
  tail call void @XSock_InitSSL() #4
  br label %18

18:                                               ; preds = %17, %15
  %.037 = phi i32 [ 512, %15 ], [ 528, %17 ]
  call void @llvm.lifetime.start.p0(i64 396, ptr nonnull %4) #4
  call void @XSock_InitInfo(ptr noundef nonnull %4) #4
  %19 = getelementptr inbounds i8, ptr %0, i64 171
  %20 = call zeroext i8 @xstrused(ptr noundef nonnull %19) #4
  %.not43 = icmp eq i8 %20, 0
  br i1 %.not43, label %21, label %41

21:                                               ; preds = %18
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 1
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  %25 = call zeroext i8 @XFlags_IsSSL(i32 noundef %.037) #4
  %.not44 = icmp eq i8 %25, 0
  %26 = select i1 %.not44, i32 80, i32 443
  store i32 %26, ptr %2, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %2, i64 2052
  %28 = call i64 (ptr, i64, ptr, ...) @xstrncat(ptr noundef nonnull %27, i64 noundef 256, ptr noundef nonnull @.str.43, i32 noundef %26) #4
  br label %29

29:                                               ; preds = %24, %21
  %30 = getelementptr inbounds i8, ptr %2, i64 2052
  %31 = call i32 @XSock_GetAddrInfo(ptr noundef nonnull %4, ptr noundef nonnull %30) #4
  %32 = icmp slt i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %29
  %34 = call i32 @XHTTP_StatusCb(ptr noundef %0, i32 noundef 14)
  br label %83

35:                                               ; preds = %29
  %36 = getelementptr inbounds i8, ptr %4, i64 392
  %37 = load i16, ptr %36, align 4, !tbaa !10
  %.not45 = icmp eq i16 %37, 0
  br i1 %.not45, label %38, label %43

38:                                               ; preds = %35
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = trunc i32 %39 to i16
  store i16 %40, ptr %36, align 4, !tbaa !10
  br label %43

41:                                               ; preds = %18
  %42 = call i64 @xstrncpy(ptr noundef nonnull %4, i64 noundef 128, ptr noundef nonnull %19) #4
  br label %43

43:                                               ; preds = %35, %38, %41
  %.sink52 = phi i32 [ 8, %41 ], [ 1, %38 ], [ 1, %35 ]
  %44 = or disjoint i32 %.037, %.sink52
  %45 = getelementptr inbounds i8, ptr %2, i64 2564
  %46 = getelementptr inbounds i8, ptr %2, i64 2596
  %47 = call i32 @XHTTP_SetAuthBasic(ptr noundef %0, ptr noundef nonnull %45, ptr noundef nonnull %46)
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %43
  %50 = call i32 @XHTTP_StatusCb(ptr noundef %0, i32 noundef 4)
  br label %83

51:                                               ; preds = %43
  %52 = getelementptr inbounds i8, ptr %0, i64 8
  %53 = load i16, ptr %52, align 8, !tbaa !13
  %54 = and i16 %53, 8
  %.not46 = icmp eq i16 %54, 0
  br i1 %.not46, label %71, label %55

55:                                               ; preds = %51
  %56 = load ptr, ptr %0, align 8, !tbaa !19
  %.not47 = icmp eq ptr %56, null
  br i1 %.not47, label %71, label %57

57:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  br i1 %.not43, label %60, label %58

58:                                               ; preds = %57
  %59 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %5, i64 noundef 1024, ptr noundef nonnull @.str.44, ptr noundef nonnull %4) #4
  br label %65

60:                                               ; preds = %57
  %61 = getelementptr inbounds i8, ptr %4, i64 392
  %62 = load i16, ptr %61, align 4, !tbaa !10
  %63 = zext i16 %62 to i32
  %64 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %5, i64 noundef 1024, ptr noundef nonnull @.str.45, ptr noundef nonnull %4, i32 noundef %63) #4
  br label %65

65:                                               ; preds = %60, %58
  %.sink = phi i64 [ %64, %60 ], [ %59, %58 ]
  %66 = getelementptr inbounds i8, ptr %6, i64 16
  store i64 %.sink, ptr %66, align 8
  %67 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %5, ptr %67, align 8, !tbaa !20
  %68 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 8, ptr %68, align 4, !tbaa !22
  store i32 19, ptr %6, align 8, !tbaa !23
  %69 = load ptr, ptr %0, align 8, !tbaa !19
  %70 = call i32 %69(ptr noundef nonnull %0, ptr noundef nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #4
  br label %71

71:                                               ; preds = %65, %55, %51
  %72 = call i32 @XSock_Open(ptr noundef %1, i32 noundef %44, ptr noundef nonnull %4) #4
  %73 = icmp eq i32 %72, -1
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = call i32 @XHTTP_StatusCb(ptr noundef nonnull %0, i32 noundef 13)
  br label %83

76:                                               ; preds = %71
  %77 = getelementptr inbounds i8, ptr %0, i64 160
  %78 = load i64, ptr %77, align 8, !tbaa !24
  %.not49 = icmp eq i64 %78, 0
  br i1 %.not49, label %83, label %79

79:                                               ; preds = %76
  %80 = trunc i64 %78 to i32
  %81 = call i32 @XSock_TimeOutR(ptr noundef %1, i32 noundef %80, i32 noundef 0) #4
  %.not50 = icmp eq i32 %81, -1
  br i1 %.not50, label %.thread, label %83

.thread:                                          ; preds = %79
  %82 = call i32 @XHTTP_StatusCb(ptr noundef nonnull %0, i32 noundef 8)
  br label %83

83:                                               ; preds = %76, %79, %.thread, %49, %74, %33
  %.2 = phi i32 [ %34, %33 ], [ %50, %49 ], [ %75, %74 ], [ %82, %.thread ], [ 18, %79 ], [ 18, %76 ]
  call void @llvm.lifetime.end.p0(i64 396, ptr nonnull %4) #4
  br label %84

84:                                               ; preds = %83, %13
  %.3 = phi i32 [ %14, %13 ], [ %.2, %83 ]
  ret i32 %.3
}

declare void @XSock_InitSSL() local_unnamed_addr #2

declare void @XSock_InitInfo(ptr noundef) local_unnamed_addr #2

declare zeroext i8 @XFlags_IsSSL(i32 noundef) local_unnamed_addr #2

declare i64 @xstrncat(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #2

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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, !7, i64 0}
!6 = !{!"XLink", !7, i64 0, !8, i64 4, !8, i64 2052, !8, i64 2308, !8, i64 2564, !8, i64 2596, !8, i64 2628, !8, i64 3652}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 392}
!11 = !{!"XSocketInfo", !8, i64 0, !8, i64 128, !7, i64 384, !7, i64 388, !12, i64 392}
!12 = !{!"short", !8, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"xhttp_", !15, i64 0, !12, i64 8, !15, i64 16, !7, i64 24, !16, i64 32, !7, i64 64, !18, i64 72, !12, i64 120, !12, i64 122, !17, i64 128, !17, i64 136, !17, i64 144, !17, i64 152, !17, i64 160, !8, i64 168, !8, i64 169, !8, i64 170, !8, i64 171, !8, i64 427, !8, i64 555}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"XByteBuffer", !15, i64 0, !17, i64 8, !17, i64 16, !12, i64 24, !12, i64 26, !7, i64 28}
!17 = !{!"long", !8, i64 0}
!18 = !{!"XMap", !15, i64 0, !15, i64 8, !15, i64 16, !17, i64 24, !17, i64 32, !7, i64 40}
!19 = !{!14, !15, i64 0}
!20 = !{!21, !15, i64 8}
!21 = !{!"xhttp_ctx_", !7, i64 0, !7, i64 4, !15, i64 8, !17, i64 16}
!22 = !{!21, !7, i64 4}
!23 = !{!21, !7, i64 0}
!24 = !{!14, !17, i64 160}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass