; LLVM IR from PacktPublishing/Demystifying-Cryptography-with-OpenSSL-3 :: Chapter09 (tls-client)

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

@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [113 x i8], align 1
@__PRETTY_FUNCTION__.run_tls_client = external hidden unnamed_addr constant [69 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [45 x i8], align 1
@stdout = external global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @run_tls_client(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store i64 16384, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %23 = call noalias ptr @malloc(i64 noundef 16384) #8
  store ptr %23, ptr %16, align 8, !tbaa !5
  %24 = load ptr, ptr %16, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %4
  br label %28

27:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 49, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

28:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %29 = call noalias ptr @malloc(i64 noundef 16384) #8
  store ptr %29, ptr %17, align 8, !tbaa !5
  %30 = load ptr, ptr %17, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  br label %34

33:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.4, i32 noundef 51, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

34:                                               ; preds = %32
  call void @ERR_clear_error()
  %35 = call ptr @TLS_client_method()
  %36 = call ptr @SSL_CTX_new(ptr noundef %35)
  store ptr %36, ptr %12, align 8, !tbaa !5
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  br label %41

40:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.4, i32 noundef 56, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

41:                                               ; preds = %39
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %48

44:                                               ; preds = %41
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = call i32 @SSL_CTX_load_verify_locations(ptr noundef %45, ptr noundef %46, ptr noundef null)
  store i32 %47, ptr %11, align 4, !tbaa !9
  br label %51

48:                                               ; preds = %41
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = call i32 @SSL_CTX_set_default_verify_paths(ptr noundef %49)
  store i32 %50, ptr %11, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %48, %44
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = icmp sle i32 %52, 0
  br i1 %53, label %54, label %61

54:                                               ; preds = %51
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %60

57:                                               ; preds = %54
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.7) #7
  br label %60

60:                                               ; preds = %57, %54
  br label %188

61:                                               ; preds = %51
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  call void @SSL_CTX_set_verify(ptr noundef %62, i32 noundef 1, ptr noundef null)
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = call i64 @SSL_CTX_ctrl(ptr noundef %63, i32 noundef 33, i64 noundef 4, ptr noundef null)
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = call ptr @BIO_new_ssl_connect(ptr noundef %65)
  store ptr %66, ptr %13, align 8, !tbaa !5
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %70

69:                                               ; preds = %61
  br label %71

70:                                               ; preds = %61
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.4, i32 noundef 72, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

71:                                               ; preds = %69
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = call i64 @BIO_ctrl(ptr noundef %72, i32 noundef 100, i64 noundef 0, ptr noundef %73)
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = call i64 @BIO_ctrl(ptr noundef %75, i32 noundef 100, i64 noundef 1, ptr noundef %76)
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = call i64 @BIO_ctrl(ptr noundef %78, i32 noundef 110, i64 noundef 0, ptr noundef %14)
  %80 = trunc i64 %79 to i32
  store i32 %80, ptr %11, align 4, !tbaa !9
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = icmp eq i32 %81, 1
  br i1 %82, label %83, label %84

83:                                               ; preds = %71
  br label %85

84:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 78, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

85:                                               ; preds = %83
  %86 = load ptr, ptr %14, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %89

88:                                               ; preds = %85
  br label %90

89:                                               ; preds = %85
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.4, i32 noundef 79, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

90:                                               ; preds = %88
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = call i64 @SSL_ctrl(ptr noundef %91, i32 noundef 55, i64 noundef 0, ptr noundef %92)
  %94 = trunc i64 %93 to i32
  store i32 %94, ptr %11, align 4, !tbaa !9
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = icmp eq i32 %95, 1
  br i1 %96, label %97, label %98

97:                                               ; preds = %90
  br label %99

98:                                               ; preds = %90
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 82, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

99:                                               ; preds = %97
  %100 = load ptr, ptr %14, align 8, !tbaa !5
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = call i32 @SSL_set1_host(ptr noundef %100, ptr noundef %101)
  store i32 %102, ptr %11, align 4, !tbaa !9
  %103 = load i32, ptr %11, align 4, !tbaa !9
  %104 = icmp eq i32 %103, 1
  br i1 %104, label %105, label %106

105:                                              ; preds = %99
  br label %107

106:                                              ; preds = %99
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 85, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

107:                                              ; preds = %105
  %108 = load ptr, ptr %13, align 8, !tbaa !5
  %109 = call i64 @BIO_ctrl(ptr noundef %108, i32 noundef 101, i64 noundef 0, ptr noundef null)
  %110 = trunc i64 %109 to i32
  store i32 %110, ptr %11, align 4, !tbaa !9
  %111 = load i32, ptr %11, align 4, !tbaa !9
  %112 = icmp sle i32 %111, 0
  br i1 %112, label %113, label %122

113:                                              ; preds = %107
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  %115 = icmp ne ptr %114, null
  br i1 %115, label %116, label %121

116:                                              ; preds = %113
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = load ptr, ptr %6, align 8, !tbaa !5
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %117, ptr noundef @.str.11, ptr noundef %118, ptr noundef %119) #7
  br label %121

121:                                              ; preds = %116, %113
  br label %188

122:                                              ; preds = %107
  %123 = load ptr, ptr %17, align 8, !tbaa !5
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %123, i64 noundef 16384, ptr noundef @.str.12, ptr noundef %124) #7
  %126 = load ptr, ptr %17, align 8, !tbaa !5
  %127 = call i64 @strlen(ptr noundef %126) #10
  %128 = trunc i64 %127 to i32
  store i32 %128, ptr %18, align 4, !tbaa !9
  %129 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %130 = load ptr, ptr %17, align 8, !tbaa !5
  %131 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, ptr noundef %130)
  %132 = load ptr, ptr %13, align 8, !tbaa !5
  %133 = load ptr, ptr %17, align 8, !tbaa !5
  %134 = load i32, ptr %18, align 4, !tbaa !9
  %135 = call i32 @BIO_write(ptr noundef %132, ptr noundef %133, i32 noundef %134)
  store i32 %135, ptr %19, align 4, !tbaa !9
  %136 = load i32, ptr %19, align 4, !tbaa !9
  %137 = load i32, ptr %18, align 4, !tbaa !9
  %138 = icmp ne i32 %136, %137
  br i1 %138, label %139, label %146

139:                                              ; preds = %122
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = icmp ne ptr %140, null
  br i1 %141, label %142, label %145

142:                                              ; preds = %139
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  %144 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef @.str.15) #7
  br label %145

145:                                              ; preds = %142, %139
  br label %188

146:                                              ; preds = %122
  %147 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %148 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  br label %149

149:                                              ; preds = %184, %146
  %150 = load ptr, ptr %14, align 8, !tbaa !5
  %151 = call i32 @SSL_get_shutdown(ptr noundef %150)
  %152 = and i32 %151, 2
  %153 = icmp ne i32 %152, 2
  br i1 %153, label %154, label %185

154:                                              ; preds = %149
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  %155 = load ptr, ptr %13, align 8, !tbaa !5
  %156 = load ptr, ptr %16, align 8, !tbaa !5
  %157 = call i32 @BIO_read(ptr noundef %155, ptr noundef %156, i32 noundef 16384)
  store i32 %157, ptr %20, align 4, !tbaa !9
  %158 = load i32, ptr %20, align 4, !tbaa !9
  %159 = icmp sle i32 %158, 0
  br i1 %159, label %160, label %176

160:                                              ; preds = %154
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  %161 = load ptr, ptr %14, align 8, !tbaa !5
  %162 = load i32, ptr %20, align 4, !tbaa !9
  %163 = call i32 @SSL_get_error(ptr noundef %161, i32 noundef %162)
  store i32 %163, ptr %21, align 4, !tbaa !9
  %164 = load i32, ptr %21, align 4, !tbaa !9
  %165 = icmp eq i32 %164, 6
  br i1 %165, label %166, label %167

166:                                              ; preds = %160
  store i32 4, ptr %22, align 4
  br label %175

167:                                              ; preds = %160
  %168 = load ptr, ptr %9, align 8, !tbaa !5
  %169 = icmp ne ptr %168, null
  br i1 %169, label %170, label %174

170:                                              ; preds = %167
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = load i32, ptr %21, align 4, !tbaa !9
  %173 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %171, ptr noundef @.str.18, i32 noundef %172) #7
  br label %174

174:                                              ; preds = %170, %167
  store i32 2, ptr %22, align 4
  br label %175

175:                                              ; preds = %174, %166
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %182

176:                                              ; preds = %154
  %177 = load ptr, ptr %16, align 8, !tbaa !5
  %178 = load i32, ptr %20, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  %180 = load ptr, ptr @stdout, align 8, !tbaa !5
  %181 = call i64 @fwrite(ptr noundef %177, i64 noundef 1, i64 noundef %179, ptr noundef %180)
  store i32 0, ptr %22, align 4
  br label %182

182:                                              ; preds = %176, %175
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  %183 = load i32, ptr %22, align 4
  switch i32 %183, label %214 [
    i32 0, label %184
    i32 4, label %185
    i32 2, label %188
  ]

184:                                              ; preds = %182
  br label %149, !llvm.loop !13

185:                                              ; preds = %182, %149
  %186 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  %187 = load ptr, ptr %13, align 8, !tbaa !5
  call void @BIO_ssl_shutdown(ptr noundef %187)
  br label %189

188:                                              ; preds = %182, %145, %121, %60
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %189

189:                                              ; preds = %188, %185
  %190 = load ptr, ptr %13, align 8, !tbaa !5
  %191 = icmp ne ptr %190, null
  br i1 %191, label %192, label %194

192:                                              ; preds = %189
  %193 = load ptr, ptr %13, align 8, !tbaa !5
  call void @BIO_free_all(ptr noundef %193)
  br label %194

194:                                              ; preds = %192, %189
  %195 = load ptr, ptr %12, align 8, !tbaa !5
  %196 = icmp ne ptr %195, null
  br i1 %196, label %197, label %199

197:                                              ; preds = %194
  %198 = load ptr, ptr %12, align 8, !tbaa !5
  call void @SSL_CTX_free(ptr noundef %198)
  br label %199

199:                                              ; preds = %197, %194
  %200 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %200) #7
  %201 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %201) #7
  %202 = call i64 @ERR_peek_error()
  %203 = icmp ne i64 %202, 0
  br i1 %203, label %204, label %212

204:                                              ; preds = %199
  store i32 1, ptr %10, align 4, !tbaa !9
  %205 = load ptr, ptr %9, align 8, !tbaa !5
  %206 = icmp ne ptr %205, null
  br i1 %206, label %207, label %211

207:                                              ; preds = %204
  %208 = load ptr, ptr %9, align 8, !tbaa !5
  %209 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %208, ptr noundef @.str.20) #7
  %210 = load ptr, ptr %9, align 8, !tbaa !5
  call void @ERR_print_errors_fp(ptr noundef %210)
  br label %211

211:                                              ; preds = %207, %204
  call void @ERR_clear_error()
  br label %212

212:                                              ; preds = %211, %199
  %213 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %213, ptr %5, align 4
  store i32 1, ptr %22, align 4
  br label %214

214:                                              ; preds = %212, %182
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %215 = load i32, ptr %5, align 4
  ret i32 %215
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare void @ERR_clear_error() #5

declare ptr @SSL_CTX_new(ptr noundef) #5

declare ptr @TLS_client_method() #5

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

declare i32 @SSL_CTX_set_default_verify_paths(ptr noundef) #5

declare void @SSL_CTX_set_verify(ptr noundef, i32 noundef, ptr noundef) #5

declare i64 @SSL_CTX_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #5

declare ptr @BIO_new_ssl_connect(ptr noundef) #5

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #5

declare i64 @SSL_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #5

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #6

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

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

declare i32 @SSL_get_shutdown(ptr noundef) #5

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

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

declare void @BIO_ssl_shutdown(ptr noundef) #5

declare void @BIO_free_all(ptr noundef) #5

declare void @SSL_CTX_free(ptr noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

declare i64 @ERR_peek_error() #5

declare void @ERR_print_errors_fp(ptr noundef) #5

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

@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [113 x i8], align 1
@__PRETTY_FUNCTION__.run_tls_client = external hidden unnamed_addr constant [69 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [45 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [38 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @run_tls_client(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  store ptr null, ptr %5, align 8, !tbaa !5
  %6 = tail call noalias dereferenceable_or_null(16384) ptr @malloc(i64 noundef 16384) #9
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %8

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 49, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

8:                                                ; preds = %4
  %9 = tail call noalias dereferenceable_or_null(16384) ptr @malloc(i64 noundef 16384) #9
  %.not80 = icmp eq ptr %9, null
  br i1 %.not80, label %10, label %11

10:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.4, i32 noundef 51, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

11:                                               ; preds = %8
  tail call void @ERR_clear_error() #8
  %12 = tail call ptr @TLS_client_method() #8
  %13 = tail call ptr @SSL_CTX_new(ptr noundef %12) #8
  %.not81 = icmp eq ptr %13, null
  br i1 %.not81, label %14, label %15

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.4, i32 noundef 56, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

15:                                               ; preds = %11
  %.not82 = icmp eq ptr %2, null
  br i1 %.not82, label %18, label %16

16:                                               ; preds = %15
  %17 = tail call i32 @SSL_CTX_load_verify_locations(ptr noundef nonnull %13, ptr noundef nonnull %2, ptr noundef null) #8
  br label %20

18:                                               ; preds = %15
  %19 = tail call i32 @SSL_CTX_set_default_verify_paths(ptr noundef nonnull %13) #8
  br label %20

20:                                               ; preds = %18, %16
  %.066 = phi i32 [ %17, %16 ], [ %19, %18 ]
  %21 = icmp slt i32 %.066, 1
  br i1 %21, label %22, label %25

22:                                               ; preds = %20
  %.not90 = icmp eq ptr %3, null
  br i1 %.not90, label %.thread106, label %23

23:                                               ; preds = %22
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.7) #8
  br label %.thread106

25:                                               ; preds = %20
  tail call void @SSL_CTX_set_verify(ptr noundef nonnull %13, i32 noundef 1, ptr noundef null) #8
  %26 = tail call i64 @SSL_CTX_ctrl(ptr noundef nonnull %13, i32 noundef 33, i64 noundef 4, ptr noundef null) #8
  %27 = tail call ptr @BIO_new_ssl_connect(ptr noundef nonnull %13) #8
  %.not83 = icmp eq ptr %27, null
  br i1 %.not83, label %28, label %29

28:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.4, i32 noundef 72, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

29:                                               ; preds = %25
  %30 = tail call i64 @BIO_ctrl(ptr noundef nonnull %27, i32 noundef 100, i64 noundef 0, ptr noundef %0) #8
  %31 = tail call i64 @BIO_ctrl(ptr noundef nonnull %27, i32 noundef 100, i64 noundef 1, ptr noundef %1) #8
  %32 = call i64 @BIO_ctrl(ptr noundef nonnull %27, i32 noundef 110, i64 noundef 0, ptr noundef nonnull %5) #8
  %33 = and i64 %32, 4294967295
  %34 = icmp eq i64 %33, 1
  br i1 %34, label %36, label %35

35:                                               ; preds = %29
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.4, i32 noundef 78, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

36:                                               ; preds = %29
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %.not84 = icmp eq ptr %37, null
  br i1 %.not84, label %38, label %39

38:                                               ; preds = %36
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.4, i32 noundef 79, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

39:                                               ; preds = %36
  %40 = call i64 @SSL_ctrl(ptr noundef nonnull %37, i32 noundef 55, i64 noundef 0, ptr noundef %0) #8
  %41 = and i64 %40, 4294967295
  %42 = icmp eq i64 %41, 1
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.4, i32 noundef 82, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

44:                                               ; preds = %39
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call i32 @SSL_set1_host(ptr noundef %45, ptr noundef %0) #8
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.4, i32 noundef 85, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

49:                                               ; preds = %44
  %50 = call i64 @BIO_ctrl(ptr noundef nonnull %27, i32 noundef 101, i64 noundef 0, ptr noundef null) #8
  %51 = trunc i64 %50 to i32
  %52 = icmp slt i32 %51, 1
  br i1 %52, label %53, label %56

53:                                               ; preds = %49
  %.not89 = icmp eq ptr %3, null
  br i1 %.not89, label %.thread98, label %54

54:                                               ; preds = %53
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.11, ptr noundef %0, ptr noundef %1) #8
  br label %.thread98

56:                                               ; preds = %49
  %57 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %9, i64 noundef 16384, ptr noundef nonnull @.str.12, ptr noundef %0) #8
  %58 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #11
  %59 = trunc i64 %58 to i32
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, ptr noundef nonnull %9)
  %62 = call i32 @BIO_write(ptr noundef nonnull %27, ptr noundef nonnull %9, i32 noundef %59) #8
  %.not85 = icmp eq i32 %62, %59
  br i1 %.not85, label %66, label %63

63:                                               ; preds = %56
  %.not88 = icmp eq ptr %3, null
  br i1 %.not88, label %.thread98, label %64

64:                                               ; preds = %63
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.15) #8
  br label %.thread98

66:                                               ; preds = %56
  %67 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %68 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = call i32 @SSL_get_shutdown(ptr noundef %69) #8
  %71 = and i32 %70, 2
  %.not86.not110 = icmp eq i32 %71, 0
  br i1 %.not86.not110, label %.lr.ph, label %.thread95

.lr.ph:                                           ; preds = %66, %81
  %72 = call i32 @BIO_read(ptr noundef nonnull %27, ptr noundef nonnull %6, i32 noundef 16384) #8
  %73 = icmp slt i32 %72, 1
  br i1 %73, label %74, label %81

74:                                               ; preds = %.lr.ph
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = call i32 @SSL_get_error(ptr noundef %75, i32 noundef %72) #8
  %77 = icmp eq i32 %76, 6
  br i1 %77, label %.thread95, label %78

78:                                               ; preds = %74
  %.not87 = icmp eq ptr %3, null
  br i1 %.not87, label %.thread98, label %79

79:                                               ; preds = %78
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.18, i32 noundef %76) #8
  br label %.thread98

81:                                               ; preds = %.lr.ph
  %82 = zext nneg i32 %72 to i64
  %83 = load ptr, ptr @stdout, align 8, !tbaa !5
  %84 = call i64 @fwrite(ptr noundef nonnull %6, i64 noundef 1, i64 noundef %82, ptr noundef %83)
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call i32 @SSL_get_shutdown(ptr noundef %85) #8
  %87 = and i32 %86, 2
  %.not86.not = icmp eq i32 %87, 0
  br i1 %.not86.not, label %.lr.ph, label %.thread95

.thread95:                                        ; preds = %81, %66, %74
  %88 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19)
  call void @BIO_ssl_shutdown(ptr noundef nonnull %27) #8
  br label %.thread98

.thread98:                                        ; preds = %.thread95, %79, %78, %63, %64, %53, %54
  %.064103 = phi i32 [ 1, %54 ], [ 1, %53 ], [ 1, %64 ], [ 1, %63 ], [ 0, %.thread95 ], [ 1, %79 ], [ 1, %78 ]
  call void @BIO_free_all(ptr noundef nonnull %27) #8
  br label %.thread106

.thread106:                                       ; preds = %22, %23, %.thread98
  %.064104 = phi i32 [ %.064103, %.thread98 ], [ 1, %23 ], [ 1, %22 ]
  call void @SSL_CTX_free(ptr noundef nonnull %13) #8
  call void @free(ptr noundef %9) #8
  call void @free(ptr noundef %6) #8
  %89 = call i64 @ERR_peek_error() #8
  %.not92 = icmp eq i64 %89, 0
  br i1 %.not92, label %94, label %90

90:                                               ; preds = %.thread106
  %.not93 = icmp eq ptr %3, null
  br i1 %.not93, label %93, label %91

91:                                               ; preds = %90
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.20) #8
  call void @ERR_print_errors_fp(ptr noundef nonnull %3) #8
  br label %93

93:                                               ; preds = %91, %90
  call void @ERR_clear_error() #8
  br label %94

94:                                               ; preds = %.thread106, %93
  %.063 = phi i32 [ 1, %93 ], [ %.064104, %.thread106 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  ret i32 %.063
}

; 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 allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

declare void @ERR_clear_error() local_unnamed_addr #5

declare ptr @SSL_CTX_new(ptr noundef) local_unnamed_addr #5

declare ptr @TLS_client_method() local_unnamed_addr #5

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

declare i32 @SSL_CTX_set_default_verify_paths(ptr noundef) local_unnamed_addr #5

declare void @SSL_CTX_set_verify(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

declare i64 @SSL_CTX_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #5

declare ptr @BIO_new_ssl_connect(ptr noundef) local_unnamed_addr #5

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #5

declare i64 @SSL_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #5

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

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #6

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

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

declare i32 @SSL_get_shutdown(ptr noundef) local_unnamed_addr #5

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

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

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

declare void @BIO_ssl_shutdown(ptr noundef) local_unnamed_addr #5

declare void @BIO_free_all(ptr noundef) local_unnamed_addr #5

declare void @SSL_CTX_free(ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #7

declare i64 @ERR_peek_error() local_unnamed_addr #5

declare void @ERR_print_errors_fp(ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { noreturn 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 = { "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 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 #7 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { noreturn nounwind }
attributes #11 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass