; 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_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 }

@.str = external hidden unnamed_addr constant [257 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [257 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_rsa_init(ptr noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_rsa_free(ptr noundef) #0

; 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_check_pubkey(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_check_privkey(ptr noundef) #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_pkcs1_encrypt(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i64 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_pkcs1_decrypt(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_self_test(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca %struct.mbedtls_rsa_context, align 8
  %7 = alloca [24 x i8], align 16
  %8 = alloca [24 x i8], align 16
  %9 = alloca [128 x i8], align 16
  %10 = alloca [20 x i8], align 16
  %11 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 336, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 20, ptr %10) #5
  call void @mbedtls_rsa_init(ptr noundef %6, i32 noundef 0, i32 noundef 0)
  %12 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 1
  store i64 128, ptr %12, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %1
  %14 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 2
  %15 = call i32 @mbedtls_mpi_read_string(ptr noundef %14, i32 noundef 16, ptr noundef @.str)
  store i32 %15, ptr %4, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  br label %188

18:                                               ; preds = %13
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 3
  %23 = call i32 @mbedtls_mpi_read_string(ptr noundef %22, i32 noundef 16, ptr noundef @.str.1)
  store i32 %23, ptr %4, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  br label %188

26:                                               ; preds = %21
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 4
  %31 = call i32 @mbedtls_mpi_read_string(ptr noundef %30, i32 noundef 16, ptr noundef @.str.2)
  store i32 %31, ptr %4, align 4, !tbaa !5
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %29
  br label %188

34:                                               ; preds = %29
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 5
  %39 = call i32 @mbedtls_mpi_read_string(ptr noundef %38, i32 noundef 16, ptr noundef @.str.3)
  store i32 %39, ptr %4, align 4, !tbaa !5
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  br label %188

42:                                               ; preds = %37
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 6
  %47 = call i32 @mbedtls_mpi_read_string(ptr noundef %46, i32 noundef 16, ptr noundef @.str.4)
  store i32 %47, ptr %4, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %45
  br label %188

50:                                               ; preds = %45
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  %54 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 7
  %55 = call i32 @mbedtls_mpi_read_string(ptr noundef %54, i32 noundef 16, ptr noundef @.str.5)
  store i32 %55, ptr %4, align 4, !tbaa !5
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  br label %188

58:                                               ; preds = %53
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  %62 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 8
  %63 = call i32 @mbedtls_mpi_read_string(ptr noundef %62, i32 noundef 16, ptr noundef @.str.6)
  store i32 %63, ptr %4, align 4, !tbaa !5
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  br label %188

66:                                               ; preds = %61
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  %70 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %6, i32 0, i32 9
  %71 = call i32 @mbedtls_mpi_read_string(ptr noundef %70, i32 noundef 16, ptr noundef @.str.7)
  store i32 %71, ptr %4, align 4, !tbaa !5
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %69
  br label %188

74:                                               ; preds = %69
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %3, align 4, !tbaa !5
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %76
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %81

81:                                               ; preds = %79, %76
  %82 = call i32 @mbedtls_rsa_check_pubkey(ptr noundef %6)
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %87, label %84

84:                                               ; preds = %81
  %85 = call i32 @mbedtls_rsa_check_privkey(ptr noundef %6)
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %93

87:                                               ; preds = %84, %81
  %88 = load i32, ptr %3, align 4, !tbaa !5
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %92

90:                                               ; preds = %87
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %92

92:                                               ; preds = %90, %87
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

93:                                               ; preds = %84
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %98

96:                                               ; preds = %93
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  br label %98

98:                                               ; preds = %96, %93
  %99 = getelementptr inbounds [24 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %99, ptr align 1 @.str.11, i64 24, i1 false)
  %100 = getelementptr inbounds [24 x i8], ptr %7, i64 0, i64 0
  %101 = getelementptr inbounds [128 x i8], ptr %9, i64 0, i64 0
  %102 = call i32 @mbedtls_rsa_pkcs1_encrypt(ptr noundef %6, ptr noundef @myrand, ptr noundef null, i32 noundef 0, i64 noundef 24, ptr noundef %100, ptr noundef %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %110

104:                                              ; preds = %98
  %105 = load i32, ptr %3, align 4, !tbaa !5
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %109

107:                                              ; preds = %104
  %108 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %109

109:                                              ; preds = %107, %104
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

110:                                              ; preds = %98
  %111 = load i32, ptr %3, align 4, !tbaa !5
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %115

113:                                              ; preds = %110
  %114 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %115

115:                                              ; preds = %113, %110
  %116 = getelementptr inbounds [128 x i8], ptr %9, i64 0, i64 0
  %117 = getelementptr inbounds [24 x i8], ptr %8, i64 0, i64 0
  %118 = call i32 @mbedtls_rsa_pkcs1_decrypt(ptr noundef %6, ptr noundef @myrand, ptr noundef null, i32 noundef 1, ptr noundef %5, ptr noundef %116, ptr noundef %117, i64 noundef 24)
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %126

120:                                              ; preds = %115
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %125

123:                                              ; preds = %120
  %124 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %125

125:                                              ; preds = %123, %120
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

126:                                              ; preds = %115
  %127 = getelementptr inbounds [24 x i8], ptr %8, i64 0, i64 0
  %128 = getelementptr inbounds [24 x i8], ptr %7, i64 0, i64 0
  %129 = load i64, ptr %5, align 8, !tbaa !14
  %130 = call i32 @memcmp(ptr noundef %127, ptr noundef %128, i64 noundef %129) #6
  %131 = icmp ne i32 %130, 0
  br i1 %131, label %132, label %138

132:                                              ; preds = %126
  %133 = load i32, ptr %3, align 4, !tbaa !5
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %137

135:                                              ; preds = %132
  %136 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %137

137:                                              ; preds = %135, %132
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

138:                                              ; preds = %126
  %139 = load i32, ptr %3, align 4, !tbaa !5
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %143

141:                                              ; preds = %138
  %142 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  br label %143

143:                                              ; preds = %141, %138
  %144 = load i32, ptr %3, align 4, !tbaa !5
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %146, label %148

146:                                              ; preds = %143
  %147 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  br label %148

148:                                              ; preds = %146, %143
  %149 = getelementptr inbounds [24 x i8], ptr %7, i64 0, i64 0
  %150 = getelementptr inbounds [20 x i8], ptr %10, i64 0, i64 0
  call void @mbedtls_sha1(ptr noundef %149, i64 noundef 24, ptr noundef %150)
  %151 = getelementptr inbounds [20 x i8], ptr %10, i64 0, i64 0
  %152 = getelementptr inbounds [128 x i8], ptr %9, i64 0, i64 0
  %153 = call i32 @mbedtls_rsa_pkcs1_sign(ptr noundef %6, ptr noundef @myrand, ptr noundef null, i32 noundef 1, i32 noundef 4, i32 noundef 0, ptr noundef %151, ptr noundef %152)
  %154 = icmp ne i32 %153, 0
  br i1 %154, label %155, label %161

155:                                              ; preds = %148
  %156 = load i32, ptr %3, align 4, !tbaa !5
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %158, label %160

158:                                              ; preds = %155
  %159 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %160

160:                                              ; preds = %158, %155
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

161:                                              ; preds = %148
  %162 = load i32, ptr %3, align 4, !tbaa !5
  %163 = icmp ne i32 %162, 0
  br i1 %163, label %164, label %166

164:                                              ; preds = %161
  %165 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  br label %166

166:                                              ; preds = %164, %161
  %167 = getelementptr inbounds [20 x i8], ptr %10, i64 0, i64 0
  %168 = getelementptr inbounds [128 x i8], ptr %9, i64 0, i64 0
  %169 = call i32 @mbedtls_rsa_pkcs1_verify(ptr noundef %6, ptr noundef null, ptr noundef null, i32 noundef 0, i32 noundef 4, i32 noundef 0, ptr noundef %167, ptr noundef %168)
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %171, label %177

171:                                              ; preds = %166
  %172 = load i32, ptr %3, align 4, !tbaa !5
  %173 = icmp ne i32 %172, 0
  br i1 %173, label %174, label %176

174:                                              ; preds = %171
  %175 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %176

176:                                              ; preds = %174, %171
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

177:                                              ; preds = %166
  %178 = load i32, ptr %3, align 4, !tbaa !5
  %179 = icmp ne i32 %178, 0
  br i1 %179, label %180, label %182

180:                                              ; preds = %177
  %181 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  br label %182

182:                                              ; preds = %180, %177
  %183 = load i32, ptr %3, align 4, !tbaa !5
  %184 = icmp ne i32 %183, 0
  br i1 %184, label %185, label %187

185:                                              ; preds = %182
  %186 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  br label %187

187:                                              ; preds = %185, %182
  br label %188

188:                                              ; preds = %187, %73, %65, %57, %49, %41, %33, %25, %17
  call void @mbedtls_rsa_free(ptr noundef %6)
  %189 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %189, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %190

190:                                              ; preds = %188, %176, %160, %137, %125, %109, %92
  call void @llvm.lifetime.end.p0(i64 20, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 336, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %191 = load i32, ptr %2, align 4
  ret i32 %191
}

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

declare i32 @printf(ptr noundef, ...) #4

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

declare void @mbedtls_sha1(ptr noundef, i64 noundef, ptr noundef) #4

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"", !6, i64 0, !11, i64 8, !12, i64 16, !12, i64 40, !12, i64 64, !12, i64 88, !12, i64 112, !12, i64 136, !12, i64 160, !12, i64 184, !12, i64 208, !12, i64 232, !12, i64 256, !12, i64 280, !12, i64 304, !6, i64 328, !6, i64 332}
!11 = !{!"long", !7, i64 0}
!12 = !{!"", !6, i64 0, !11, i64 8, !13, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!11, !11, 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_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 }

@.str = external hidden unnamed_addr constant [257 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [257 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_rsa_init(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_rsa_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress 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_check_pubkey(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_check_privkey(ptr noundef) local_unnamed_addr #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_pkcs1_encrypt(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_rsa_pkcs1_decrypt(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_self_test(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca i64, align 8
  %3 = alloca %struct.mbedtls_rsa_context, align 8
  %4 = alloca [24 x i8], align 16
  %5 = alloca [24 x i8], align 16
  %6 = alloca [128 x i8], align 16
  %7 = alloca [20 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 336, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %7) #6
  call void @mbedtls_rsa_init(ptr noundef nonnull %3, i32 noundef 0, i32 noundef 0)
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  store i64 128, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %3, i64 16
  %10 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %9, i32 noundef 16, ptr noundef nonnull @.str) #6
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %.critedge41

11:                                               ; preds = %1
  %12 = getelementptr inbounds i8, ptr %3, i64 40
  %13 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %12, i32 noundef 16, ptr noundef nonnull @.str.1) #6
  %.not25 = icmp eq i32 %13, 0
  br i1 %.not25, label %14, label %.critedge41

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %3, i64 64
  %16 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %15, i32 noundef 16, ptr noundef nonnull @.str.2) #6
  %.not26 = icmp eq i32 %16, 0
  br i1 %.not26, label %17, label %.critedge41

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %3, i64 88
  %19 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %18, i32 noundef 16, ptr noundef nonnull @.str.3) #6
  %.not27 = icmp eq i32 %19, 0
  br i1 %.not27, label %20, label %.critedge41

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %3, i64 112
  %22 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %21, i32 noundef 16, ptr noundef nonnull @.str.4) #6
  %.not28 = icmp eq i32 %22, 0
  br i1 %.not28, label %23, label %.critedge41

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %3, i64 136
  %25 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %24, i32 noundef 16, ptr noundef nonnull @.str.5) #6
  %.not29 = icmp eq i32 %25, 0
  br i1 %.not29, label %26, label %.critedge41

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %3, i64 160
  %28 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %27, i32 noundef 16, ptr noundef nonnull @.str.6) #6
  %.not30 = icmp eq i32 %28, 0
  br i1 %.not30, label %29, label %.critedge41

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %3, i64 184
  %31 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %30, i32 noundef 16, ptr noundef nonnull @.str.7) #6
  %.not31 = icmp eq i32 %31, 0
  br i1 %.not31, label %32, label %.critedge41

32:                                               ; preds = %29
  %.not32 = icmp eq i32 %0, 0
  br i1 %.not32, label %35, label %33

33:                                               ; preds = %32
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %35

35:                                               ; preds = %33, %32
  %36 = call i32 @mbedtls_rsa_check_pubkey(ptr noundef nonnull %3)
  %.not33 = icmp eq i32 %36, 0
  br i1 %.not33, label %37, label %39

37:                                               ; preds = %35
  %38 = call i32 @mbedtls_rsa_check_privkey(ptr noundef nonnull %3)
  %.not34 = icmp eq i32 %38, 0
  br i1 %.not34, label %42, label %39

39:                                               ; preds = %37, %35
  br i1 %.not32, label %79, label %40

40:                                               ; preds = %39
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %79

42:                                               ; preds = %37
  br i1 %.not32, label %45, label %43

43:                                               ; preds = %42
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %45

45:                                               ; preds = %43, %42
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %4, ptr noundef nonnull align 1 dereferenceable(24) @.str.11, i64 24, i1 false)
  %46 = call i32 @mbedtls_rsa_pkcs1_encrypt(ptr noundef nonnull %3, ptr noundef nonnull @myrand, ptr noundef null, i32 noundef 0, i64 noundef 24, ptr noundef nonnull %4, ptr noundef nonnull %6)
  %.not35 = icmp eq i32 %46, 0
  br i1 %.not35, label %50, label %47

47:                                               ; preds = %45
  br i1 %.not32, label %79, label %48

48:                                               ; preds = %47
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %79

50:                                               ; preds = %45
  br i1 %.not32, label %51, label %.thread

51:                                               ; preds = %50
  %52 = call i32 @mbedtls_rsa_pkcs1_decrypt(ptr noundef nonnull %3, ptr noundef nonnull @myrand, ptr noundef null, i32 noundef 1, ptr noundef nonnull %2, ptr noundef nonnull %6, ptr noundef nonnull %5, i64 noundef 24)
  %.not36 = icmp eq i32 %52, 0
  br i1 %.not36, label %57, label %79

.thread:                                          ; preds = %50
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %54 = call i32 @mbedtls_rsa_pkcs1_decrypt(ptr noundef nonnull %3, ptr noundef nonnull @myrand, ptr noundef null, i32 noundef 1, ptr noundef nonnull %2, ptr noundef nonnull %6, ptr noundef nonnull %5, i64 noundef 24)
  %.not3642 = icmp eq i32 %54, 0
  br i1 %.not3642, label %.thread44, label %55

55:                                               ; preds = %.thread
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %79

57:                                               ; preds = %51
  %58 = load i64, ptr %2, align 8, !tbaa !13
  %bcmp = call i32 @bcmp(ptr nonnull %5, ptr nonnull %4, i64 %58)
  %.not37 = icmp eq i32 %bcmp, 0
  br i1 %.not37, label %.critedge, label %79

.thread44:                                        ; preds = %.thread
  %59 = load i64, ptr %2, align 8, !tbaa !13
  %bcmp45 = call i32 @bcmp(ptr nonnull %5, ptr nonnull %4, i64 %59)
  %.not3746 = icmp eq i32 %bcmp45, 0
  br i1 %.not3746, label %62, label %60

60:                                               ; preds = %.thread44
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %79

62:                                               ; preds = %.thread44
  %63 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  br label %.critedge

.critedge:                                        ; preds = %57, %62
  call void @mbedtls_sha1(ptr noundef nonnull %4, i64 noundef 24, ptr noundef nonnull %7) #6
  %65 = call i32 @mbedtls_rsa_pkcs1_sign(ptr noundef nonnull %3, ptr noundef nonnull @myrand, ptr noundef null, i32 noundef 1, i32 noundef 4, i32 noundef 0, ptr noundef nonnull %7, ptr noundef nonnull %6)
  %.not38 = icmp eq i32 %65, 0
  br i1 %.not38, label %69, label %66

66:                                               ; preds = %.critedge
  br i1 %.not32, label %79, label %67

67:                                               ; preds = %66
  %68 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %79

69:                                               ; preds = %.critedge
  br i1 %.not32, label %70, label %.thread49

70:                                               ; preds = %69
  %71 = call i32 @mbedtls_rsa_pkcs1_verify(ptr noundef nonnull %3, ptr noundef null, ptr noundef null, i32 noundef 0, i32 noundef 4, i32 noundef 0, ptr noundef nonnull %7, ptr noundef nonnull %6)
  %.not39 = icmp eq i32 %71, 0
  br i1 %.not39, label %.critedge41, label %79

.thread49:                                        ; preds = %69
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  %73 = call i32 @mbedtls_rsa_pkcs1_verify(ptr noundef nonnull %3, ptr noundef null, ptr noundef null, i32 noundef 0, i32 noundef 4, i32 noundef 0, ptr noundef nonnull %7, ptr noundef nonnull %6)
  %.not3950 = icmp eq i32 %73, 0
  br i1 %.not3950, label %76, label %74

74:                                               ; preds = %.thread49
  %75 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %79

76:                                               ; preds = %.thread49
  %77 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %78 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  br label %.critedge41

.critedge41:                                      ; preds = %70, %76, %29, %26, %23, %20, %17, %14, %11, %1
  %.0 = phi i32 [ %10, %1 ], [ %13, %11 ], [ %16, %14 ], [ %19, %17 ], [ %22, %20 ], [ %25, %23 ], [ %28, %26 ], [ %31, %29 ], [ 0, %76 ], [ 0, %70 ]
  call void @mbedtls_rsa_free(ptr noundef nonnull %3)
  br label %79

79:                                               ; preds = %70, %57, %51, %74, %66, %67, %60, %55, %47, %48, %39, %40, %.critedge41
  %.016 = phi i32 [ %.0, %.critedge41 ], [ 1, %40 ], [ 1, %39 ], [ 1, %48 ], [ 1, %47 ], [ 1, %55 ], [ 1, %60 ], [ 1, %67 ], [ 1, %66 ], [ 1, %74 ], [ 1, %51 ], [ 1, %57 ], [ 1, %70 ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 336, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  ret i32 %.016
}

declare i32 @mbedtls_mpi_read_string(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

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

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

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


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