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

; 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.4 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.ocsp_callback = external hidden unnamed_addr constant [33 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [51 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ocsp_callback(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %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 ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call ptr @SSL_get_ex_data(ptr noundef %24, i32 noundef 0)
  store ptr %25, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call i64 @SSL_ctrl(ptr noundef %26, i32 noundef 70, i64 noundef 0, ptr noundef %10)
  store i64 %27, ptr %11, align 8, !tbaa !11
  %28 = load i64, ptr %11, align 8, !tbaa !11
  %29 = icmp sle i64 %28, 0
  br i1 %29, label %33, label %30

30:                                               ; preds = %2
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %40, label %33

33:                                               ; preds = %30, %2
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.13) #6
  br label %39

39:                                               ; preds = %36, %33
  br label %199

40:                                               ; preds = %30
  %41 = load i64, ptr %11, align 8, !tbaa !11
  %42 = call ptr @d2i_OCSP_RESPONSE(ptr noundef null, ptr noundef %10, i64 noundef %41)
  store ptr %42, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %52, label %45

45:                                               ; preds = %40
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %51

48:                                               ; preds = %45
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.14) #6
  br label %51

51:                                               ; preds = %48, %45
  br label %199

52:                                               ; preds = %40
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %74

55:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = call ptr @BIO_new_fp(ptr noundef %56, i32 noundef 0)
  store ptr %57, ptr %12, align 8, !tbaa !5
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  br label %62

61:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.4, i32 noundef 163, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

62:                                               ; preds = %60
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.16) #6
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.17) #6
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call i32 @OCSP_RESPONSE_print(ptr noundef %67, ptr noundef %68, i64 noundef 0)
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str.18) #6
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = call i32 @BIO_free(ptr noundef %72)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %74

74:                                               ; preds = %62, %52
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = call i32 @OCSP_response_status(ptr noundef %75)
  store i32 %76, ptr %13, align 4, !tbaa !9
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %86

79:                                               ; preds = %74
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %85

82:                                               ; preds = %79
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.19) #6
  br label %85

85:                                               ; preds = %82, %79
  br label %199

86:                                               ; preds = %74
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = call ptr @OCSP_response_get1_basic(ptr noundef %87)
  store ptr %88, ptr %7, align 8, !tbaa !5
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %86
  br label %93

92:                                               ; preds = %86
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.4, i32 noundef 179, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

93:                                               ; preds = %91
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = call ptr @SSL_get0_verified_chain(ptr noundef %94)
  store ptr %95, ptr %14, align 8, !tbaa !5
  %96 = load ptr, ptr %14, align 8, !tbaa !5
  %97 = icmp ne ptr %96, null
  br i1 %97, label %98, label %99

98:                                               ; preds = %93
  br label %100

99:                                               ; preds = %93
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.4, i32 noundef 182, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

100:                                              ; preds = %98
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = call ptr @SSL_get_SSL_CTX(ptr noundef %101)
  store ptr %102, ptr %15, align 8, !tbaa !5
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = icmp ne ptr %103, null
  br i1 %104, label %105, label %106

105:                                              ; preds = %100
  br label %107

106:                                              ; preds = %100
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.4, i32 noundef 185, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

107:                                              ; preds = %105
  %108 = load ptr, ptr %15, align 8, !tbaa !5
  %109 = call ptr @SSL_CTX_get_cert_store(ptr noundef %108)
  store ptr %109, ptr %16, align 8, !tbaa !5
  %110 = load ptr, ptr %16, align 8, !tbaa !5
  %111 = icmp ne ptr %110, null
  br i1 %111, label %112, label %113

112:                                              ; preds = %107
  br label %114

113:                                              ; preds = %107
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.4, i32 noundef 187, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

114:                                              ; preds = %112
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = load ptr, ptr %14, align 8, !tbaa !5
  %117 = load ptr, ptr %16, align 8, !tbaa !5
  %118 = call i32 @OCSP_basic_verify(ptr noundef %115, ptr noundef %116, ptr noundef %117, i64 noundef 0)
  store i32 %118, ptr %13, align 4, !tbaa !9
  %119 = load i32, ptr %13, align 4, !tbaa !9
  %120 = icmp ne i32 %119, 1
  br i1 %120, label %121, label %128

121:                                              ; preds = %114
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  %123 = icmp ne ptr %122, null
  br i1 %123, label %124, label %127

124:                                              ; preds = %121
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %125, ptr noundef @.str.23) #6
  br label %127

127:                                              ; preds = %124, %121
  br label %199

128:                                              ; preds = %114
  %129 = load ptr, ptr %14, align 8, !tbaa !5
  %130 = call ptr @ossl_check_const_X509_sk_type(ptr noundef %129)
  %131 = call i32 @OPENSSL_sk_num(ptr noundef %130)
  %132 = icmp sge i32 %131, 2
  br i1 %132, label %133, label %134

133:                                              ; preds = %128
  br label %135

134:                                              ; preds = %128
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.4, i32 noundef 196, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

135:                                              ; preds = %133
  %136 = load ptr, ptr %14, align 8, !tbaa !5
  %137 = call ptr @ossl_check_const_X509_sk_type(ptr noundef %136)
  %138 = call ptr @OPENSSL_sk_value(ptr noundef %137, i32 noundef 0)
  store ptr %138, ptr %17, align 8, !tbaa !5
  %139 = load ptr, ptr %14, align 8, !tbaa !5
  %140 = call ptr @ossl_check_const_X509_sk_type(ptr noundef %139)
  %141 = call ptr @OPENSSL_sk_value(ptr noundef %140, i32 noundef 1)
  store ptr %141, ptr %18, align 8, !tbaa !5
  %142 = load ptr, ptr %17, align 8, !tbaa !5
  %143 = load ptr, ptr %18, align 8, !tbaa !5
  %144 = call ptr @OCSP_cert_to_id(ptr noundef null, ptr noundef %142, ptr noundef %143)
  store ptr %144, ptr %8, align 8, !tbaa !5
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  %146 = icmp ne ptr %145, null
  br i1 %146, label %147, label %148

147:                                              ; preds = %135
  br label %149

148:                                              ; preds = %135
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.4, i32 noundef 200, ptr noundef @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

149:                                              ; preds = %147
  store ptr null, ptr %19, align 8, !tbaa !5
  store ptr null, ptr %20, align 8, !tbaa !5
  store ptr null, ptr %21, align 8, !tbaa !5
  store i32 2, ptr %22, align 4, !tbaa !9
  store i32 -1, ptr %23, align 4, !tbaa !9
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = load ptr, ptr %8, align 8, !tbaa !5
  %152 = call i32 @OCSP_resp_find_status(ptr noundef %150, ptr noundef %151, ptr noundef %22, ptr noundef %23, ptr noundef %19, ptr noundef %20, ptr noundef %21)
  store i32 %152, ptr %13, align 4, !tbaa !9
  %153 = load i32, ptr %13, align 4, !tbaa !9
  %154 = icmp ne i32 %153, 1
  br i1 %154, label %155, label %162

155:                                              ; preds = %149
  %156 = load ptr, ptr %9, align 8, !tbaa !5
  %157 = icmp ne ptr %156, null
  br i1 %157, label %158, label %161

158:                                              ; preds = %155
  %159 = load ptr, ptr %9, align 8, !tbaa !5
  %160 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %159, ptr noundef @.str.26) #6
  br label %161

161:                                              ; preds = %158, %155
  br label %199

162:                                              ; preds = %149
  %163 = load ptr, ptr %20, align 8, !tbaa !5
  %164 = load ptr, ptr %21, align 8, !tbaa !5
  %165 = call i32 @OCSP_check_validity(ptr noundef %163, ptr noundef %164, i64 noundef 300, i64 noundef -1)
  store i32 %165, ptr %13, align 4, !tbaa !9
  %166 = load i32, ptr %13, align 4, !tbaa !9
  %167 = icmp ne i32 %166, 1
  br i1 %167, label %168, label %175

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

171:                                              ; preds = %168
  %172 = load ptr, ptr %9, align 8, !tbaa !5
  %173 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %172, ptr noundef @.str.27) #6
  br label %174

174:                                              ; preds = %171, %168
  br label %199

175:                                              ; preds = %162
  %176 = load i32, ptr %22, align 4, !tbaa !9
  switch i32 %176, label %191 [
    i32 1, label %177
    i32 0, label %184
  ]

177:                                              ; preds = %175
  %178 = load ptr, ptr %9, align 8, !tbaa !5
  %179 = icmp ne ptr %178, null
  br i1 %179, label %180, label %183

180:                                              ; preds = %177
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %181, ptr noundef @.str.28) #6
  br label %183

183:                                              ; preds = %180, %177
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %198

184:                                              ; preds = %175
  %185 = load ptr, ptr %9, align 8, !tbaa !5
  %186 = icmp ne ptr %185, null
  br i1 %186, label %187, label %190

187:                                              ; preds = %184
  %188 = load ptr, ptr %9, align 8, !tbaa !5
  %189 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %188, ptr noundef @.str.29) #6
  br label %190

190:                                              ; preds = %187, %184
  br label %198

191:                                              ; preds = %175
  %192 = load ptr, ptr %9, align 8, !tbaa !5
  %193 = icmp ne ptr %192, null
  br i1 %193, label %194, label %197

194:                                              ; preds = %191
  %195 = load ptr, ptr %9, align 8, !tbaa !5
  %196 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %195, ptr noundef @.str.30) #6
  br label %197

197:                                              ; preds = %194, %191
  br label %198

198:                                              ; preds = %197, %190, %183
  br label %199

199:                                              ; preds = %198, %174, %161, %127, %85, %51, %39
  %200 = load ptr, ptr %8, align 8, !tbaa !5
  %201 = icmp ne ptr %200, null
  br i1 %201, label %202, label %204

202:                                              ; preds = %199
  %203 = load ptr, ptr %8, align 8, !tbaa !5
  call void @OCSP_CERTID_free(ptr noundef %203)
  br label %204

204:                                              ; preds = %202, %199
  %205 = load ptr, ptr %7, align 8, !tbaa !5
  %206 = icmp ne ptr %205, null
  br i1 %206, label %207, label %209

207:                                              ; preds = %204
  %208 = load ptr, ptr %7, align 8, !tbaa !5
  call void @OCSP_BASICRESP_free(ptr noundef %208)
  br label %209

209:                                              ; preds = %207, %204
  %210 = load ptr, ptr %6, align 8, !tbaa !5
  %211 = icmp ne ptr %210, null
  br i1 %211, label %212, label %214

212:                                              ; preds = %209
  %213 = load ptr, ptr %6, align 8, !tbaa !5
  call void @OCSP_RESPONSE_free(ptr noundef %213)
  br label %214

214:                                              ; preds = %212, %209
  %215 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret i32 %215
}

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

declare ptr @SSL_get_ex_data(ptr noundef, i32 noundef) #4

declare ptr @d2i_OCSP_RESPONSE(ptr noundef, ptr noundef, i64 noundef) #4

declare ptr @BIO_new_fp(ptr noundef, i32 noundef) #4

declare i32 @OCSP_RESPONSE_print(ptr noundef, ptr noundef, i64 noundef) #4

declare i32 @BIO_free(ptr noundef) #4

declare i32 @OCSP_response_status(ptr noundef) #4

declare ptr @OCSP_response_get1_basic(ptr noundef) #4

declare ptr @SSL_get0_verified_chain(ptr noundef) #4

declare ptr @SSL_get_SSL_CTX(ptr noundef) #4

declare ptr @SSL_CTX_get_cert_store(ptr noundef) #4

declare i32 @OCSP_basic_verify(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #4

declare i32 @OPENSSL_sk_num(ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ossl_check_const_X509_sk_type(ptr noundef) #5

declare ptr @OPENSSL_sk_value(ptr noundef, i32 noundef) #4

declare ptr @OCSP_cert_to_id(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @OCSP_resp_find_status(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @OCSP_check_validity(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #4

declare void @OCSP_CERTID_free(ptr noundef) #4

declare void @OCSP_BASICRESP_free(ptr noundef) #4

declare void @OCSP_RESPONSE_free(ptr noundef) #4

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 = { 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 #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 = { "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 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { noreturn 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, !12, i64 0}
!12 = !{!"long", !7, i64 0}


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

@.str.4 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1
@__PRETTY_FUNCTION__.ocsp_callback = external hidden unnamed_addr constant [33 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [51 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ocsp_callback(ptr noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = tail call ptr @SSL_get_ex_data(ptr noundef %0, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  store ptr null, ptr %3, align 8, !tbaa !5
  %10 = call i64 @SSL_ctrl(ptr noundef %0, i32 noundef 70, i64 noundef 0, ptr noundef nonnull %3) #6
  %11 = icmp sgt i64 %10, 0
  %12 = load ptr, ptr %3, align 8
  %13 = icmp ne ptr %12, null
  %or.cond = select i1 %11, i1 %13, i1 false
  br i1 %or.cond, label %17, label %14

14:                                               ; preds = %2
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %.thread123, label %15

15:                                               ; preds = %14
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.13) #6
  br label %.thread123

17:                                               ; preds = %2
  %18 = call ptr @d2i_OCSP_RESPONSE(ptr noundef null, ptr noundef nonnull %3, i64 noundef %10) #6
  %.not76 = icmp eq ptr %18, null
  %.not77 = icmp eq ptr %9, null
  br i1 %.not76, label %19, label %22

19:                                               ; preds = %17
  br i1 %.not77, label %.thread123, label %20

20:                                               ; preds = %19
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.14) #6
  br label %.thread123

22:                                               ; preds = %17
  br i1 %.not77, label %26, label %23

23:                                               ; preds = %22
  %24 = call ptr @BIO_new_fp(ptr noundef nonnull %9, i32 noundef 0) #6
  %.not79 = icmp eq ptr %24, null
  br i1 %.not79, label %25, label %.thread

25:                                               ; preds = %23
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.4, i32 noundef 163, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

26:                                               ; preds = %22
  %27 = call i32 @OCSP_response_status(ptr noundef nonnull %18) #6
  %.not80 = icmp eq i32 %27, 0
  br i1 %.not80, label %36, label %80

.thread:                                          ; preds = %23
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.16) #6
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.17) #6
  %30 = call i32 @OCSP_RESPONSE_print(ptr noundef nonnull %24, ptr noundef nonnull %18, i64 noundef 0) #6
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.18) #6
  %32 = call i32 @BIO_free(ptr noundef nonnull %24) #6
  %33 = call i32 @OCSP_response_status(ptr noundef nonnull %18) #6
  %.not8092 = icmp eq i32 %33, 0
  br i1 %.not8092, label %36, label %34

34:                                               ; preds = %.thread
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.19) #6
  br label %80

36:                                               ; preds = %.thread, %26
  %37 = call ptr @OCSP_response_get1_basic(ptr noundef nonnull %18) #6
  %.not81 = icmp eq ptr %37, null
  br i1 %.not81, label %38, label %39

38:                                               ; preds = %36
  call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.4, i32 noundef 179, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

39:                                               ; preds = %36
  %40 = call ptr @SSL_get0_verified_chain(ptr noundef %0) #6
  %.not82 = icmp eq ptr %40, null
  br i1 %.not82, label %41, label %42

41:                                               ; preds = %39
  call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.4, i32 noundef 182, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

42:                                               ; preds = %39
  %43 = call ptr @SSL_get_SSL_CTX(ptr noundef %0) #6
  %.not83 = icmp eq ptr %43, null
  br i1 %.not83, label %44, label %45

44:                                               ; preds = %42
  call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.4, i32 noundef 185, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

45:                                               ; preds = %42
  %46 = call ptr @SSL_CTX_get_cert_store(ptr noundef nonnull %43) #6
  %.not84 = icmp eq ptr %46, null
  br i1 %.not84, label %47, label %48

47:                                               ; preds = %45
  call void @__assert_fail(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.4, i32 noundef 187, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

48:                                               ; preds = %45
  %49 = call i32 @OCSP_basic_verify(ptr noundef nonnull %37, ptr noundef nonnull %40, ptr noundef nonnull %46, i64 noundef 0) #6
  %.not85 = icmp eq i32 %49, 1
  br i1 %.not85, label %53, label %50

50:                                               ; preds = %48
  br i1 %.not77, label %.thread115, label %51

51:                                               ; preds = %50
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.23) #6
  br label %.thread115

53:                                               ; preds = %48
  %54 = call ptr @ossl_check_const_X509_sk_type(ptr noundef nonnull %40)
  %55 = call i32 @OPENSSL_sk_num(ptr noundef %54) #6
  %56 = icmp sgt i32 %55, 1
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.4, i32 noundef 196, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

58:                                               ; preds = %53
  %59 = call ptr @ossl_check_const_X509_sk_type(ptr noundef nonnull %40)
  %60 = call ptr @OPENSSL_sk_value(ptr noundef %59, i32 noundef 0) #6
  %61 = call ptr @ossl_check_const_X509_sk_type(ptr noundef nonnull %40)
  %62 = call ptr @OPENSSL_sk_value(ptr noundef %61, i32 noundef 1) #6
  %63 = call ptr @OCSP_cert_to_id(ptr noundef null, ptr noundef %60, ptr noundef %62) #6
  %.not86 = icmp eq ptr %63, null
  br i1 %.not86, label %64, label %65

64:                                               ; preds = %58
  call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.4, i32 noundef 200, ptr noundef nonnull @__PRETTY_FUNCTION__.ocsp_callback) #7
  unreachable

65:                                               ; preds = %58
  store ptr null, ptr %4, align 8, !tbaa !5
  store ptr null, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %6, align 8, !tbaa !5
  store i32 2, ptr %7, align 4, !tbaa !9
  store i32 -1, ptr %8, align 4, !tbaa !9
  %66 = call i32 @OCSP_resp_find_status(ptr noundef nonnull %37, ptr noundef nonnull %63, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6) #6
  %.not87 = icmp eq i32 %66, 1
  br i1 %.not87, label %68, label %67

67:                                               ; preds = %65
  br i1 %.not77, label %79, label %.sink.split

68:                                               ; preds = %65
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call i32 @OCSP_check_validity(ptr noundef %69, ptr noundef %70, i64 noundef 300, i64 noundef -1) #6
  %.not88 = icmp eq i32 %71, 1
  br i1 %.not88, label %73, label %72

72:                                               ; preds = %68
  br i1 %.not77, label %79, label %.sink.split

73:                                               ; preds = %68
  %74 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %74, label %77 [
    i32 1, label %75
    i32 0, label %76
  ]

75:                                               ; preds = %73
  br i1 %.not77, label %79, label %.sink.split

76:                                               ; preds = %73
  br i1 %.not77, label %79, label %.sink.split

77:                                               ; preds = %73
  br i1 %.not77, label %79, label %.sink.split

.sink.split:                                      ; preds = %77, %76, %75, %72, %67
  %.str.26.sink = phi ptr [ @.str.26, %67 ], [ @.str.27, %72 ], [ @.str.28, %75 ], [ @.str.29, %76 ], [ @.str.30, %77 ]
  %.0.ph.ph = phi i32 [ 1, %67 ], [ 1, %72 ], [ 0, %75 ], [ 1, %76 ], [ 1, %77 ]
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull %.str.26.sink) #6
  br label %79

79:                                               ; preds = %.sink.split, %67, %72, %77, %76, %75
  %.0.ph = phi i32 [ 0, %75 ], [ 1, %76 ], [ 1, %77 ], [ 1, %72 ], [ 1, %67 ], [ %.0.ph.ph, %.sink.split ]
  call void @OCSP_CERTID_free(ptr noundef nonnull %63) #6
  br label %.thread115

.thread115:                                       ; preds = %51, %50, %79
  %.0106 = phi i32 [ %.0.ph, %79 ], [ 1, %51 ], [ 1, %50 ]
  call void @OCSP_BASICRESP_free(ptr noundef nonnull %37) #6
  br label %80

80:                                               ; preds = %26, %34, %.thread115
  %.0106113120 = phi i32 [ %.0106, %.thread115 ], [ 1, %34 ], [ 1, %26 ]
  call void @OCSP_RESPONSE_free(ptr noundef nonnull %18) #6
  br label %.thread123

.thread123:                                       ; preds = %20, %19, %15, %14, %80
  %.0106113121 = phi i32 [ %.0106113120, %80 ], [ 1, %14 ], [ 1, %15 ], [ 1, %19 ], [ 1, %20 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 %.0106113121
}

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

declare ptr @SSL_get_ex_data(ptr noundef, i32 noundef) local_unnamed_addr #4

declare ptr @d2i_OCSP_RESPONSE(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare ptr @BIO_new_fp(ptr noundef, i32 noundef) local_unnamed_addr #4

declare i32 @OCSP_RESPONSE_print(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #4

declare i32 @OCSP_response_status(ptr noundef) local_unnamed_addr #4

declare ptr @OCSP_response_get1_basic(ptr noundef) local_unnamed_addr #4

declare ptr @SSL_get0_verified_chain(ptr noundef) local_unnamed_addr #4

declare ptr @SSL_get_SSL_CTX(ptr noundef) local_unnamed_addr #4

declare ptr @SSL_CTX_get_cert_store(ptr noundef) local_unnamed_addr #4

declare i32 @OCSP_basic_verify(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare i32 @OPENSSL_sk_num(ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ossl_check_const_X509_sk_type(ptr noundef) local_unnamed_addr #5

declare ptr @OPENSSL_sk_value(ptr noundef, i32 noundef) local_unnamed_addr #4

declare ptr @OCSP_cert_to_id(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @OCSP_resp_find_status(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @OCSP_check_validity(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #4

declare void @OCSP_CERTID_free(ptr noundef) local_unnamed_addr #4

declare void @OCSP_BASICRESP_free(ptr noundef) local_unnamed_addr #4

declare void @OCSP_RESPONSE_free(ptr noundef) local_unnamed_addr #4

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 = { 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 #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 = { "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 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { noreturn 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}


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