; 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_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: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_public(ptr noundef, ptr noundef, ptr noundef) #1

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

; 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) #2

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

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

29:                                               ; preds = %8
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  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
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %44, i32 0, i32 1
  %46 = load i64, ptr %45, align 8, !tbaa !14
  store i64 %46, ptr %19, align 8, !tbaa !11
  %47 = load i64, ptr %17, align 8, !tbaa !11
  %48 = load i64, ptr %19, align 8, !tbaa !11
  %49 = sub i64 %48, 11
  %50 = icmp ugt i64 %47, %49
  br i1 %50, label %51, label %54

51:                                               ; preds = %43
  %52 = load i64, ptr %19, align 8, !tbaa !11
  %53 = sub i64 %52, 11
  br label %56

54:                                               ; preds = %43
  %55 = load i64, ptr %17, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %54, %51
  %57 = phi i64 [ %53, %51 ], [ %55, %54 ]
  store i64 %57, ptr %21, align 8, !tbaa !11
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 1
  br i1 %59, label %60, label %66

60:                                               ; preds = %56
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %61, i32 0, i32 15
  %63 = load i32, ptr %62, align 8, !tbaa !17
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %60
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %28, align 4
  br label %272

66:                                               ; preds = %60, %56
  %67 = load i64, ptr %19, align 8, !tbaa !11
  %68 = icmp ult i64 %67, 16
  br i1 %68, label %72, label %69

69:                                               ; preds = %66
  %70 = load i64, ptr %19, align 8, !tbaa !11
  %71 = icmp ugt i64 %70, 1024
  br i1 %71, label %72, label %73

72:                                               ; preds = %69, %66
  store i32 -16512, ptr %9, align 4
  store i32 1, ptr %28, align 4
  br label %272

73:                                               ; preds = %69
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %81

76:                                               ; preds = %73
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load ptr, ptr %15, align 8, !tbaa !5
  %79 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %80 = call i32 @mbedtls_rsa_public(ptr noundef %77, ptr noundef %78, ptr noundef %79)
  br label %88

81:                                               ; preds = %73
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = load ptr, ptr %15, align 8, !tbaa !5
  %86 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %87 = call i32 @mbedtls_rsa_private(ptr noundef %82, ptr noundef %83, ptr noundef %84, ptr noundef %85, ptr noundef %86)
  br label %88

88:                                               ; preds = %81, %76
  %89 = phi i32 [ %80, %76 ], [ %87, %81 ]
  store i32 %89, ptr %18, align 4, !tbaa !9
  %90 = load i32, ptr %18, align 4, !tbaa !9
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %88
  br label %269

93:                                               ; preds = %88
  %94 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %95 = load i8, ptr %94, align 16, !tbaa !13
  %96 = zext i8 %95 to i32
  %97 = load i32, ptr %24, align 4, !tbaa !9
  %98 = or i32 %97, %96
  store i32 %98, ptr %24, align 4, !tbaa !9
  %99 = load i32, ptr %13, align 4, !tbaa !9
  %100 = icmp eq i32 %99, 1
  br i1 %100, label %101, label %148

101:                                              ; preds = %93
  %102 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 1
  %103 = load i8, ptr %102, align 1, !tbaa !13
  %104 = zext i8 %103 to i32
  %105 = xor i32 %104, 2
  %106 = load i32, ptr %24, align 4, !tbaa !9
  %107 = or i32 %106, %105
  store i32 %107, ptr %24, align 4, !tbaa !9
  store i64 2, ptr %20, align 8, !tbaa !11
  br label %108

108:                                              ; preds = %144, %101
  %109 = load i64, ptr %20, align 8, !tbaa !11
  %110 = load i64, ptr %19, align 8, !tbaa !11
  %111 = icmp ult i64 %109, %110
  br i1 %111, label %112, label %147

112:                                              ; preds = %108
  %113 = load i64, ptr %20, align 8, !tbaa !11
  %114 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %113
  %115 = load i8, ptr %114, align 1, !tbaa !13
  %116 = zext i8 %115 to i32
  %117 = load i64, ptr %20, align 8, !tbaa !11
  %118 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %117
  %119 = load i8, ptr %118, align 1, !tbaa !13
  %120 = zext i8 %119 to i32
  %121 = sub nsw i32 0, %120
  %122 = trunc i32 %121 to i8
  %123 = zext i8 %122 to i32
  %124 = or i32 %116, %123
  %125 = ashr i32 %124, 7
  %126 = xor i32 %125, 1
  %127 = load i8, ptr %25, align 1, !tbaa !13
  %128 = zext i8 %127 to i32
  %129 = or i32 %128, %126
  %130 = trunc i32 %129 to i8
  store i8 %130, ptr %25, align 1, !tbaa !13
  %131 = load i8, ptr %25, align 1, !tbaa !13
  %132 = zext i8 %131 to i32
  %133 = load i8, ptr %25, align 1, !tbaa !13
  %134 = zext i8 %133 to i32
  %135 = sub nsw i32 0, %134
  %136 = trunc i32 %135 to i8
  %137 = zext i8 %136 to i32
  %138 = or i32 %132, %137
  %139 = ashr i32 %138, 7
  %140 = xor i32 %139, 1
  %141 = sext i32 %140 to i64
  %142 = load i64, ptr %23, align 8, !tbaa !11
  %143 = add i64 %142, %141
  store i64 %143, ptr %23, align 8, !tbaa !11
  br label %144

144:                                              ; preds = %112
  %145 = load i64, ptr %20, align 8, !tbaa !11
  %146 = add i64 %145, 1
  store i64 %146, ptr %20, align 8, !tbaa !11
  br label %108, !llvm.loop !18

147:                                              ; preds = %108
  br label %189

148:                                              ; preds = %93
  %149 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 1
  %150 = load i8, ptr %149, align 1, !tbaa !13
  %151 = zext i8 %150 to i32
  %152 = xor i32 %151, 1
  %153 = load i32, ptr %24, align 4, !tbaa !9
  %154 = or i32 %153, %152
  store i32 %154, ptr %24, align 4, !tbaa !9
  store i64 2, ptr %20, align 8, !tbaa !11
  br label %155

155:                                              ; preds = %185, %148
  %156 = load i64, ptr %20, align 8, !tbaa !11
  %157 = load i64, ptr %19, align 8, !tbaa !11
  %158 = icmp ult i64 %156, %157
  br i1 %158, label %159, label %188

159:                                              ; preds = %155
  %160 = load i64, ptr %20, align 8, !tbaa !11
  %161 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %160
  %162 = load i8, ptr %161, align 1, !tbaa !13
  %163 = zext i8 %162 to i32
  %164 = call i32 @if_int(i32 noundef %163, i32 noundef 0, i32 noundef 1)
  %165 = load i8, ptr %25, align 1, !tbaa !13
  %166 = zext i8 %165 to i32
  %167 = or i32 %166, %164
  %168 = trunc i32 %167 to i8
  store i8 %168, ptr %25, align 1, !tbaa !13
  %169 = load i8, ptr %25, align 1, !tbaa !13
  %170 = zext i8 %169 to i32
  %171 = call i32 @if_int(i32 noundef %170, i32 noundef 0, i32 noundef 1)
  %172 = zext i32 %171 to i64
  %173 = load i64, ptr %23, align 8, !tbaa !11
  %174 = add i64 %173, %172
  store i64 %174, ptr %23, align 8, !tbaa !11
  %175 = load i8, ptr %25, align 1, !tbaa !13
  %176 = zext i8 %175 to i32
  %177 = load i64, ptr %20, align 8, !tbaa !11
  %178 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %177
  %179 = load i8, ptr %178, align 1, !tbaa !13
  %180 = zext i8 %179 to i32
  %181 = xor i32 %180, 255
  %182 = call i32 @if_int(i32 noundef %176, i32 noundef 0, i32 noundef %181)
  %183 = load i32, ptr %24, align 4, !tbaa !9
  %184 = or i32 %183, %182
  store i32 %184, ptr %24, align 4, !tbaa !9
  br label %185

185:                                              ; preds = %159
  %186 = load i64, ptr %20, align 8, !tbaa !11
  %187 = add i64 %186, 1
  store i64 %187, ptr %20, align 8, !tbaa !11
  br label %155, !llvm.loop !20

188:                                              ; preds = %155
  br label %189

189:                                              ; preds = %188, %147
  %190 = load i8, ptr %25, align 1, !tbaa !13
  %191 = zext i8 %190 to i32
  %192 = call i32 @if_int(i32 noundef %191, i32 noundef 0, i32 noundef 1)
  %193 = load i32, ptr %24, align 4, !tbaa !9
  %194 = or i32 %193, %192
  store i32 %194, ptr %24, align 4, !tbaa !9
  %195 = load i64, ptr %23, align 8, !tbaa !11
  %196 = call i32 @size_greater_than(i64 noundef 8, i64 noundef %195)
  %197 = load i32, ptr %24, align 4, !tbaa !9
  %198 = or i32 %197, %196
  store i32 %198, ptr %24, align 4, !tbaa !9
  %199 = load i32, ptr %24, align 4, !tbaa !9
  %200 = load i64, ptr %21, align 8, !tbaa !11
  %201 = trunc i64 %200 to i32
  %202 = load i64, ptr %19, align 8, !tbaa !11
  %203 = load i64, ptr %23, align 8, !tbaa !11
  %204 = sub i64 %202, %203
  %205 = sub i64 %204, 3
  %206 = trunc i64 %205 to i32
  %207 = call i32 @if_int(i32 noundef %199, i32 noundef %201, i32 noundef %206)
  %208 = zext i32 %207 to i64
  store i64 %208, ptr %26, align 8, !tbaa !11
  %209 = load i64, ptr %26, align 8, !tbaa !11
  %210 = load i64, ptr %21, align 8, !tbaa !11
  %211 = call i32 @size_greater_than(i64 noundef %209, i64 noundef %210)
  store i32 %211, ptr %27, align 4, !tbaa !9
  %212 = load i32, ptr %24, align 4, !tbaa !9
  %213 = load i32, ptr %27, align 4, !tbaa !9
  %214 = call i32 @if_int(i32 noundef %213, i32 noundef 17408, i32 noundef 0)
  %215 = call i32 @if_int(i32 noundef %212, i32 noundef 16640, i32 noundef %214)
  %216 = sub nsw i32 0, %215
  store i32 %216, ptr %18, align 4, !tbaa !9
  %217 = load i32, ptr %24, align 4, !tbaa !9
  %218 = load i32, ptr %27, align 4, !tbaa !9
  %219 = or i32 %217, %218
  %220 = call i32 @all_or_nothing_int(i32 noundef %219)
  store i32 %220, ptr %24, align 4, !tbaa !9
  store i64 11, ptr %20, align 8, !tbaa !11
  br label %221

221:                                              ; preds = %234, %189
  %222 = load i64, ptr %20, align 8, !tbaa !11
  %223 = load i64, ptr %19, align 8, !tbaa !11
  %224 = icmp ult i64 %222, %223
  br i1 %224, label %225, label %237

225:                                              ; preds = %221
  %226 = load i32, ptr %24, align 4, !tbaa !9
  %227 = xor i32 %226, -1
  %228 = load i64, ptr %20, align 8, !tbaa !11
  %229 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %228
  %230 = load i8, ptr %229, align 1, !tbaa !13
  %231 = zext i8 %230 to i32
  %232 = and i32 %231, %227
  %233 = trunc i32 %232 to i8
  store i8 %233, ptr %229, align 1, !tbaa !13
  br label %234

234:                                              ; preds = %225
  %235 = load i64, ptr %20, align 8, !tbaa !11
  %236 = add i64 %235, 1
  store i64 %236, ptr %20, align 8, !tbaa !11
  br label %221, !llvm.loop !21

237:                                              ; preds = %221
  %238 = load i32, ptr %27, align 4, !tbaa !9
  %239 = load i64, ptr %21, align 8, !tbaa !11
  %240 = trunc i64 %239 to i32
  %241 = load i64, ptr %26, align 8, !tbaa !11
  %242 = trunc i64 %241 to i32
  %243 = call i32 @if_int(i32 noundef %238, i32 noundef %240, i32 noundef %242)
  %244 = zext i32 %243 to i64
  store i64 %244, ptr %26, align 8, !tbaa !11
  %245 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %246 = load i64, ptr %19, align 8, !tbaa !11
  %247 = getelementptr inbounds i8, ptr %245, i64 %246
  %248 = load i64, ptr %21, align 8, !tbaa !11
  %249 = sub i64 0, %248
  %250 = getelementptr inbounds i8, ptr %247, i64 %249
  %251 = load i64, ptr %21, align 8, !tbaa !11
  %252 = load i64, ptr %21, align 8, !tbaa !11
  %253 = load i64, ptr %26, align 8, !tbaa !11
  %254 = sub i64 %252, %253
  call void @mem_move_to_left(ptr noundef %250, i64 noundef %251, i64 noundef %254)
  %255 = load i64, ptr %17, align 8, !tbaa !11
  %256 = icmp ne i64 %255, 0
  br i1 %256, label %257, label %266

257:                                              ; preds = %237
  %258 = load ptr, ptr %16, align 8, !tbaa !5
  %259 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  %260 = load i64, ptr %19, align 8, !tbaa !11
  %261 = getelementptr inbounds i8, ptr %259, i64 %260
  %262 = load i64, ptr %21, align 8, !tbaa !11
  %263 = sub i64 0, %262
  %264 = getelementptr inbounds i8, ptr %261, i64 %263
  %265 = load i64, ptr %21, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %258, ptr align 1 %264, i64 %265, i1 false)
  br label %266

266:                                              ; preds = %257, %237
  %267 = load i64, ptr %26, align 8, !tbaa !11
  %268 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 %267, ptr %268, align 8, !tbaa !11
  br label %269

269:                                              ; preds = %266, %92
  %270 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 0
  call void @mbedtls_platform_zeroize(ptr noundef %270, i64 noundef 1024)
  %271 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %271, ptr %9, align 4
  store i32 1, ptr %28, align 4
  br label %272

272:                                              ; preds = %269, %72, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %273 = load i32, ptr %9, align 4
  ret i32 %273
}

; Function Attrs: nounwind uwtable
declare hidden i32 @if_int(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @size_greater_than(i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @all_or_nothing_int(i32 noundef) #1

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

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

!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 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 8}
!15 = !{!"mbedtls_rsa_context", !10, i64 0, !12, i64 8, !16, i64 16, !16, i64 40, !16, i64 64, !16, i64 88, !16, i64 112, !16, i64 136, !16, i64 160, !16, i64 184, !16, i64 208, !16, i64 232, !16, i64 256, !16, i64 280, !16, i64 304, !10, i64 328, !10, i64 332}
!16 = !{!"mbedtls_mpi", !10, i64 0, !12, i64 8, !6, i64 16}
!17 = !{!15, !10, i64 328}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}


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

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

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

; 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) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_rsaes_pkcs1_v15_decrypt(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4, ptr noundef %5, ptr nocapture noundef writeonly %6, i64 noundef %7) local_unnamed_addr #1 {
  %9 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %9) #5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = add i64 %11, -11
  %13 = tail call i64 @llvm.umin.i64(i64 %12, i64 %7)
  %14 = icmp eq i32 %3, 1
  br i1 %14, label %15, label %19

15:                                               ; preds = %8
  %16 = getelementptr inbounds i8, ptr %0, i64 328
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %.not = icmp ne i32 %17, 0
  %18 = add i64 %11, -1025
  %or.cond = icmp ult i64 %18, -1009
  %or.cond90 = select i1 %.not, i1 true, i1 %or.cond
  br i1 %or.cond90, label %134, label %22

19:                                               ; preds = %8
  %.old = add i64 %11, -1025
  %or.cond.old = icmp ult i64 %.old, -1009
  br i1 %or.cond.old, label %134, label %20

20:                                               ; preds = %19
  %21 = icmp eq i32 %3, 0
  br i1 %21, label %.thread91, label %.thread94

22:                                               ; preds = %15
  %23 = call i32 @mbedtls_rsa_private(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %5, ptr noundef nonnull %9)
  %.not88 = icmp eq i32 %23, 0
  br i1 %.not88, label %.lr.ph107.preheader, label %133

.thread94:                                        ; preds = %20
  %24 = call i32 @mbedtls_rsa_private(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %5, ptr noundef nonnull %9)
  %.not8895 = icmp eq i32 %24, 0
  br i1 %.not8895, label %.lr.ph.preheader, label %133

.thread91:                                        ; preds = %20
  %25 = call i32 @mbedtls_rsa_public(ptr noundef nonnull %0, ptr noundef %5, ptr noundef nonnull %9)
  %.not8892 = icmp eq i32 %25, 0
  br i1 %.not8892, label %.lr.ph.preheader, label %133

.lr.ph107.preheader:                              ; preds = %22
  %26 = load i8, ptr %9, align 16, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %9, i64 1
  %28 = load i8, ptr %27, align 1, !tbaa !14
  %29 = xor i8 %28, 2
  %30 = or i8 %29, %26
  %31 = zext i8 %30 to i32
  %xtraiter = and i64 %11, 1
  %32 = icmp eq i64 %11, 3
  br i1 %32, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph107.preheader.new

.lr.ph107.preheader.new:                          ; preds = %.lr.ph107.preheader
  %33 = and i64 %11, 2046
  %34 = add nsw i64 %33, -4
  br label %.lr.ph107

.lr.ph107:                                        ; preds = %.lr.ph107, %.lr.ph107.preheader.new
  %.076106 = phi i8 [ 0, %.lr.ph107.preheader.new ], [ %51, %.lr.ph107 ]
  %.079105 = phi i64 [ 0, %.lr.ph107.preheader.new ], [ %57, %.lr.ph107 ]
  %.083104 = phi i64 [ 2, %.lr.ph107.preheader.new ], [ %58, %.lr.ph107 ]
  %niter = phi i64 [ 0, %.lr.ph107.preheader.new ], [ %niter.next.1, %.lr.ph107 ]
  %35 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %.083104
  %36 = load i8, ptr %35, align 2, !tbaa !14
  %37 = icmp eq i8 %36, 0
  %38 = zext i1 %37 to i8
  %39 = or i8 %.076106, %38
  %40 = add nsw i8 %39, -1
  %41 = xor i8 %.076106, -1
  %42 = and i8 %40, %41
  %43 = lshr i8 %42, 7
  %44 = zext nneg i8 %43 to i64
  %45 = add i64 %.079105, %44
  %46 = or disjoint i64 %.083104, 1
  %47 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !14
  %49 = icmp eq i8 %48, 0
  %50 = zext i1 %49 to i8
  %51 = or i8 %39, %50
  %52 = add nsw i8 %51, -1
  %53 = xor i8 %.076106, -1
  %54 = and i8 %52, %53
  %55 = lshr i8 %54, 7
  %56 = zext nneg i8 %55 to i64
  %57 = add i64 %45, %56
  %58 = add nuw nsw i64 %.083104, 2
  %niter.next.1 = add nuw nsw i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %34
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph107, !llvm.loop !15

.lr.ph.preheader:                                 ; preds = %.thread94, %.thread91
  %59 = load i8, ptr %9, align 16, !tbaa !14
  %60 = getelementptr inbounds i8, ptr %9, i64 1
  %61 = load i8, ptr %60, align 1, !tbaa !14
  %62 = xor i8 %61, 1
  %63 = or i8 %62, %59
  %64 = zext i8 %63 to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.1101 = phi i8 [ %70, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.077100 = phi i32 [ %79, %.lr.ph ], [ %64, %.lr.ph.preheader ]
  %.18099 = phi i64 [ %74, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.18498 = phi i64 [ %80, %.lr.ph ], [ 2, %.lr.ph.preheader ]
  %65 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %.18498
  %66 = load i8, ptr %65, align 1, !tbaa !14
  %67 = zext i8 %66 to i32
  %68 = call i32 @if_int(i32 noundef %67, i32 noundef 0, i32 noundef 1)
  %69 = trunc i32 %68 to i8
  %70 = or i8 %.1101, %69
  %71 = zext i8 %70 to i32
  %72 = call i32 @if_int(i32 noundef %71, i32 noundef 0, i32 noundef 1)
  %73 = zext i32 %72 to i64
  %74 = add i64 %.18099, %73
  %75 = load i8, ptr %65, align 1, !tbaa !14
  %76 = xor i8 %75, -1
  %77 = zext i8 %76 to i32
  %78 = call i32 @if_int(i32 noundef %71, i32 noundef 0, i32 noundef %77)
  %79 = or i32 %78, %.077100
  %80 = add nuw i64 %.18498, 1
  %exitcond.not = icmp eq i64 %80, %11
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !17

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph107, %.lr.ph107.preheader
  %.lcssa141.ph = phi i8 [ poison, %.lr.ph107.preheader ], [ %51, %.lr.ph107 ]
  %.lcssa.ph = phi i64 [ poison, %.lr.ph107.preheader ], [ %57, %.lr.ph107 ]
  %.076106.unr = phi i8 [ 0, %.lr.ph107.preheader ], [ %51, %.lr.ph107 ]
  %.079105.unr = phi i64 [ 0, %.lr.ph107.preheader ], [ %57, %.lr.ph107 ]
  %.083104.unr = phi i64 [ 2, %.lr.ph107.preheader ], [ %58, %.lr.ph107 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph107.epil

.lr.ph107.epil:                                   ; preds = %.loopexit.loopexit.unr-lcssa
  %81 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %.083104.unr
  %82 = load i8, ptr %81, align 1, !tbaa !14
  %83 = icmp eq i8 %82, 0
  %84 = zext i1 %83 to i8
  %85 = or i8 %.076106.unr, %84
  %86 = add nsw i8 %85, -1
  %87 = xor i8 %.076106.unr, -1
  %88 = and i8 %86, %87
  %89 = lshr i8 %88, 7
  %90 = zext nneg i8 %89 to i64
  %91 = add i64 %.079105.unr, %90
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph107.epil, %.loopexit.loopexit.unr-lcssa
  %.281 = phi i64 [ %.lcssa.ph, %.loopexit.loopexit.unr-lcssa ], [ %91, %.lr.ph107.epil ], [ %74, %.lr.ph ]
  %.178 = phi i32 [ %31, %.loopexit.loopexit.unr-lcssa ], [ %31, %.lr.ph107.epil ], [ %79, %.lr.ph ]
  %.2 = phi i8 [ %.lcssa141.ph, %.loopexit.loopexit.unr-lcssa ], [ %85, %.lr.ph107.epil ], [ %70, %.lr.ph ]
  %92 = zext i8 %.2 to i32
  %93 = call i32 @if_int(i32 noundef %92, i32 noundef 0, i32 noundef 1)
  %94 = or i32 %93, %.178
  %95 = call i32 @size_greater_than(i64 noundef 8, i64 noundef %.281)
  %96 = or i32 %94, %95
  %97 = trunc i64 %13 to i32
  %98 = sub i64 %11, %.281
  %99 = trunc i64 %98 to i32
  %100 = add i32 %99, -3
  %101 = call i32 @if_int(i32 noundef %96, i32 noundef %97, i32 noundef %100)
  %102 = zext i32 %101 to i64
  %103 = call i32 @size_greater_than(i64 noundef %102, i64 noundef %13)
  %104 = call i32 @if_int(i32 noundef %103, i32 noundef 17408, i32 noundef 0)
  %105 = call i32 @if_int(i32 noundef %96, i32 noundef 16640, i32 noundef %104)
  %106 = sub nsw i32 0, %105
  %107 = or i32 %103, %96
  %108 = call i32 @all_or_nothing_int(i32 noundef %107)
  %109 = icmp ugt i64 %11, 11
  br i1 %109, label %iter.check, label %._crit_edge

iter.check:                                       ; preds = %.loopexit
  %110 = trunc i32 %108 to i8
  %111 = xor i8 %110, -1
  %112 = add i64 %11, -11
  %min.iters.check = icmp ult i64 %112, 8
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check129 = icmp ult i64 %112, 32
  br i1 %min.iters.check129, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %112, -32
  %broadcast.splatinsert = insertelement <16 x i8> poison, i8 %111, i64 0
  %broadcast.splat = shufflevector <16 x i8> %broadcast.splatinsert, <16 x i8> poison, <16 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 11
  %113 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %offset.idx
  %114 = getelementptr inbounds i8, ptr %113, i64 16
  %wide.load = load <16 x i8>, ptr %113, align 1, !tbaa !14
  %wide.load130 = load <16 x i8>, ptr %114, align 1, !tbaa !14
  %115 = and <16 x i8> %wide.load, %broadcast.splat
  %116 = and <16 x i8> %wide.load130, %broadcast.splat
  store <16 x i8> %115, ptr %113, align 1, !tbaa !14
  store <16 x i8> %116, ptr %114, align 1, !tbaa !14
  %index.next = add nuw i64 %index, 32
  %117 = icmp eq i64 %index.next, %n.vec
  br i1 %117, label %middle.block, label %vector.body, !llvm.loop !18

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %112, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end133 = or disjoint i64 %n.vec, 11
  %n.vec.remaining = and i64 %112, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec132 = and i64 %112, -8
  %ind.end = add i64 %n.vec132, 11
  %broadcast.splatinsert137 = insertelement <8 x i8> poison, i8 %111, i64 0
  %broadcast.splat138 = shufflevector <8 x i8> %broadcast.splatinsert137, <8 x i8> poison, <8 x i32> zeroinitializer
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index134 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next139, %vec.epilog.vector.body ]
  %offset.idx135 = add i64 %index134, 11
  %118 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %offset.idx135
  %wide.load136 = load <8 x i8>, ptr %118, align 1, !tbaa !14
  %119 = and <8 x i8> %wide.load136, %broadcast.splat138
  store <8 x i8> %119, ptr %118, align 1, !tbaa !14
  %index.next139 = add nuw i64 %index134, 8
  %120 = icmp eq i64 %index.next139, %n.vec132
  br i1 %120, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !21

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n140 = icmp eq i64 %112, %n.vec132
  br i1 %cmp.n140, label %._crit_edge, label %vec.epilog.scalar.ph.preheader

vec.epilog.scalar.ph.preheader:                   ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %.285110.ph = phi i64 [ 11, %iter.check ], [ %ind.end133, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  br label %vec.epilog.scalar.ph

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.preheader, %vec.epilog.scalar.ph
  %.285110 = phi i64 [ %124, %vec.epilog.scalar.ph ], [ %.285110.ph, %vec.epilog.scalar.ph.preheader ]
  %121 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 %.285110
  %122 = load i8, ptr %121, align 1, !tbaa !14
  %123 = and i8 %122, %111
  store i8 %123, ptr %121, align 1, !tbaa !14
  %124 = add nuw nsw i64 %.285110, 1
  %exitcond118.not = icmp eq i64 %124, %11
  br i1 %exitcond118.not, label %._crit_edge, label %vec.epilog.scalar.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %vec.epilog.scalar.ph, %middle.block, %vec.epilog.middle.block, %.loopexit
  %125 = call i32 @if_int(i32 noundef %103, i32 noundef %97, i32 noundef %101)
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds i8, ptr %9, i64 %11
  %128 = sub i64 0, %13
  %129 = getelementptr inbounds i8, ptr %127, i64 %128
  %130 = sub i64 %13, %126
  call void @mem_move_to_left(ptr noundef nonnull %129, i64 noundef %13, i64 noundef %130)
  %.not89 = icmp eq i64 %7, 0
  br i1 %.not89, label %132, label %131

131:                                              ; preds = %._crit_edge
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr nonnull align 1 %129, i64 %13, i1 false)
  br label %132

132:                                              ; preds = %131, %._crit_edge
  store i64 %126, ptr %4, align 8, !tbaa !23
  br label %133

133:                                              ; preds = %.thread94, %.thread91, %22, %132
  %.082 = phi i32 [ %23, %22 ], [ %106, %132 ], [ %25, %.thread91 ], [ %24, %.thread94 ]
  call void @mbedtls_platform_zeroize(ptr noundef nonnull %9, i64 noundef 1024) #5
  br label %134

134:                                              ; preds = %19, %15, %133
  %.0 = phi i32 [ %.082, %133 ], [ -16512, %15 ], [ -16512, %19 ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %9) #5
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @if_int(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @size_greater_than(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @all_or_nothing_int(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 8}
!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, !7, i64 328}
!14 = !{!8, !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16, !19, !20}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !16, !19, !20}
!22 = distinct !{!22, !16, !20, !19}
!23 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass