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

; 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 [114 x i8], align 1
@__PRETTY_FUNCTION__.run_tls_client = external hidden unnamed_addr constant [97 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, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  store ptr null, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  store i64 16384, ptr %19, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %28 = call noalias ptr @malloc(i64 noundef 16384) #8
  store ptr %28, ptr %20, align 8, !tbaa !5
  %29 = load ptr, ptr %20, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %6
  br label %33

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

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %34 = call noalias ptr @malloc(i64 noundef 16384) #8
  store ptr %34, ptr %21, align 8, !tbaa !5
  %35 = load ptr, ptr %21, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %33
  br label %39

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

39:                                               ; preds = %37
  call void @ERR_clear_error()
  %40 = call ptr @TLS_client_method()
  %41 = call ptr @SSL_CTX_new(ptr noundef %40)
  store ptr %41, ptr %16, align 8, !tbaa !5
  %42 = load ptr, ptr %16, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  br label %46

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

46:                                               ; preds = %44
  %47 = load ptr, ptr %16, align 8, !tbaa !5
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = call i32 @SSL_CTX_load_verify_locations(ptr noundef %47, ptr noundef %48, ptr noundef null)
  store i32 %49, ptr %15, align 4, !tbaa !9
  %50 = load i32, ptr %15, align 4, !tbaa !9
  %51 = icmp sle i32 %50, 0
  br i1 %51, label %52, label %59

52:                                               ; preds = %46
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %58

55:                                               ; preds = %52
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.7) #7
  br label %58

58:                                               ; preds = %55, %52
  br label %195

59:                                               ; preds = %46
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = call i32 @load_client_certificate(ptr noundef %60, ptr noundef %61, ptr noundef %62, ptr noundef %63)
  store i32 %64, ptr %22, align 4, !tbaa !9
  %65 = load i32, ptr %22, align 4, !tbaa !9
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %59
  br label %195

68:                                               ; preds = %59
  %69 = load ptr, ptr %16, align 8, !tbaa !5
  call void @SSL_CTX_set_verify(ptr noundef %69, i32 noundef 1, ptr noundef null)
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = call i64 @SSL_CTX_ctrl(ptr noundef %70, i32 noundef 33, i64 noundef 4, ptr noundef null)
  %72 = load ptr, ptr %16, align 8, !tbaa !5
  %73 = call ptr @BIO_new_ssl_connect(ptr noundef %72)
  store ptr %73, ptr %17, align 8, !tbaa !5
  %74 = load ptr, ptr %17, align 8, !tbaa !5
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %77

76:                                               ; preds = %68
  br label %78

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

78:                                               ; preds = %76
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = call i64 @BIO_ctrl(ptr noundef %79, i32 noundef 100, i64 noundef 0, ptr noundef %80)
  %82 = load ptr, ptr %17, align 8, !tbaa !5
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = call i64 @BIO_ctrl(ptr noundef %82, i32 noundef 100, i64 noundef 1, ptr noundef %83)
  %85 = load ptr, ptr %17, align 8, !tbaa !5
  %86 = call i64 @BIO_ctrl(ptr noundef %85, i32 noundef 110, i64 noundef 0, ptr noundef %18)
  %87 = trunc i64 %86 to i32
  store i32 %87, ptr %15, align 4, !tbaa !9
  %88 = load i32, ptr %15, align 4, !tbaa !9
  %89 = icmp eq i32 %88, 1
  br i1 %89, label %90, label %91

90:                                               ; preds = %78
  br label %92

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

92:                                               ; preds = %90
  %93 = load ptr, ptr %18, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %95, label %96

95:                                               ; preds = %92
  br label %97

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

97:                                               ; preds = %95
  %98 = load ptr, ptr %18, align 8, !tbaa !5
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = call i64 @SSL_ctrl(ptr noundef %98, i32 noundef 55, i64 noundef 0, ptr noundef %99)
  %101 = trunc i64 %100 to i32
  store i32 %101, ptr %15, align 4, !tbaa !9
  %102 = load i32, ptr %15, align 4, !tbaa !9
  %103 = icmp eq i32 %102, 1
  br i1 %103, label %104, label %105

104:                                              ; preds = %97
  br label %106

105:                                              ; preds = %97
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 115, ptr noundef @__PRETTY_FUNCTION__.run_tls_client) #9
  unreachable

106:                                              ; preds = %104
  %107 = load ptr, ptr %18, align 8, !tbaa !5
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = call i32 @SSL_set1_host(ptr noundef %107, ptr noundef %108)
  store i32 %109, ptr %15, align 4, !tbaa !9
  %110 = load i32, ptr %15, align 4, !tbaa !9
  %111 = icmp eq i32 %110, 1
  br i1 %111, label %112, label %113

112:                                              ; preds = %106
  br label %114

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

114:                                              ; preds = %112
  %115 = load ptr, ptr %17, align 8, !tbaa !5
  %116 = call i64 @BIO_ctrl(ptr noundef %115, i32 noundef 101, i64 noundef 0, ptr noundef null)
  %117 = trunc i64 %116 to i32
  store i32 %117, ptr %15, align 4, !tbaa !9
  %118 = load i32, ptr %15, align 4, !tbaa !9
  %119 = icmp sle i32 %118, 0
  br i1 %119, label %120, label %129

120:                                              ; preds = %114
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = icmp ne ptr %121, null
  br i1 %122, label %123, label %128

123:                                              ; preds = %120
  %124 = load ptr, ptr %13, align 8, !tbaa !5
  %125 = load ptr, ptr %8, align 8, !tbaa !5
  %126 = load ptr, ptr %9, align 8, !tbaa !5
  %127 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %124, ptr noundef @.str.11, ptr noundef %125, ptr noundef %126) #7
  br label %128

128:                                              ; preds = %123, %120
  br label %195

129:                                              ; preds = %114
  %130 = load ptr, ptr %21, align 8, !tbaa !5
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %130, i64 noundef 16384, ptr noundef @.str.12, ptr noundef %131) #7
  %133 = load ptr, ptr %21, align 8, !tbaa !5
  %134 = call i64 @strlen(ptr noundef %133) #10
  %135 = trunc i64 %134 to i32
  store i32 %135, ptr %23, align 4, !tbaa !9
  %136 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %137 = load ptr, ptr %21, align 8, !tbaa !5
  %138 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, ptr noundef %137)
  %139 = load ptr, ptr %17, align 8, !tbaa !5
  %140 = load ptr, ptr %21, align 8, !tbaa !5
  %141 = load i32, ptr %23, align 4, !tbaa !9
  %142 = call i32 @BIO_write(ptr noundef %139, ptr noundef %140, i32 noundef %141)
  store i32 %142, ptr %24, align 4, !tbaa !9
  %143 = load i32, ptr %24, align 4, !tbaa !9
  %144 = load i32, ptr %23, align 4, !tbaa !9
  %145 = icmp ne i32 %143, %144
  br i1 %145, label %146, label %153

146:                                              ; preds = %129
  %147 = load ptr, ptr %13, align 8, !tbaa !5
  %148 = icmp ne ptr %147, null
  br i1 %148, label %149, label %152

149:                                              ; preds = %146
  %150 = load ptr, ptr %13, align 8, !tbaa !5
  %151 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %150, ptr noundef @.str.15) #7
  br label %152

152:                                              ; preds = %149, %146
  br label %195

153:                                              ; preds = %129
  %154 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %155 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  br label %156

156:                                              ; preds = %191, %153
  %157 = load ptr, ptr %18, align 8, !tbaa !5
  %158 = call i32 @SSL_get_shutdown(ptr noundef %157)
  %159 = and i32 %158, 2
  %160 = icmp ne i32 %159, 2
  br i1 %160, label %161, label %192

161:                                              ; preds = %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %162 = load ptr, ptr %17, align 8, !tbaa !5
  %163 = load ptr, ptr %20, align 8, !tbaa !5
  %164 = call i32 @BIO_read(ptr noundef %162, ptr noundef %163, i32 noundef 16384)
  store i32 %164, ptr %25, align 4, !tbaa !9
  %165 = load i32, ptr %25, align 4, !tbaa !9
  %166 = icmp sle i32 %165, 0
  br i1 %166, label %167, label %183

167:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  %168 = load ptr, ptr %18, align 8, !tbaa !5
  %169 = load i32, ptr %25, align 4, !tbaa !9
  %170 = call i32 @SSL_get_error(ptr noundef %168, i32 noundef %169)
  store i32 %170, ptr %26, align 4, !tbaa !9
  %171 = load i32, ptr %26, align 4, !tbaa !9
  %172 = icmp eq i32 %171, 6
  br i1 %172, label %173, label %174

173:                                              ; preds = %167
  store i32 4, ptr %27, align 4
  br label %182

174:                                              ; preds = %167
  %175 = load ptr, ptr %13, align 8, !tbaa !5
  %176 = icmp ne ptr %175, null
  br i1 %176, label %177, label %181

177:                                              ; preds = %174
  %178 = load ptr, ptr %13, align 8, !tbaa !5
  %179 = load i32, ptr %26, align 4, !tbaa !9
  %180 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %178, ptr noundef @.str.18, i32 noundef %179) #7
  br label %181

181:                                              ; preds = %177, %174
  store i32 2, ptr %27, align 4
  br label %182

182:                                              ; preds = %181, %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  br label %189

183:                                              ; preds = %161
  %184 = load ptr, ptr %20, align 8, !tbaa !5
  %185 = load i32, ptr %25, align 4, !tbaa !9
  %186 = sext i32 %185 to i64
  %187 = load ptr, ptr @stdout, align 8, !tbaa !5
  %188 = call i64 @fwrite(ptr noundef %184, i64 noundef 1, i64 noundef %186, ptr noundef %187)
  store i32 0, ptr %27, align 4
  br label %189

189:                                              ; preds = %183, %182
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  %190 = load i32, ptr %27, align 4
  switch i32 %190, label %221 [
    i32 0, label %191
    i32 4, label %192
    i32 2, label %195
  ]

191:                                              ; preds = %189
  br label %156, !llvm.loop !13

192:                                              ; preds = %189, %156
  %193 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  %194 = load ptr, ptr %17, align 8, !tbaa !5
  call void @BIO_ssl_shutdown(ptr noundef %194)
  br label %196

195:                                              ; preds = %189, %152, %128, %67, %58
  store i32 1, ptr %14, align 4, !tbaa !9
  br label %196

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

199:                                              ; preds = %196
  %200 = load ptr, ptr %17, align 8, !tbaa !5
  call void @BIO_free_all(ptr noundef %200)
  br label %201

201:                                              ; preds = %199, %196
  %202 = load ptr, ptr %16, align 8, !tbaa !5
  %203 = icmp ne ptr %202, null
  br i1 %203, label %204, label %206

204:                                              ; preds = %201
  %205 = load ptr, ptr %16, align 8, !tbaa !5
  call void @SSL_CTX_free(ptr noundef %205)
  br label %206

206:                                              ; preds = %204, %201
  %207 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %207) #7
  %208 = load ptr, ptr %20, align 8, !tbaa !5
  call void @free(ptr noundef %208) #7
  %209 = call i64 @ERR_peek_error()
  %210 = icmp ne i64 %209, 0
  br i1 %210, label %211, label %219

211:                                              ; preds = %206
  store i32 1, ptr %14, align 4, !tbaa !9
  %212 = load ptr, ptr %13, align 8, !tbaa !5
  %213 = icmp ne ptr %212, null
  br i1 %213, label %214, label %218

214:                                              ; preds = %211
  %215 = load ptr, ptr %13, align 8, !tbaa !5
  %216 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %215, ptr noundef @.str.20) #7
  %217 = load ptr, ptr %13, align 8, !tbaa !5
  call void @ERR_print_errors_fp(ptr noundef %217)
  br label %218

218:                                              ; preds = %214, %211
  call void @ERR_clear_error()
  br label %219

219:                                              ; preds = %218, %206
  %220 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %220, ptr %7, align 4
  store i32 1, ptr %27, align 4
  br label %221

221:                                              ; preds = %219, %189
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  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 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  %222 = load i32, ptr %7, align 4
  ret i32 %222
}

; 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

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

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 [114 x i8], align 1
@__PRETTY_FUNCTION__.run_tls_client = external hidden unnamed_addr constant [97 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, ptr noundef %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  store ptr null, ptr %7, align 8, !tbaa !5
  %8 = tail call noalias dereferenceable_or_null(16384) ptr @malloc(i64 noundef 16384) #9
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

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

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

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

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

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

17:                                               ; preds = %13
  %18 = tail call i32 @SSL_CTX_load_verify_locations(ptr noundef nonnull %15, ptr noundef %2, ptr noundef null) #8
  %19 = icmp slt i32 %18, 1
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %.not91 = icmp eq ptr %5, null
  br i1 %.not91, label %.thread107, label %21

21:                                               ; preds = %20
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %5, ptr noundef nonnull @.str.7) #8
  br label %.thread107

23:                                               ; preds = %17
  %24 = tail call i32 @load_client_certificate(ptr noundef %3, ptr noundef %4, ptr noundef nonnull %15, ptr noundef %5)
  %.not83 = icmp eq i32 %24, 0
  br i1 %.not83, label %25, label %.thread107

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

28:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.4, i32 noundef 105, 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 %7) #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 111, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

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

38:                                               ; preds = %36
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.4, i32 noundef 112, 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 115, ptr noundef nonnull @__PRETTY_FUNCTION__.run_tls_client) #10
  unreachable

44:                                               ; preds = %39
  %45 = load ptr, ptr %7, 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 118, 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
  %.not90 = icmp eq ptr %5, null
  br i1 %.not90, label %.thread99, label %54

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

56:                                               ; preds = %49
  %57 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %11, i64 noundef 16384, ptr noundef nonnull @.str.12, ptr noundef %0) #8
  %58 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %11) #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 %11)
  %62 = call i32 @BIO_write(ptr noundef nonnull %27, ptr noundef nonnull %11, i32 noundef %59) #8
  %.not86 = icmp eq i32 %62, %59
  br i1 %.not86, label %66, label %63

63:                                               ; preds = %56
  %.not89 = icmp eq ptr %5, null
  br i1 %.not89, label %.thread99, label %64

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

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 %7, align 8, !tbaa !5
  %70 = call i32 @SSL_get_shutdown(ptr noundef %69) #8
  %71 = and i32 %70, 2
  %.not87.not111 = icmp eq i32 %71, 0
  br i1 %.not87.not111, label %.lr.ph, label %.thread96

.lr.ph:                                           ; preds = %66, %81
  %72 = call i32 @BIO_read(ptr noundef nonnull %27, ptr noundef nonnull %8, 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 %7, 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 %.thread96, label %78

78:                                               ; preds = %74
  %.not88 = icmp eq ptr %5, null
  br i1 %.not88, label %.thread99, label %79

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

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 %8, i64 noundef 1, i64 noundef %82, ptr noundef %83)
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = call i32 @SSL_get_shutdown(ptr noundef %85) #8
  %87 = and i32 %86, 2
  %.not87.not = icmp eq i32 %87, 0
  br i1 %.not87.not, label %.lr.ph, label %.thread96

.thread96:                                        ; 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 %.thread99

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

.thread107:                                       ; preds = %23, %20, %21, %.thread99
  %.067105 = phi i32 [ %.067104, %.thread99 ], [ 1, %21 ], [ 1, %20 ], [ 1, %23 ]
  call void @SSL_CTX_free(ptr noundef nonnull %15) #8
  call void @free(ptr noundef %11) #8
  call void @free(ptr noundef %8) #8
  %89 = call i64 @ERR_peek_error() #8
  %.not93 = icmp eq i64 %89, 0
  br i1 %.not93, label %94, label %90

90:                                               ; preds = %.thread107
  %.not94 = icmp eq ptr %5, null
  br i1 %.not94, label %93, label %91

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

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

94:                                               ; preds = %.thread107, %93
  %.066 = phi i32 [ 1, %93 ], [ %.067105, %.thread107 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  ret i32 %.066
}

; 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

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

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