; LLVM IR from ARMmbed/mbed-crypto :: library (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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

declare i64 @mbedtls_mpi_bitlen(ptr noundef) #2

; 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @mbedtls_md_init(ptr noundef) #2

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

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

declare void @mbedtls_md_free(ptr noundef) #2

declare void @mbedtls_platform_zeroize(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_rsassa_pss_sign(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7) #3 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca [64 x i8], align 16
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  %26 = alloca i64, align 8
  %27 = alloca ptr, align 8
  %28 = alloca %struct.mbedtls_md_context_t, align 8
  %29 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store i32 %3, ptr %13, align 4, !tbaa !9
  store i32 %4, ptr %14, align 4, !tbaa !9
  store i32 %5, ptr %15, align 4, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %30 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %30, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.start.p0(i64 8, 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
  store i64 0, ptr %24, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #5
  store i32 -110, ptr %25, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %28) #5
  br label %31

31:                                               ; preds = %8
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %51

45:                                               ; preds = %42
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %46, i32 0, i32 15
  %48 = load i32, ptr %47, align 8, !tbaa !13
  %49 = icmp ne i32 %48, 1
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

51:                                               ; preds = %45, %42
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

55:                                               ; preds = %51
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %56, i32 0, i32 1
  %58 = load i64, ptr %57, align 8, !tbaa !16
  store i64 %58, ptr %18, align 8, !tbaa !11
  %59 = load i32, ptr %14, align 4, !tbaa !9
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %71

61:                                               ; preds = %55
  %62 = load i32, ptr %14, align 4, !tbaa !9
  %63 = call ptr @mbedtls_md_info_from_type(i32 noundef %62)
  store ptr %63, ptr %27, align 8, !tbaa !5
  %64 = load ptr, ptr %27, align 8, !tbaa !5
  %65 = icmp eq ptr %64, null
  br i1 %65, label %66, label %67

66:                                               ; preds = %61
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

67:                                               ; preds = %61
  %68 = load ptr, ptr %27, align 8, !tbaa !5
  %69 = call zeroext i8 @mbedtls_md_get_size(ptr noundef %68)
  %70 = zext i8 %69 to i32
  store i32 %70, ptr %15, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %67, %55
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %72, i32 0, i32 16
  %74 = load i32, ptr %73, align 4, !tbaa !17
  %75 = call ptr @mbedtls_md_info_from_type(i32 noundef %74)
  store ptr %75, ptr %27, align 8, !tbaa !5
  %76 = load ptr, ptr %27, align 8, !tbaa !5
  %77 = icmp eq ptr %76, null
  br i1 %77, label %78, label %79

78:                                               ; preds = %71
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

79:                                               ; preds = %71
  %80 = load ptr, ptr %27, align 8, !tbaa !5
  %81 = call zeroext i8 @mbedtls_md_get_size(ptr noundef %80)
  %82 = zext i8 %81 to i64
  store i64 %82, ptr %23, align 8, !tbaa !11
  %83 = load i64, ptr %23, align 8, !tbaa !11
  %84 = sub i64 %83, 2
  store i64 %84, ptr %22, align 8, !tbaa !11
  %85 = load i64, ptr %18, align 8, !tbaa !11
  %86 = load i64, ptr %23, align 8, !tbaa !11
  %87 = load i64, ptr %22, align 8, !tbaa !11
  %88 = add i64 %86, %87
  %89 = add i64 %88, 2
  %90 = icmp ult i64 %85, %89
  br i1 %90, label %91, label %92

91:                                               ; preds = %79
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

92:                                               ; preds = %79
  %93 = load i64, ptr %18, align 8, !tbaa !11
  %94 = load i64, ptr %23, align 8, !tbaa !11
  %95 = load i64, ptr %23, align 8, !tbaa !11
  %96 = add i64 %94, %95
  %97 = add i64 %96, 2
  %98 = icmp uge i64 %93, %97
  br i1 %98, label %99, label %101

99:                                               ; preds = %92
  %100 = load i64, ptr %23, align 8, !tbaa !11
  store i64 %100, ptr %21, align 8, !tbaa !11
  br label %106

101:                                              ; preds = %92
  %102 = load i64, ptr %18, align 8, !tbaa !11
  %103 = load i64, ptr %23, align 8, !tbaa !11
  %104 = sub i64 %102, %103
  %105 = sub i64 %104, 2
  store i64 %105, ptr %21, align 8, !tbaa !11
  br label %106

106:                                              ; preds = %101, %99
  br label %107

107:                                              ; preds = %106
  %108 = load ptr, ptr %17, align 8, !tbaa !5
  %109 = load i64, ptr %18, align 8, !tbaa !11
  call void @llvm.memset.p0.i64(ptr align 1 %108, i8 0, i64 %109, i1 false)
  %110 = load ptr, ptr %11, align 8, !tbaa !5
  %111 = load ptr, ptr %12, align 8, !tbaa !5
  %112 = getelementptr inbounds [64 x i8], ptr %20, i64 0, i64 0
  %113 = load i64, ptr %21, align 8, !tbaa !11
  %114 = call i32 %110(ptr noundef %111, ptr noundef %112, i64 noundef %113)
  store i32 %114, ptr %25, align 4, !tbaa !9
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %119

116:                                              ; preds = %107
  %117 = load i32, ptr %25, align 4, !tbaa !9
  %118 = add nsw i32 -17536, %117
  store i32 %118, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

119:                                              ; preds = %107
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %120, i32 0, i32 2
  %122 = call i64 @mbedtls_mpi_bitlen(ptr noundef %121)
  %123 = sub i64 %122, 1
  store i64 %123, ptr %26, align 8, !tbaa !11
  %124 = load i64, ptr %18, align 8, !tbaa !11
  %125 = load i64, ptr %23, align 8, !tbaa !11
  %126 = sub i64 %124, %125
  %127 = load i64, ptr %21, align 8, !tbaa !11
  %128 = sub i64 %126, %127
  %129 = sub i64 %128, 2
  %130 = load ptr, ptr %19, align 8, !tbaa !5
  %131 = getelementptr inbounds i8, ptr %130, i64 %129
  store ptr %131, ptr %19, align 8, !tbaa !5
  %132 = load ptr, ptr %19, align 8, !tbaa !5
  %133 = getelementptr inbounds i8, ptr %132, i32 1
  store ptr %133, ptr %19, align 8, !tbaa !5
  store i8 1, ptr %132, align 1, !tbaa !18
  %134 = load ptr, ptr %19, align 8, !tbaa !5
  %135 = getelementptr inbounds [64 x i8], ptr %20, i64 0, i64 0
  %136 = load i64, ptr %21, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %134, ptr align 16 %135, i64 %136, i1 false)
  %137 = load i64, ptr %21, align 8, !tbaa !11
  %138 = load ptr, ptr %19, align 8, !tbaa !5
  %139 = getelementptr inbounds i8, ptr %138, i64 %137
  store ptr %139, ptr %19, align 8, !tbaa !5
  call void @mbedtls_md_init(ptr noundef %28)
  %140 = load ptr, ptr %27, align 8, !tbaa !5
  %141 = call i32 @mbedtls_md_setup(ptr noundef %28, ptr noundef %140, i32 noundef 0)
  store i32 %141, ptr %25, align 4, !tbaa !9
  %142 = icmp ne i32 %141, 0
  br i1 %142, label %143, label %144

143:                                              ; preds = %119
  br label %214

144:                                              ; preds = %119
  %145 = call i32 @mbedtls_md_starts(ptr noundef %28)
  store i32 %145, ptr %25, align 4, !tbaa !9
  %146 = icmp ne i32 %145, 0
  br i1 %146, label %147, label %148

147:                                              ; preds = %144
  br label %214

148:                                              ; preds = %144
  %149 = load ptr, ptr %19, align 8, !tbaa !5
  %150 = call i32 @mbedtls_md_update(ptr noundef %28, ptr noundef %149, i64 noundef 8)
  store i32 %150, ptr %25, align 4, !tbaa !9
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %153

152:                                              ; preds = %148
  br label %214

153:                                              ; preds = %148
  %154 = load ptr, ptr %16, align 8, !tbaa !5
  %155 = load i32, ptr %15, align 4, !tbaa !9
  %156 = zext i32 %155 to i64
  %157 = call i32 @mbedtls_md_update(ptr noundef %28, ptr noundef %154, i64 noundef %156)
  store i32 %157, ptr %25, align 4, !tbaa !9
  %158 = icmp ne i32 %157, 0
  br i1 %158, label %159, label %160

159:                                              ; preds = %153
  br label %214

160:                                              ; preds = %153
  %161 = getelementptr inbounds [64 x i8], ptr %20, i64 0, i64 0
  %162 = load i64, ptr %21, align 8, !tbaa !11
  %163 = call i32 @mbedtls_md_update(ptr noundef %28, ptr noundef %161, i64 noundef %162)
  store i32 %163, ptr %25, align 4, !tbaa !9
  %164 = icmp ne i32 %163, 0
  br i1 %164, label %165, label %166

165:                                              ; preds = %160
  br label %214

166:                                              ; preds = %160
  %167 = load ptr, ptr %19, align 8, !tbaa !5
  %168 = call i32 @mbedtls_md_finish(ptr noundef %28, ptr noundef %167)
  store i32 %168, ptr %25, align 4, !tbaa !9
  %169 = icmp ne i32 %168, 0
  br i1 %169, label %170, label %171

170:                                              ; preds = %166
  br label %214

171:                                              ; preds = %166
  %172 = load i64, ptr %26, align 8, !tbaa !11
  %173 = urem i64 %172, 8
  %174 = icmp eq i64 %173, 0
  br i1 %174, label %175, label %176

175:                                              ; preds = %171
  store i64 1, ptr %24, align 8, !tbaa !11
  br label %176

176:                                              ; preds = %175, %171
  %177 = load ptr, ptr %17, align 8, !tbaa !5
  %178 = load i64, ptr %24, align 8, !tbaa !11
  %179 = getelementptr inbounds i8, ptr %177, i64 %178
  %180 = load i64, ptr %18, align 8, !tbaa !11
  %181 = load i64, ptr %23, align 8, !tbaa !11
  %182 = sub i64 %180, %181
  %183 = sub i64 %182, 1
  %184 = load i64, ptr %24, align 8, !tbaa !11
  %185 = sub i64 %183, %184
  %186 = load ptr, ptr %19, align 8, !tbaa !5
  %187 = load i64, ptr %23, align 8, !tbaa !11
  %188 = call i32 @mgf_mask(ptr noundef %179, i64 noundef %185, ptr noundef %186, i64 noundef %187, ptr noundef %28)
  store i32 %188, ptr %25, align 4, !tbaa !9
  %189 = icmp ne i32 %188, 0
  br i1 %189, label %190, label %191

190:                                              ; preds = %176
  br label %214

191:                                              ; preds = %176
  %192 = load ptr, ptr %10, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %192, i32 0, i32 2
  %194 = call i64 @mbedtls_mpi_bitlen(ptr noundef %193)
  %195 = sub i64 %194, 1
  store i64 %195, ptr %26, align 8, !tbaa !11
  %196 = load i64, ptr %18, align 8, !tbaa !11
  %197 = mul i64 %196, 8
  %198 = load i64, ptr %26, align 8, !tbaa !11
  %199 = sub i64 %197, %198
  %200 = trunc i64 %199 to i32
  %201 = ashr i32 255, %200
  %202 = load ptr, ptr %17, align 8, !tbaa !5
  %203 = getelementptr inbounds i8, ptr %202, i64 0
  %204 = load i8, ptr %203, align 1, !tbaa !18
  %205 = zext i8 %204 to i32
  %206 = and i32 %205, %201
  %207 = trunc i32 %206 to i8
  store i8 %207, ptr %203, align 1, !tbaa !18
  %208 = load i64, ptr %23, align 8, !tbaa !11
  %209 = load ptr, ptr %19, align 8, !tbaa !5
  %210 = getelementptr inbounds i8, ptr %209, i64 %208
  store ptr %210, ptr %19, align 8, !tbaa !5
  %211 = load ptr, ptr %19, align 8, !tbaa !5
  %212 = getelementptr inbounds i8, ptr %211, i32 1
  store ptr %212, ptr %19, align 8, !tbaa !5
  store i8 -68, ptr %211, align 1, !tbaa !18
  %213 = getelementptr inbounds [64 x i8], ptr %20, i64 0, i64 0
  call void @mbedtls_platform_zeroize(ptr noundef %213, i64 noundef 64)
  br label %214

214:                                              ; preds = %191, %190, %170, %165, %159, %152, %147, %143
  call void @mbedtls_md_free(ptr noundef %28)
  %215 = load i32, ptr %25, align 4, !tbaa !9
  %216 = icmp ne i32 %215, 0
  br i1 %216, label %217, label %219

217:                                              ; preds = %214
  %218 = load i32, ptr %25, align 4, !tbaa !9
  store i32 %218, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

219:                                              ; preds = %214
  %220 = load i32, ptr %13, align 4, !tbaa !9
  %221 = icmp eq i32 %220, 0
  br i1 %221, label %222, label %227

222:                                              ; preds = %219
  %223 = load ptr, ptr %10, align 8, !tbaa !5
  %224 = load ptr, ptr %17, align 8, !tbaa !5
  %225 = load ptr, ptr %17, align 8, !tbaa !5
  %226 = call i32 @mbedtls_rsa_public(ptr noundef %223, ptr noundef %224, ptr noundef %225)
  br label %234

227:                                              ; preds = %219
  %228 = load ptr, ptr %10, align 8, !tbaa !5
  %229 = load ptr, ptr %11, align 8, !tbaa !5
  %230 = load ptr, ptr %12, align 8, !tbaa !5
  %231 = load ptr, ptr %17, align 8, !tbaa !5
  %232 = load ptr, ptr %17, align 8, !tbaa !5
  %233 = call i32 @mbedtls_rsa_private(ptr noundef %228, ptr noundef %229, ptr noundef %230, ptr noundef %231, ptr noundef %232)
  br label %234

234:                                              ; preds = %227, %222
  %235 = phi i32 [ %226, %222 ], [ %233, %227 ]
  store i32 %235, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %236

236:                                              ; preds = %234, %217, %116, %91, %78, %66, %54, %50
  call void @llvm.lifetime.end.p0(i64 24, ptr %28) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 4, 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 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %237 = load i32, ptr %9, align 4
  ret i32 %237
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

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

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

%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

; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

declare i64 @mbedtls_mpi_bitlen(ptr noundef) local_unnamed_addr #2

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

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

declare ptr @mbedtls_md_info_from_type(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @mbedtls_md_init(ptr noundef) local_unnamed_addr #2

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

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

declare void @mbedtls_md_free(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_platform_zeroize(ptr noundef, i64 noundef) local_unnamed_addr #2

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

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 328
  %14 = load i32, ptr %13, align 8, !tbaa !5
  %.not = icmp ne i32 %14, 1
  %15 = icmp eq ptr %1, null
  %or.cond = or i1 %15, %.not
  br i1 %or.cond, label %85, label %17

16:                                               ; preds = %8
  %.old = icmp eq ptr %1, null
  br i1 %.old, label %85, label %17

17:                                               ; preds = %12, %16
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %.not87 = icmp eq i32 %4, 0
  br i1 %.not87, label %26, label %20

20:                                               ; preds = %17
  %21 = tail call ptr @mbedtls_md_info_from_type(i32 noundef %4) #5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %85, label %23

23:                                               ; preds = %20
  %24 = tail call zeroext i8 @mbedtls_md_get_size(ptr noundef nonnull %21) #5
  %25 = zext i8 %24 to i32
  br label %26

26:                                               ; preds = %23, %17
  %.072 = phi i32 [ %25, %23 ], [ %5, %17 ]
  %27 = getelementptr inbounds i8, ptr %0, i64 332
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %29 = tail call ptr @mbedtls_md_info_from_type(i32 noundef %28) #5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %85, label %31

31:                                               ; preds = %26
  %32 = tail call zeroext i8 @mbedtls_md_get_size(ptr noundef nonnull %29) #5
  %33 = zext i8 %32 to i64
  %reass.add = shl nuw nsw i64 %33, 1
  %34 = icmp ult i64 %19, %reass.add
  br i1 %34, label %85, label %35

35:                                               ; preds = %31
  %36 = add nuw nsw i64 %reass.add, 2
  %.not88 = icmp ult i64 %19, %36
  %37 = sub i64 %19, %33
  %38 = add nsw i64 %37, -2
  %.073 = select i1 %.not88, i64 %38, i64 %33
  tail call void @llvm.memset.p0.i64(ptr align 1 %7, i8 0, i64 %19, i1 false)
  %39 = call i32 %1(ptr noundef %2, ptr noundef nonnull %9, i64 noundef %.073) #5
  %.not89 = icmp eq i32 %39, 0
  br i1 %.not89, label %42, label %40

40:                                               ; preds = %35
  %41 = add nsw i32 %39, -17536
  br label %85

42:                                               ; preds = %35
  %43 = getelementptr inbounds i8, ptr %0, i64 16
  %44 = call i64 @mbedtls_mpi_bitlen(ptr noundef nonnull %43) #5
  %45 = add i64 %44, 7
  %46 = sub i64 %37, %.073
  %47 = getelementptr i8, ptr %7, i64 %46
  %48 = getelementptr i8, ptr %47, i64 -2
  %49 = getelementptr i8, ptr %47, i64 -1
  store i8 1, ptr %48, align 1, !tbaa !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %49, ptr nonnull align 16 %9, i64 %.073, i1 false)
  %50 = getelementptr inbounds i8, ptr %49, i64 %.073
  call void @mbedtls_md_init(ptr noundef nonnull %10) #5
  %51 = call i32 @mbedtls_md_setup(ptr noundef nonnull %10, ptr noundef nonnull %29, i32 noundef 0) #5
  %.not90 = icmp eq i32 %51, 0
  br i1 %.not90, label %52, label %.thread

52:                                               ; preds = %42
  %53 = call i32 @mbedtls_md_starts(ptr noundef nonnull %10) #5
  %.not91 = icmp eq i32 %53, 0
  br i1 %.not91, label %54, label %.thread

54:                                               ; preds = %52
  %55 = call i32 @mbedtls_md_update(ptr noundef nonnull %10, ptr noundef %50, i64 noundef 8) #5
  %.not92 = icmp eq i32 %55, 0
  br i1 %.not92, label %56, label %.thread

56:                                               ; preds = %54
  %57 = zext i32 %.072 to i64
  %58 = call i32 @mbedtls_md_update(ptr noundef nonnull %10, ptr noundef %6, i64 noundef %57) #5
  %.not93 = icmp eq i32 %58, 0
  br i1 %.not93, label %59, label %.thread

59:                                               ; preds = %56
  %60 = call i32 @mbedtls_md_update(ptr noundef nonnull %10, ptr noundef nonnull %9, i64 noundef %.073) #5
  %.not94 = icmp eq i32 %60, 0
  br i1 %.not94, label %61, label %.thread

61:                                               ; preds = %59
  %62 = call i32 @mbedtls_md_finish(ptr noundef nonnull %10, ptr noundef %50) #5
  %.not95 = icmp eq i32 %62, 0
  br i1 %.not95, label %63, label %.thread

63:                                               ; preds = %61
  %64 = and i64 %45, 7
  %65 = icmp eq i64 %64, 0
  %spec.select = zext i1 %65 to i64
  %66 = getelementptr inbounds i8, ptr %7, i64 %spec.select
  %67 = xor i64 %spec.select, -1
  %68 = add i64 %37, %67
  %69 = call i32 @mgf_mask(ptr noundef %66, i64 noundef %68, ptr noundef %50, i64 noundef %33, ptr noundef nonnull %10)
  %.not96 = icmp eq i32 %69, 0
  br i1 %.not96, label %70, label %.thread

.thread:                                          ; preds = %42, %52, %54, %56, %59, %61, %63
  %.0.ph = phi i32 [ %69, %63 ], [ %62, %61 ], [ %60, %59 ], [ %58, %56 ], [ %55, %54 ], [ %53, %52 ], [ %51, %42 ]
  call void @mbedtls_md_free(ptr noundef nonnull %10) #5
  br label %85

70:                                               ; preds = %63
  %71 = call i64 @mbedtls_mpi_bitlen(ptr noundef nonnull %43) #5
  %72 = shl i64 %19, 3
  %.neg100 = or disjoint i64 %72, 1
  %73 = sub i64 %.neg100, %71
  %74 = trunc i64 %73 to i32
  %75 = lshr i32 255, %74
  %76 = load i8, ptr %7, align 1, !tbaa !15
  %77 = trunc nuw i32 %75 to i8
  %78 = and i8 %76, %77
  store i8 %78, ptr %7, align 1, !tbaa !15
  %79 = getelementptr inbounds i8, ptr %50, i64 %33
  store i8 -68, ptr %79, align 1, !tbaa !15
  call void @mbedtls_platform_zeroize(ptr noundef nonnull %9, i64 noundef 64) #5
  call void @mbedtls_md_free(ptr noundef nonnull %10) #5
  %80 = icmp eq i32 %3, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %70
  %82 = call i32 @mbedtls_rsa_public(ptr noundef nonnull %0, ptr noundef nonnull %7, ptr noundef nonnull %7)
  br label %85

83:                                               ; preds = %70
  %84 = call i32 @mbedtls_rsa_private(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %7, ptr noundef nonnull %7)
  br label %85

85:                                               ; preds = %.thread, %81, %83, %31, %26, %20, %16, %12, %40
  %.071 = phi i32 [ %41, %40 ], [ -16512, %12 ], [ -16512, %16 ], [ -16512, %20 ], [ -16512, %26 ], [ -16512, %31 ], [ %82, %81 ], [ %84, %83 ], [ %.0.ph, %.thread ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %9) #5
  ret i32 %.071
}

declare i32 @mbedtls_md_starts(ptr noundef) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 328}
!6 = !{!"mbedtls_rsa_context", !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 = !{!"mbedtls_mpi", !7, i64 0, !10, i64 8, !12, i64 16}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !7, i64 332}
!15 = !{!8, !8, i64 0}


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