; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (rsa)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.mbedtls_md_context_t = type { ptr, ptr, ptr }
%struct.mbedtls_rsa_context = type { i32, i64, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, i32, i32 }
%struct.mbedtls_mpi = type { i32, i64, ptr }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

declare i64 @mbedtls_mpi_bitlen(ptr noundef) #2

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

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

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

declare ptr @mbedtls_md_info_from_type(i32 noundef) #2

declare zeroext i8 @mbedtls_md_get_size(ptr noundef) #2

declare void @mbedtls_md_init(ptr noundef) #2

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

declare void @mbedtls_md_free(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @mgf_mask(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #3

declare i32 @mbedtls_md_starts(ptr noundef) #2

declare i32 @mbedtls_md_update(ptr noundef, ptr noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_rsassa_pss_verify_ext(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7, i32 noundef %8, ptr noundef %9) #3 {
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i64, align 8
  %24 = alloca ptr, align 8
  %25 = alloca [64 x i8], align 16
  %26 = alloca [8 x i8], align 1
  %27 = alloca i32, align 4
  %28 = alloca i64, align 8
  %29 = alloca i64, align 8
  %30 = alloca ptr, align 8
  %31 = alloca %struct.mbedtls_md_context_t, align 8
  %32 = alloca [1024 x i8], align 16
  %33 = alloca i32, align 4
  store ptr %0, ptr %12, align 8, !tbaa !5
  store ptr %1, ptr %13, align 8, !tbaa !5
  store ptr %2, ptr %14, align 8, !tbaa !5
  store i32 %3, ptr %15, align 4, !tbaa !9
  store i32 %4, ptr %16, align 4, !tbaa !9
  store i32 %5, ptr %17, align 4, !tbaa !9
  store ptr %6, ptr %18, align 8, !tbaa !5
  store i32 %7, ptr %19, align 4, !tbaa !9
  store i32 %8, ptr %20, align 4, !tbaa !9
  store ptr %9, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %25) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %31) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %32) #5
  %34 = load i32, ptr %15, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %42

36:                                               ; preds = %10
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %37, i32 0, i32 15
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = icmp ne i32 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %36
  store i32 -16512, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

42:                                               ; preds = %36, %10
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %43, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !15
  store i64 %45, ptr %23, align 8, !tbaa !16
  %46 = load i64, ptr %23, align 8, !tbaa !16
  %47 = icmp ult i64 %46, 16
  br i1 %47, label %51, label %48

48:                                               ; preds = %42
  %49 = load i64, ptr %23, align 8, !tbaa !16
  %50 = icmp ugt i64 %49, 1024
  br i1 %50, label %51, label %52

51:                                               ; preds = %48, %42
  store i32 -16512, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

52:                                               ; preds = %48
  %53 = load i32, ptr %15, align 4, !tbaa !9
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %60

55:                                               ; preds = %52
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = load ptr, ptr %21, align 8, !tbaa !5
  %58 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %59 = call i32 @mbedtls_rsa_public(ptr noundef %56, ptr noundef %57, ptr noundef %58)
  br label %67

60:                                               ; preds = %52
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = load ptr, ptr %21, align 8, !tbaa !5
  %65 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %66 = call i32 @mbedtls_rsa_private(ptr noundef %61, ptr noundef %62, ptr noundef %63, ptr noundef %64, ptr noundef %65)
  br label %67

67:                                               ; preds = %60, %55
  %68 = phi i32 [ %59, %55 ], [ %66, %60 ]
  store i32 %68, ptr %22, align 4, !tbaa !9
  %69 = load i32, ptr %22, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %67
  %72 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %72, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

73:                                               ; preds = %67
  %74 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  store ptr %74, ptr %24, align 8, !tbaa !5
  %75 = load i64, ptr %23, align 8, !tbaa !16
  %76 = sub i64 %75, 1
  %77 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !17
  %79 = zext i8 %78 to i32
  %80 = icmp ne i32 %79, 188
  br i1 %80, label %81, label %82

81:                                               ; preds = %73
  store i32 -16640, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

82:                                               ; preds = %73
  %83 = load i32, ptr %16, align 4, !tbaa !9
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %95

85:                                               ; preds = %82
  %86 = load i32, ptr %16, align 4, !tbaa !9
  %87 = call ptr @mbedtls_md_info_from_type(i32 noundef %86)
  store ptr %87, ptr %30, align 8, !tbaa !5
  %88 = load ptr, ptr %30, align 8, !tbaa !5
  %89 = icmp eq ptr %88, null
  br i1 %89, label %90, label %91

90:                                               ; preds = %85
  store i32 -16512, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

91:                                               ; preds = %85
  %92 = load ptr, ptr %30, align 8, !tbaa !5
  %93 = call zeroext i8 @mbedtls_md_get_size(ptr noundef %92)
  %94 = zext i8 %93 to i32
  store i32 %94, ptr %17, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %91, %82
  %96 = load i32, ptr %19, align 4, !tbaa !9
  %97 = call ptr @mbedtls_md_info_from_type(i32 noundef %96)
  store ptr %97, ptr %30, align 8, !tbaa !5
  %98 = load ptr, ptr %30, align 8, !tbaa !5
  %99 = icmp eq ptr %98, null
  br i1 %99, label %100, label %101

100:                                              ; preds = %95
  store i32 -16512, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

101:                                              ; preds = %95
  %102 = load ptr, ptr %30, align 8, !tbaa !5
  %103 = call zeroext i8 @mbedtls_md_get_size(ptr noundef %102)
  %104 = zext i8 %103 to i32
  store i32 %104, ptr %27, align 4, !tbaa !9
  %105 = load i64, ptr %23, align 8, !tbaa !16
  %106 = load i32, ptr %27, align 4, !tbaa !9
  %107 = zext i32 %106 to i64
  %108 = sub i64 %105, %107
  %109 = sub i64 %108, 1
  store i64 %109, ptr %28, align 8, !tbaa !16
  %110 = getelementptr inbounds [8 x i8], ptr %26, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %110, i8 0, i64 8, i1 false)
  %111 = load ptr, ptr %12, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %111, i32 0, i32 2
  %113 = call i64 @mbedtls_mpi_bitlen(ptr noundef %112)
  %114 = sub i64 %113, 1
  store i64 %114, ptr %29, align 8, !tbaa !16
  %115 = load i64, ptr %29, align 8, !tbaa !16
  %116 = urem i64 %115, 8
  %117 = icmp eq i64 %116, 0
  br i1 %117, label %118, label %123

118:                                              ; preds = %101
  %119 = load ptr, ptr %24, align 8, !tbaa !5
  %120 = getelementptr inbounds i8, ptr %119, i32 1
  store ptr %120, ptr %24, align 8, !tbaa !5
  %121 = load i64, ptr %23, align 8, !tbaa !16
  %122 = sub i64 %121, 1
  store i64 %122, ptr %23, align 8, !tbaa !16
  br label %123

123:                                              ; preds = %118, %101
  %124 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %125 = load i8, ptr %124, align 16, !tbaa !17
  %126 = zext i8 %125 to i32
  %127 = load i64, ptr %23, align 8, !tbaa !16
  %128 = mul i64 %127, 8
  %129 = sub i64 8, %128
  %130 = load i64, ptr %29, align 8, !tbaa !16
  %131 = add i64 %129, %130
  %132 = trunc i64 %131 to i32
  %133 = ashr i32 %126, %132
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %136

135:                                              ; preds = %123
  store i32 -16512, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

136:                                              ; preds = %123
  call void @mbedtls_md_init(ptr noundef %31)
  %137 = load ptr, ptr %30, align 8, !tbaa !5
  %138 = call i32 @mbedtls_md_setup(ptr noundef %31, ptr noundef %137, i32 noundef 0)
  store i32 %138, ptr %22, align 4, !tbaa !9
  %139 = icmp ne i32 %138, 0
  br i1 %139, label %140, label %142

140:                                              ; preds = %136
  call void @mbedtls_md_free(ptr noundef %31)
  %141 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %141, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

142:                                              ; preds = %136
  %143 = load ptr, ptr %24, align 8, !tbaa !5
  %144 = load i64, ptr %23, align 8, !tbaa !16
  %145 = load i32, ptr %27, align 4, !tbaa !9
  %146 = zext i32 %145 to i64
  %147 = sub i64 %144, %146
  %148 = sub i64 %147, 1
  %149 = load ptr, ptr %24, align 8, !tbaa !5
  %150 = load i64, ptr %23, align 8, !tbaa !16
  %151 = getelementptr inbounds i8, ptr %149, i64 %150
  %152 = load i32, ptr %27, align 4, !tbaa !9
  %153 = zext i32 %152 to i64
  %154 = sub i64 0, %153
  %155 = getelementptr inbounds i8, ptr %151, i64 %154
  %156 = getelementptr inbounds i8, ptr %155, i64 -1
  %157 = load i32, ptr %27, align 4, !tbaa !9
  %158 = zext i32 %157 to i64
  call void @mgf_mask(ptr noundef %143, i64 noundef %148, ptr noundef %156, i64 noundef %158, ptr noundef %31)
  %159 = load i64, ptr %23, align 8, !tbaa !16
  %160 = mul i64 %159, 8
  %161 = load i64, ptr %29, align 8, !tbaa !16
  %162 = sub i64 %160, %161
  %163 = trunc i64 %162 to i32
  %164 = ashr i32 255, %163
  %165 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %166 = load i8, ptr %165, align 16, !tbaa !17
  %167 = zext i8 %166 to i32
  %168 = and i32 %167, %164
  %169 = trunc i32 %168 to i8
  store i8 %169, ptr %165, align 16, !tbaa !17
  br label %170

170:                                              ; preds = %183, %142
  %171 = load ptr, ptr %24, align 8, !tbaa !5
  %172 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %173 = load i64, ptr %23, align 8, !tbaa !16
  %174 = getelementptr inbounds i8, ptr %172, i64 %173
  %175 = icmp ult ptr %171, %174
  br i1 %175, label %176, label %181

176:                                              ; preds = %170
  %177 = load ptr, ptr %24, align 8, !tbaa !5
  %178 = load i8, ptr %177, align 1, !tbaa !17
  %179 = zext i8 %178 to i32
  %180 = icmp eq i32 %179, 0
  br label %181

181:                                              ; preds = %176, %170
  %182 = phi i1 [ false, %170 ], [ %180, %176 ]
  br i1 %182, label %183, label %186

183:                                              ; preds = %181
  %184 = load ptr, ptr %24, align 8, !tbaa !5
  %185 = getelementptr inbounds i8, ptr %184, i32 1
  store ptr %185, ptr %24, align 8, !tbaa !5
  br label %170, !llvm.loop !18

186:                                              ; preds = %181
  %187 = load ptr, ptr %24, align 8, !tbaa !5
  %188 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %189 = load i64, ptr %23, align 8, !tbaa !16
  %190 = getelementptr inbounds i8, ptr %188, i64 %189
  %191 = icmp eq ptr %187, %190
  br i1 %191, label %198, label %192

192:                                              ; preds = %186
  %193 = load ptr, ptr %24, align 8, !tbaa !5
  %194 = getelementptr inbounds i8, ptr %193, i32 1
  store ptr %194, ptr %24, align 8, !tbaa !5
  %195 = load i8, ptr %193, align 1, !tbaa !17
  %196 = zext i8 %195 to i32
  %197 = icmp ne i32 %196, 1
  br i1 %197, label %198, label %199

198:                                              ; preds = %192, %186
  call void @mbedtls_md_free(ptr noundef %31)
  store i32 -16640, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

199:                                              ; preds = %192
  %200 = load ptr, ptr %24, align 8, !tbaa !5
  %201 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %202 = ptrtoint ptr %200 to i64
  %203 = ptrtoint ptr %201 to i64
  %204 = sub i64 %202, %203
  %205 = load i64, ptr %28, align 8, !tbaa !16
  %206 = sub i64 %205, %204
  store i64 %206, ptr %28, align 8, !tbaa !16
  %207 = load i32, ptr %20, align 4, !tbaa !9
  %208 = icmp ne i32 %207, -1
  br i1 %208, label %209, label %215

209:                                              ; preds = %199
  %210 = load i64, ptr %28, align 8, !tbaa !16
  %211 = load i32, ptr %20, align 4, !tbaa !9
  %212 = sext i32 %211 to i64
  %213 = icmp ne i64 %210, %212
  br i1 %213, label %214, label %215

214:                                              ; preds = %209
  call void @mbedtls_md_free(ptr noundef %31)
  store i32 -16640, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

215:                                              ; preds = %209, %199
  %216 = call i32 @mbedtls_md_starts(ptr noundef %31)
  %217 = getelementptr inbounds [8 x i8], ptr %26, i64 0, i64 0
  %218 = call i32 @mbedtls_md_update(ptr noundef %31, ptr noundef %217, i64 noundef 8)
  %219 = load ptr, ptr %18, align 8, !tbaa !5
  %220 = load i32, ptr %17, align 4, !tbaa !9
  %221 = zext i32 %220 to i64
  %222 = call i32 @mbedtls_md_update(ptr noundef %31, ptr noundef %219, i64 noundef %221)
  %223 = load ptr, ptr %24, align 8, !tbaa !5
  %224 = load i64, ptr %28, align 8, !tbaa !16
  %225 = call i32 @mbedtls_md_update(ptr noundef %31, ptr noundef %223, i64 noundef %224)
  %226 = getelementptr inbounds [64 x i8], ptr %25, i64 0, i64 0
  %227 = call i32 @mbedtls_md_finish(ptr noundef %31, ptr noundef %226)
  call void @mbedtls_md_free(ptr noundef %31)
  %228 = load ptr, ptr %24, align 8, !tbaa !5
  %229 = load i64, ptr %28, align 8, !tbaa !16
  %230 = getelementptr inbounds i8, ptr %228, i64 %229
  %231 = getelementptr inbounds [64 x i8], ptr %25, i64 0, i64 0
  %232 = load i32, ptr %27, align 4, !tbaa !9
  %233 = zext i32 %232 to i64
  %234 = call i32 @memcmp(ptr noundef %230, ptr noundef %231, i64 noundef %233) #6
  %235 = icmp eq i32 %234, 0
  br i1 %235, label %236, label %237

236:                                              ; preds = %215
  store i32 0, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

237:                                              ; preds = %215
  store i32 -17280, ptr %11, align 4
  store i32 1, ptr %33, align 4
  br label %238

238:                                              ; preds = %237, %236, %214, %198, %140, %135, %100, %90, %81, %71, %51, %41
  call void @llvm.lifetime.end.p0(i64 1024, ptr %32) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %31) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  %239 = load i32, ptr %11, align 4
  ret i32 %239
}

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind willreturn memory(read) "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 = { nounwind }
attributes #6 = { 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, !10, i64 328}
!12 = !{!"", !10, i64 0, !13, i64 8, !14, i64 16, !14, i64 40, !14, i64 64, !14, i64 88, !14, i64 112, !14, i64 136, !14, i64 160, !14, i64 184, !14, i64 208, !14, i64 232, !14, i64 256, !14, i64 280, !14, i64 304, !10, i64 328, !10, i64 332}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !10, i64 0, !13, i64 8, !6, i64 16}
!15 = !{!12, !13, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.mbedtls_md_context_t = type { ptr, ptr, ptr }

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

declare i64 @mbedtls_mpi_bitlen(ptr noundef) 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: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_public(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare ptr @mbedtls_md_info_from_type(i32 noundef) local_unnamed_addr #1

declare zeroext i8 @mbedtls_md_get_size(ptr noundef) local_unnamed_addr #1

declare void @mbedtls_md_init(ptr noundef) local_unnamed_addr #1

declare i32 @mbedtls_md_setup(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @mbedtls_md_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @mgf_mask(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @mbedtls_md_starts(ptr noundef) local_unnamed_addr #1

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

declare i32 @mbedtls_md_finish(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_rsassa_pss_verify_ext(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7, i32 noundef %8, ptr noundef %9) local_unnamed_addr #2 {
  %11 = alloca [64 x i8], align 16
  %12 = alloca [8 x i8], align 8
  %13 = alloca %struct.mbedtls_md_context_t, align 8
  %14 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %13) #4
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %14) #4
  %15 = icmp eq i32 %3, 1
  br i1 %15, label %16, label %19

16:                                               ; preds = %10
  %17 = getelementptr inbounds i8, ptr %0, i64 328
  %18 = load i32, ptr %17, align 8, !tbaa !5
  %.not = icmp eq i32 %18, 1
  br i1 %.not, label %.thread, label %106

19:                                               ; preds = %10
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = add i64 %21, -1025
  %or.cond = icmp ult i64 %22, -1009
  br i1 %or.cond, label %106, label %26

.thread:                                          ; preds = %16
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = add i64 %24, -1025
  %or.cond81 = icmp ult i64 %25, -1009
  br i1 %or.cond81, label %106, label %.thread82

26:                                               ; preds = %19
  %27 = icmp eq i32 %3, 0
  br i1 %27, label %28, label %.thread82

28:                                               ; preds = %26
  %29 = call i32 @mbedtls_rsa_public(ptr noundef nonnull %0, ptr noundef %9, ptr noundef nonnull %14)
  br label %32

.thread82:                                        ; preds = %.thread, %26
  %30 = phi i64 [ %21, %26 ], [ %24, %.thread ]
  %31 = call i32 @mbedtls_rsa_private(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %9, ptr noundef nonnull %14)
  br label %32

32:                                               ; preds = %.thread82, %28
  %33 = phi i64 [ %21, %28 ], [ %30, %.thread82 ]
  %34 = phi i32 [ %29, %28 ], [ %31, %.thread82 ]
  %.not71 = icmp eq i32 %34, 0
  br i1 %.not71, label %35, label %106

35:                                               ; preds = %32
  %36 = add nsw i64 %33, -1
  %37 = getelementptr inbounds [1024 x i8], ptr %14, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !14
  %.not72 = icmp eq i8 %38, -68
  br i1 %.not72, label %39, label %106

39:                                               ; preds = %35
  %.not73 = icmp eq i32 %4, 0
  br i1 %.not73, label %46, label %40

40:                                               ; preds = %39
  %41 = call ptr @mbedtls_md_info_from_type(i32 noundef %4) #4
  %42 = icmp eq ptr %41, null
  br i1 %42, label %106, label %43

43:                                               ; preds = %40
  %44 = call zeroext i8 @mbedtls_md_get_size(ptr noundef nonnull %41) #4
  %45 = zext i8 %44 to i32
  br label %46

46:                                               ; preds = %43, %39
  %.061 = phi i32 [ %45, %43 ], [ %5, %39 ]
  %47 = call ptr @mbedtls_md_info_from_type(i32 noundef %7) #4
  %48 = icmp eq ptr %47, null
  br i1 %48, label %106, label %49

49:                                               ; preds = %46
  %50 = call zeroext i8 @mbedtls_md_get_size(ptr noundef nonnull %47) #4
  %51 = zext i8 %50 to i64
  %52 = xor i64 %51, -1
  %53 = add nsw i64 %33, %52
  store i64 0, ptr %12, align 8
  %54 = getelementptr inbounds i8, ptr %0, i64 16
  %55 = call i64 @mbedtls_mpi_bitlen(ptr noundef nonnull %54) #4
  %56 = add i64 %55, -1
  %57 = and i64 %56, 7
  %58 = icmp eq i64 %57, 0
  %spec.select = select i1 %58, i64 %36, i64 %33
  %spec.select79.idx = zext i1 %58 to i64
  %spec.select79 = getelementptr inbounds i8, ptr %14, i64 %spec.select79.idx
  %59 = load i8, ptr %14, align 16, !tbaa !14
  %60 = zext i8 %59 to i32
  %61 = shl nuw nsw i64 %spec.select, 3
  %62 = sub i64 %55, %61
  %63 = trunc i64 %62 to i32
  %64 = add i32 %63, 7
  %65 = lshr i32 %60, %64
  %.not74 = icmp eq i32 %65, 0
  br i1 %.not74, label %66, label %106

66:                                               ; preds = %49
  call void @mbedtls_md_init(ptr noundef nonnull %13) #4
  %67 = call i32 @mbedtls_md_setup(ptr noundef nonnull %13, ptr noundef nonnull %47, i32 noundef 0) #4
  %.not75 = icmp eq i32 %67, 0
  br i1 %.not75, label %.lr.ph.preheader, label %68

68:                                               ; preds = %66
  call void @mbedtls_md_free(ptr noundef nonnull %13) #4
  br label %106

.lr.ph.preheader:                                 ; preds = %66
  %69 = add nsw i64 %spec.select, %52
  %70 = getelementptr inbounds i8, ptr %spec.select79, i64 %spec.select
  %71 = sub nsw i64 0, %51
  %72 = getelementptr inbounds i8, ptr %70, i64 %71
  %73 = getelementptr inbounds i8, ptr %72, i64 -1
  call void @mgf_mask(ptr noundef nonnull %spec.select79, i64 noundef %69, ptr noundef nonnull %73, i64 noundef %51, ptr noundef nonnull %13)
  %74 = sub i64 %61, %56
  %75 = trunc i64 %74 to i32
  %76 = lshr i32 255, %75
  %77 = load i8, ptr %14, align 16, !tbaa !14
  %78 = trunc nuw i32 %76 to i8
  %79 = and i8 %77, %78
  store i8 %79, ptr %14, align 16, !tbaa !14
  %80 = getelementptr inbounds i8, ptr %14, i64 %spec.select
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %83
  %.183 = phi ptr [ %84, %83 ], [ %spec.select79, %.lr.ph.preheader ]
  %81 = load i8, ptr %.183, align 1, !tbaa !14
  %82 = icmp eq i8 %81, 0
  br i1 %82, label %83, label %.critedge

83:                                               ; preds = %.lr.ph
  %84 = getelementptr inbounds i8, ptr %.183, i64 1
  %85 = icmp ult ptr %84, %80
  br i1 %85, label %.lr.ph, label %.critedge, !llvm.loop !15

.critedge:                                        ; preds = %.lr.ph, %83
  %.1.lcssa.ph = phi ptr [ %84, %83 ], [ %.183, %.lr.ph ]
  %86 = icmp eq ptr %.1.lcssa.ph, %80
  br i1 %86, label %90, label %87

87:                                               ; preds = %.critedge
  %88 = getelementptr inbounds i8, ptr %.1.lcssa.ph, i64 1
  %89 = load i8, ptr %.1.lcssa.ph, align 1, !tbaa !14
  %.not76 = icmp eq i8 %89, 1
  br i1 %.not76, label %91, label %90

90:                                               ; preds = %87, %.critedge
  call void @mbedtls_md_free(ptr noundef nonnull %13) #4
  br label %106

91:                                               ; preds = %87
  %92 = ptrtoint ptr %88 to i64
  %93 = ptrtoint ptr %14 to i64
  %.neg = sub i64 %93, %92
  %94 = add i64 %53, %.neg
  %.not77 = icmp eq i32 %8, -1
  %95 = sext i32 %8 to i64
  %.not78 = icmp eq i64 %94, %95
  %or.cond80 = select i1 %.not77, i1 true, i1 %.not78
  br i1 %or.cond80, label %97, label %96

96:                                               ; preds = %91
  call void @mbedtls_md_free(ptr noundef nonnull %13) #4
  br label %106

97:                                               ; preds = %91
  %98 = call i32 @mbedtls_md_starts(ptr noundef nonnull %13) #4
  %99 = call i32 @mbedtls_md_update(ptr noundef nonnull %13, ptr noundef nonnull %12, i64 noundef 8) #4
  %100 = zext i32 %.061 to i64
  %101 = call i32 @mbedtls_md_update(ptr noundef nonnull %13, ptr noundef %6, i64 noundef %100) #4
  %102 = call i32 @mbedtls_md_update(ptr noundef nonnull %13, ptr noundef nonnull %88, i64 noundef %94) #4
  %103 = call i32 @mbedtls_md_finish(ptr noundef nonnull %13, ptr noundef nonnull %11) #4
  call void @mbedtls_md_free(ptr noundef nonnull %13) #4
  %104 = getelementptr inbounds i8, ptr %88, i64 %94
  %bcmp = call i32 @bcmp(ptr nonnull %104, ptr nonnull %11, i64 %51)
  %105 = icmp eq i32 %bcmp, 0
  %. = select i1 %105, i32 0, i32 -17280
  br label %106

106:                                              ; preds = %.thread, %97, %49, %46, %40, %35, %32, %19, %16, %96, %90, %68
  %.0 = phi i32 [ %67, %68 ], [ -16640, %90 ], [ -16640, %96 ], [ -16512, %16 ], [ -16512, %19 ], [ %34, %32 ], [ -16640, %35 ], [ -16512, %40 ], [ -16512, %46 ], [ -16512, %49 ], [ %., %97 ], [ -16512, %.thread ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %11) #4
  ret i32 %.0
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind 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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 328}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 40, !11, i64 64, !11, i64 88, !11, i64 112, !11, i64 136, !11, i64 160, !11, i64 184, !11, i64 208, !11, i64 232, !11, i64 256, !11, i64 280, !11, i64 304, !7, i64 328, !7, i64 332}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"", !7, i64 0, !10, i64 8, !12, i64 16}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!8, !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass