; 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_mpi = type { i32, i64, 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 }

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

declare void @mbedtls_mpi_init(ptr noundef) #1

declare i32 @mbedtls_mpi_cmp_mpi(ptr noundef, ptr noundef) #1

declare i32 @mbedtls_mpi_mul_mpi(ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @mbedtls_mpi_sub_int(ptr noundef, ptr noundef, i64 noundef) #1

declare i32 @mbedtls_mpi_gcd(ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @mbedtls_mpi_cmp_int(ptr noundef, i64 noundef) #1

declare i32 @mbedtls_mpi_inv_mod(ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @mbedtls_mpi_mod_mpi(ptr noundef, ptr noundef, ptr noundef) #1

declare void @mbedtls_mpi_free(ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_check_privkey(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.mbedtls_mpi, align 8
  %6 = alloca %struct.mbedtls_mpi, align 8
  %7 = alloca %struct.mbedtls_mpi, align 8
  %8 = alloca %struct.mbedtls_mpi, align 8
  %9 = alloca %struct.mbedtls_mpi, align 8
  %10 = alloca %struct.mbedtls_mpi, align 8
  %11 = alloca %struct.mbedtls_mpi, align 8
  %12 = alloca %struct.mbedtls_mpi, align 8
  %13 = alloca %struct.mbedtls_mpi, align 8
  %14 = alloca %struct.mbedtls_mpi, align 8
  %15 = alloca %struct.mbedtls_mpi, align 8
  %16 = alloca %struct.mbedtls_mpi, align 8
  %17 = alloca %struct.mbedtls_mpi, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #3
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 @mbedtls_rsa_check_pubkey(ptr noundef %19)
  store i32 %20, ptr %4, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %1
  %23 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %23, ptr %2, align 4
  store i32 1, ptr %18, align 4
  br label %192

24:                                               ; preds = %1
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %25, i32 0, i32 5
  %27 = getelementptr inbounds %struct.mbedtls_mpi, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %42

30:                                               ; preds = %24
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %31, i32 0, i32 6
  %33 = getelementptr inbounds %struct.mbedtls_mpi, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %42

36:                                               ; preds = %30
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %37, i32 0, i32 4
  %39 = getelementptr inbounds %struct.mbedtls_mpi, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = icmp ne ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %36, %30, %24
  store i32 -16896, ptr %2, align 4
  store i32 1, ptr %18, align 4
  br label %192

43:                                               ; preds = %36
  call void @mbedtls_mpi_init(ptr noundef %5)
  call void @mbedtls_mpi_init(ptr noundef %6)
  call void @mbedtls_mpi_init(ptr noundef %7)
  call void @mbedtls_mpi_init(ptr noundef %8)
  call void @mbedtls_mpi_init(ptr noundef %9)
  call void @mbedtls_mpi_init(ptr noundef %10)
  call void @mbedtls_mpi_init(ptr noundef %11)
  call void @mbedtls_mpi_init(ptr noundef %12)
  call void @mbedtls_mpi_init(ptr noundef %13)
  call void @mbedtls_mpi_init(ptr noundef %14)
  call void @mbedtls_mpi_init(ptr noundef %15)
  call void @mbedtls_mpi_init(ptr noundef %16)
  call void @mbedtls_mpi_init(ptr noundef %17)
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %45, i32 0, i32 5
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %47, i32 0, i32 6
  %49 = call i32 @mbedtls_mpi_mul_mpi(ptr noundef %5, ptr noundef %46, ptr noundef %48)
  store i32 %49, ptr %4, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %44
  br label %180

52:                                               ; preds = %44
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %56, i32 0, i32 4
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %58, i32 0, i32 3
  %60 = call i32 @mbedtls_mpi_mul_mpi(ptr noundef %6, ptr noundef %57, ptr noundef %59)
  store i32 %60, ptr %4, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %55
  br label %180

63:                                               ; preds = %55
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %67, i32 0, i32 5
  %69 = call i32 @mbedtls_mpi_sub_int(ptr noundef %7, ptr noundef %68, i64 noundef 1)
  store i32 %69, ptr %4, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %66
  br label %180

72:                                               ; preds = %66
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %76, i32 0, i32 6
  %78 = call i32 @mbedtls_mpi_sub_int(ptr noundef %8, ptr noundef %77, i64 noundef 1)
  store i32 %78, ptr %4, align 4, !tbaa !9
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %81

80:                                               ; preds = %75
  br label %180

81:                                               ; preds = %75
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  %85 = call i32 @mbedtls_mpi_mul_mpi(ptr noundef %9, ptr noundef %7, ptr noundef %8)
  store i32 %85, ptr %4, align 4, !tbaa !9
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %88

87:                                               ; preds = %84
  br label %180

88:                                               ; preds = %84
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %92, i32 0, i32 3
  %94 = call i32 @mbedtls_mpi_gcd(ptr noundef %11, ptr noundef %93, ptr noundef %9)
  store i32 %94, ptr %4, align 4, !tbaa !9
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %97

96:                                               ; preds = %91
  br label %180

97:                                               ; preds = %91
  br label %98

98:                                               ; preds = %97
  br label %99

99:                                               ; preds = %98
  br label %100

100:                                              ; preds = %99
  %101 = call i32 @mbedtls_mpi_gcd(ptr noundef %12, ptr noundef %7, ptr noundef %8)
  store i32 %101, ptr %4, align 4, !tbaa !9
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %104

103:                                              ; preds = %100
  br label %180

104:                                              ; preds = %100
  br label %105

105:                                              ; preds = %104
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106
  %108 = call i32 @mbedtls_mpi_div_mpi(ptr noundef %13, ptr noundef %14, ptr noundef %9, ptr noundef %12)
  store i32 %108, ptr %4, align 4, !tbaa !9
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %111

110:                                              ; preds = %107
  br label %180

111:                                              ; preds = %107
  br label %112

112:                                              ; preds = %111
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113
  %115 = call i32 @mbedtls_mpi_mod_mpi(ptr noundef %10, ptr noundef %6, ptr noundef %13)
  store i32 %115, ptr %4, align 4, !tbaa !9
  %116 = icmp ne i32 %115, 0
  br i1 %116, label %117, label %118

117:                                              ; preds = %114
  br label %180

118:                                              ; preds = %114
  br label %119

119:                                              ; preds = %118
  br label %120

120:                                              ; preds = %119
  br label %121

121:                                              ; preds = %120
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %122, i32 0, i32 4
  %124 = call i32 @mbedtls_mpi_mod_mpi(ptr noundef %15, ptr noundef %123, ptr noundef %7)
  store i32 %124, ptr %4, align 4, !tbaa !9
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %127

126:                                              ; preds = %121
  br label %180

127:                                              ; preds = %121
  br label %128

128:                                              ; preds = %127
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %131, i32 0, i32 4
  %133 = call i32 @mbedtls_mpi_mod_mpi(ptr noundef %16, ptr noundef %132, ptr noundef %8)
  store i32 %133, ptr %4, align 4, !tbaa !9
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %136

135:                                              ; preds = %130
  br label %180

136:                                              ; preds = %130
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137
  br label %139

139:                                              ; preds = %138
  %140 = load ptr, ptr %3, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %140, i32 0, i32 6
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %142, i32 0, i32 5
  %144 = call i32 @mbedtls_mpi_inv_mod(ptr noundef %17, ptr noundef %141, ptr noundef %143)
  store i32 %144, ptr %4, align 4, !tbaa !9
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %146, label %147

146:                                              ; preds = %139
  br label %180

147:                                              ; preds = %139
  br label %148

148:                                              ; preds = %147
  br label %149

149:                                              ; preds = %148
  %150 = load ptr, ptr %3, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %150, i32 0, i32 2
  %152 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef %5, ptr noundef %151)
  %153 = icmp ne i32 %152, 0
  br i1 %153, label %178, label %154

154:                                              ; preds = %149
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %155, i32 0, i32 7
  %157 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef %15, ptr noundef %156)
  %158 = icmp ne i32 %157, 0
  br i1 %158, label %178, label %159

159:                                              ; preds = %154
  %160 = load ptr, ptr %3, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %160, i32 0, i32 8
  %162 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef %16, ptr noundef %161)
  %163 = icmp ne i32 %162, 0
  br i1 %163, label %178, label %164

164:                                              ; preds = %159
  %165 = load ptr, ptr %3, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %165, i32 0, i32 9
  %167 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef %17, ptr noundef %166)
  %168 = icmp ne i32 %167, 0
  br i1 %168, label %178, label %169

169:                                              ; preds = %164
  %170 = call i32 @mbedtls_mpi_cmp_int(ptr noundef %14, i64 noundef 0)
  %171 = icmp ne i32 %170, 0
  br i1 %171, label %178, label %172

172:                                              ; preds = %169
  %173 = call i32 @mbedtls_mpi_cmp_int(ptr noundef %10, i64 noundef 1)
  %174 = icmp ne i32 %173, 0
  br i1 %174, label %178, label %175

175:                                              ; preds = %172
  %176 = call i32 @mbedtls_mpi_cmp_int(ptr noundef %11, i64 noundef 1)
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %179

178:                                              ; preds = %175, %172, %169, %164, %159, %154, %149
  store i32 -16896, ptr %4, align 4, !tbaa !9
  br label %179

179:                                              ; preds = %178, %175
  br label %180

180:                                              ; preds = %179, %146, %135, %126, %117, %110, %103, %96, %87, %80, %71, %62, %51
  call void @mbedtls_mpi_free(ptr noundef %5)
  call void @mbedtls_mpi_free(ptr noundef %6)
  call void @mbedtls_mpi_free(ptr noundef %7)
  call void @mbedtls_mpi_free(ptr noundef %8)
  call void @mbedtls_mpi_free(ptr noundef %9)
  call void @mbedtls_mpi_free(ptr noundef %10)
  call void @mbedtls_mpi_free(ptr noundef %11)
  call void @mbedtls_mpi_free(ptr noundef %12)
  call void @mbedtls_mpi_free(ptr noundef %13)
  call void @mbedtls_mpi_free(ptr noundef %14)
  call void @mbedtls_mpi_free(ptr noundef %15)
  call void @mbedtls_mpi_free(ptr noundef %16)
  call void @mbedtls_mpi_free(ptr noundef %17)
  %181 = load i32, ptr %4, align 4, !tbaa !9
  %182 = icmp eq i32 %181, -16896
  br i1 %182, label %183, label %185

183:                                              ; preds = %180
  %184 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %184, ptr %2, align 4
  store i32 1, ptr %18, align 4
  br label %192

185:                                              ; preds = %180
  %186 = load i32, ptr %4, align 4, !tbaa !9
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %191

188:                                              ; preds = %185
  %189 = load i32, ptr %4, align 4, !tbaa !9
  %190 = add nsw i32 -16896, %189
  store i32 %190, ptr %2, align 4
  store i32 1, ptr %18, align 4
  br label %192

191:                                              ; preds = %185
  store i32 0, ptr %2, align 4
  store i32 1, ptr %18, align 4
  br label %192

192:                                              ; preds = %191, %188, %183, %42, %22
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %193 = load i32, ptr %2, align 4
  ret i32 %193
}

declare i32 @mbedtls_mpi_div_mpi(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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


; 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_mpi = type { i32, i64, ptr }

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

declare void @mbedtls_mpi_init(ptr noundef) local_unnamed_addr #1

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

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

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

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

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

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

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

declare void @mbedtls_mpi_free(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_rsa_check_privkey(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.mbedtls_mpi, align 8
  %3 = alloca %struct.mbedtls_mpi, align 8
  %4 = alloca %struct.mbedtls_mpi, align 8
  %5 = alloca %struct.mbedtls_mpi, align 8
  %6 = alloca %struct.mbedtls_mpi, align 8
  %7 = alloca %struct.mbedtls_mpi, align 8
  %8 = alloca %struct.mbedtls_mpi, align 8
  %9 = alloca %struct.mbedtls_mpi, align 8
  %10 = alloca %struct.mbedtls_mpi, align 8
  %11 = alloca %struct.mbedtls_mpi, align 8
  %12 = alloca %struct.mbedtls_mpi, align 8
  %13 = alloca %struct.mbedtls_mpi, align 8
  %14 = alloca %struct.mbedtls_mpi, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %12) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %13) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %14) #3
  %15 = tail call i32 @mbedtls_rsa_check_pubkey(ptr noundef %0)
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %16, label %75

16:                                               ; preds = %1
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  %18 = getelementptr inbounds i8, ptr %0, i64 104
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %.not38 = icmp eq ptr %19, null
  br i1 %.not38, label %75, label %20

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %0, i64 112
  %22 = getelementptr inbounds i8, ptr %0, i64 128
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %.not39 = icmp eq ptr %23, null
  br i1 %.not39, label %75, label %24

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 64
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %.not40 = icmp eq ptr %27, null
  br i1 %.not40, label %75, label %28

28:                                               ; preds = %24
  call void @mbedtls_mpi_init(ptr noundef nonnull %2) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %3) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %4) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %5) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %6) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %7) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %8) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %9) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %10) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %11) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %12) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %13) #3
  call void @mbedtls_mpi_init(ptr noundef nonnull %14) #3
  %29 = call i32 @mbedtls_mpi_mul_mpi(ptr noundef nonnull %2, ptr noundef nonnull %17, ptr noundef nonnull %21) #3
  %.not41 = icmp eq i32 %29, 0
  br i1 %.not41, label %30, label %72

30:                                               ; preds = %28
  %31 = getelementptr inbounds i8, ptr %0, i64 40
  %32 = call i32 @mbedtls_mpi_mul_mpi(ptr noundef nonnull %3, ptr noundef nonnull %25, ptr noundef nonnull %31) #3
  %.not42 = icmp eq i32 %32, 0
  br i1 %.not42, label %33, label %72

33:                                               ; preds = %30
  %34 = call i32 @mbedtls_mpi_sub_int(ptr noundef nonnull %4, ptr noundef nonnull %17, i64 noundef 1) #3
  %.not43 = icmp eq i32 %34, 0
  br i1 %.not43, label %35, label %72

35:                                               ; preds = %33
  %36 = call i32 @mbedtls_mpi_sub_int(ptr noundef nonnull %5, ptr noundef nonnull %21, i64 noundef 1) #3
  %.not44 = icmp eq i32 %36, 0
  br i1 %.not44, label %37, label %72

37:                                               ; preds = %35
  %38 = call i32 @mbedtls_mpi_mul_mpi(ptr noundef nonnull %6, ptr noundef nonnull %4, ptr noundef nonnull %5) #3
  %.not45 = icmp eq i32 %38, 0
  br i1 %.not45, label %39, label %72

39:                                               ; preds = %37
  %40 = call i32 @mbedtls_mpi_gcd(ptr noundef nonnull %8, ptr noundef nonnull %31, ptr noundef nonnull %6) #3
  %.not46 = icmp eq i32 %40, 0
  br i1 %.not46, label %41, label %72

41:                                               ; preds = %39
  %42 = call i32 @mbedtls_mpi_gcd(ptr noundef nonnull %9, ptr noundef nonnull %4, ptr noundef nonnull %5) #3
  %.not47 = icmp eq i32 %42, 0
  br i1 %.not47, label %43, label %72

43:                                               ; preds = %41
  %44 = call i32 @mbedtls_mpi_div_mpi(ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef nonnull %6, ptr noundef nonnull %9) #3
  %.not48 = icmp eq i32 %44, 0
  br i1 %.not48, label %45, label %72

45:                                               ; preds = %43
  %46 = call i32 @mbedtls_mpi_mod_mpi(ptr noundef nonnull %7, ptr noundef nonnull %3, ptr noundef nonnull %10) #3
  %.not49 = icmp eq i32 %46, 0
  br i1 %.not49, label %47, label %72

47:                                               ; preds = %45
  %48 = call i32 @mbedtls_mpi_mod_mpi(ptr noundef nonnull %12, ptr noundef nonnull %25, ptr noundef nonnull %4) #3
  %.not50 = icmp eq i32 %48, 0
  br i1 %.not50, label %49, label %72

49:                                               ; preds = %47
  %50 = call i32 @mbedtls_mpi_mod_mpi(ptr noundef nonnull %13, ptr noundef nonnull %25, ptr noundef nonnull %5) #3
  %.not51 = icmp eq i32 %50, 0
  br i1 %.not51, label %51, label %72

51:                                               ; preds = %49
  %52 = call i32 @mbedtls_mpi_inv_mod(ptr noundef nonnull %14, ptr noundef nonnull %21, ptr noundef nonnull %17) #3
  %.not52 = icmp eq i32 %52, 0
  br i1 %.not52, label %53, label %72

53:                                               ; preds = %51
  %54 = getelementptr inbounds i8, ptr %0, i64 16
  %55 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef nonnull %2, ptr noundef nonnull %54) #3
  %.not53 = icmp eq i32 %55, 0
  br i1 %.not53, label %56, label %71

56:                                               ; preds = %53
  %57 = getelementptr inbounds i8, ptr %0, i64 136
  %58 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef nonnull %12, ptr noundef nonnull %57) #3
  %.not54 = icmp eq i32 %58, 0
  br i1 %.not54, label %59, label %71

59:                                               ; preds = %56
  %60 = getelementptr inbounds i8, ptr %0, i64 160
  %61 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef nonnull %13, ptr noundef nonnull %60) #3
  %.not55 = icmp eq i32 %61, 0
  br i1 %.not55, label %62, label %71

62:                                               ; preds = %59
  %63 = getelementptr inbounds i8, ptr %0, i64 184
  %64 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef nonnull %14, ptr noundef nonnull %63) #3
  %.not56 = icmp eq i32 %64, 0
  br i1 %.not56, label %65, label %71

65:                                               ; preds = %62
  %66 = call i32 @mbedtls_mpi_cmp_int(ptr noundef nonnull %11, i64 noundef 0) #3
  %.not57 = icmp eq i32 %66, 0
  br i1 %.not57, label %67, label %71

67:                                               ; preds = %65
  %68 = call i32 @mbedtls_mpi_cmp_int(ptr noundef nonnull %7, i64 noundef 1) #3
  %.not58 = icmp eq i32 %68, 0
  br i1 %.not58, label %69, label %71

69:                                               ; preds = %67
  %70 = call i32 @mbedtls_mpi_cmp_int(ptr noundef nonnull %8, i64 noundef 1) #3
  %.not59 = icmp eq i32 %70, 0
  br i1 %.not59, label %72, label %71

71:                                               ; preds = %69, %67, %65, %62, %59, %56, %53
  br label %72

72:                                               ; preds = %69, %71, %51, %49, %47, %45, %43, %41, %39, %37, %35, %33, %30, %28
  %.0 = phi i32 [ %29, %28 ], [ %32, %30 ], [ %34, %33 ], [ %36, %35 ], [ %38, %37 ], [ %40, %39 ], [ %42, %41 ], [ %44, %43 ], [ %46, %45 ], [ %48, %47 ], [ %50, %49 ], [ %52, %51 ], [ -16896, %71 ], [ 0, %69 ]
  call void @mbedtls_mpi_free(ptr noundef nonnull %2) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %3) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %4) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %5) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %6) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %7) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %8) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %9) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %10) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %11) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %12) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %13) #3
  call void @mbedtls_mpi_free(ptr noundef nonnull %14) #3
  switch i32 %.0, label %73 [
    i32 -16896, label %75
    i32 0, label %75
  ]

73:                                               ; preds = %72
  %74 = add nsw i32 %.0, -16896
  br label %75

75:                                               ; preds = %72, %72, %16, %20, %24, %1, %73
  %.024 = phi i32 [ %74, %73 ], [ %15, %1 ], [ -16896, %24 ], [ -16896, %20 ], [ -16896, %16 ], [ %.0, %72 ], [ %.0, %72 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %13) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  ret i32 %.024
}

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

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


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