; LLVM IR from HarshCasper/NeoAlgo :: C/cryptography (Affine_Substitution_Cipher)

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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = call ptr @llvm.stacksave.p0()
  store ptr %21, ptr %9, align 8
  %22 = alloca i32, i64 %20, align 16
  store i64 %20, ptr %10, align 8
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = alloca i32, i64 %24, align 16
  store i64 %24, ptr %11, align 8
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = zext i32 %26 to i64
  %28 = alloca i32, i64 %27, align 16
  store i64 %27, ptr %12, align 8
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = alloca i32, i64 %30, align 16
  store i64 %30, ptr %13, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %2)
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = mul i64 %36, 1
  %38 = call noalias ptr @malloc(i64 noundef %37) #9
  store ptr %38, ptr %15, align 8, !tbaa !9
  %39 = load ptr, ptr %15, align 8, !tbaa !9
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %43

41:                                               ; preds = %0
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %47

43:                                               ; preds = %0
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %45 = load ptr, ptr %15, align 8, !tbaa !9
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %45)
  br label %47

47:                                               ; preds = %43, %41
  store i32 0, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %91, %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = load ptr, ptr %15, align 8, !tbaa !9
  %52 = call i64 @strlen(ptr noundef %51) #10
  %53 = icmp ult i64 %50, %52
  br i1 %53, label %54, label %94

54:                                               ; preds = %48
  %55 = load ptr, ptr %15, align 8, !tbaa !9
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %55, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = sext i8 %59 to i32
  %61 = icmp ne i32 %60, 32
  br i1 %61, label %62, label %83

62:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %63 = call ptr @__ctype_toupper_loc() #11
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  %65 = load ptr, ptr %15, align 8, !tbaa !9
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %65, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %70 = sext i8 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %64, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  store i32 %73, ptr %17, align 4, !tbaa !5
  %74 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %74, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  %75 = load i32, ptr %18, align 4, !tbaa !5
  %76 = trunc i32 %75 to i8
  %77 = load ptr, ptr %15, align 8, !tbaa !9
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i8, ptr %77, i64 %79
  store i8 %76, ptr %80, align 1, !tbaa !11
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %4, align 4, !tbaa !5
  br label %90

83:                                               ; preds = %54
  %84 = load ptr, ptr %15, align 8, !tbaa !9
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i8, ptr %84, i64 %86
  store i8 32, ptr %87, align 1, !tbaa !11
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %4, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %83, %62
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %3, align 4, !tbaa !5
  br label %48, !llvm.loop !12

94:                                               ; preds = %48
  %95 = load ptr, ptr %15, align 8, !tbaa !9
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i8, ptr %95, i64 %97
  store i8 0, ptr %98, align 1, !tbaa !11
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %100 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %7)
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = icmp slt i32 %101, 1
  br i1 %102, label %106, label %103

103:                                              ; preds = %94
  %104 = load i32, ptr %7, align 4, !tbaa !5
  %105 = icmp sgt i32 %104, 25
  br i1 %105, label %106, label %108

106:                                              ; preds = %103, %94
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  call void @exit(i32 noundef 0) #12
  unreachable

108:                                              ; preds = %103
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = call i32 @CalculateGCD(i32 noundef %109)
  store i32 %110, ptr %6, align 4, !tbaa !5
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = icmp ne i32 %111, 1
  br i1 %112, label %113, label %117

113:                                              ; preds = %108
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %114, i32 noundef %115)
  call void @exit(i32 noundef 0) #12
  unreachable

117:                                              ; preds = %108
  %118 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %119 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %8)
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = icmp slt i32 %120, 0
  br i1 %121, label %125, label %122

122:                                              ; preds = %117
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = icmp sgt i32 %123, 25
  br i1 %124, label %125, label %127

125:                                              ; preds = %122, %117
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @exit(i32 noundef 0) #12
  unreachable

127:                                              ; preds = %122
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %158, %127
  %129 = load i32, ptr %3, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = load ptr, ptr %15, align 8, !tbaa !9
  %132 = call i64 @strlen(ptr noundef %131) #10
  %133 = icmp ult i64 %130, %132
  br i1 %133, label %134, label %161

134:                                              ; preds = %128
  %135 = load ptr, ptr %15, align 8, !tbaa !9
  %136 = load i32, ptr %3, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds i8, ptr %135, i64 %137
  %139 = load i8, ptr %138, align 1, !tbaa !11
  %140 = sext i8 %139 to i32
  %141 = icmp ne i32 %140, 32
  br i1 %141, label %142, label %153

142:                                              ; preds = %134
  %143 = load ptr, ptr %15, align 8, !tbaa !9
  %144 = load i32, ptr %3, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds i8, ptr %143, i64 %145
  %147 = load i8, ptr %146, align 1, !tbaa !11
  %148 = sext i8 %147 to i32
  %149 = sub nsw i32 %148, 65
  %150 = load i32, ptr %3, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds i32, ptr %22, i64 %151
  store i32 %149, ptr %152, align 4, !tbaa !5
  br label %157

153:                                              ; preds = %134
  %154 = load i32, ptr %3, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i32, ptr %22, i64 %155
  store i32 -20, ptr %156, align 4, !tbaa !5
  br label %157

157:                                              ; preds = %153, %142
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %3, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %3, align 4, !tbaa !5
  br label %128, !llvm.loop !14

161:                                              ; preds = %128
  %162 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %163 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %164

164:                                              ; preds = %212, %161
  %165 = load i32, ptr %3, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = load ptr, ptr %15, align 8, !tbaa !9
  %168 = call i64 @strlen(ptr noundef %167) #10
  %169 = icmp ult i64 %166, %168
  br i1 %169, label %170, label %215

170:                                              ; preds = %164
  %171 = load i32, ptr %3, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds i32, ptr %22, i64 %172
  %174 = load i32, ptr %173, align 4, !tbaa !5
  %175 = icmp ne i32 %174, -20
  br i1 %175, label %176, label %205

176:                                              ; preds = %170
  %177 = load i32, ptr %7, align 4, !tbaa !5
  %178 = load i32, ptr %3, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds i32, ptr %22, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = mul nsw i32 %177, %181
  %183 = load i32, ptr %8, align 4, !tbaa !5
  %184 = add nsw i32 %182, %183
  %185 = srem i32 %184, 26
  %186 = load i32, ptr %3, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds i32, ptr %25, i64 %187
  store i32 %185, ptr %188, align 4, !tbaa !5
  %189 = load i32, ptr %3, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds i32, ptr %25, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !5
  %193 = add nsw i32 %192, 65
  %194 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %193)
  %195 = load i32, ptr %3, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds i32, ptr %25, i64 %196
  %198 = load i32, ptr %197, align 4, !tbaa !5
  %199 = add nsw i32 %198, 65
  %200 = trunc i32 %199 to i8
  %201 = load ptr, ptr %16, align 8, !tbaa !9
  %202 = load i32, ptr %3, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds i8, ptr %201, i64 %203
  store i8 %200, ptr %204, align 1, !tbaa !11
  br label %211

205:                                              ; preds = %170
  %206 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %207 = load ptr, ptr %16, align 8, !tbaa !9
  %208 = load i32, ptr %3, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds i8, ptr %207, i64 %209
  store i8 32, ptr %210, align 1, !tbaa !11
  br label %211

211:                                              ; preds = %205, %176
  br label %212

212:                                              ; preds = %211
  %213 = load i32, ptr %3, align 4, !tbaa !5
  %214 = add nsw i32 %213, 1
  store i32 %214, ptr %3, align 4, !tbaa !5
  br label %164, !llvm.loop !15

215:                                              ; preds = %164
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %216

216:                                              ; preds = %246, %215
  %217 = load i32, ptr %3, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = load ptr, ptr %16, align 8, !tbaa !9
  %220 = call i64 @strlen(ptr noundef %219) #10
  %221 = icmp ult i64 %218, %220
  br i1 %221, label %222, label %249

222:                                              ; preds = %216
  %223 = load ptr, ptr %16, align 8, !tbaa !9
  %224 = load i32, ptr %3, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds i8, ptr %223, i64 %225
  %227 = load i8, ptr %226, align 1, !tbaa !11
  %228 = sext i8 %227 to i32
  %229 = icmp ne i32 %228, 32
  br i1 %229, label %230, label %241

230:                                              ; preds = %222
  %231 = load ptr, ptr %16, align 8, !tbaa !9
  %232 = load i32, ptr %3, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds i8, ptr %231, i64 %233
  %235 = load i8, ptr %234, align 1, !tbaa !11
  %236 = sext i8 %235 to i32
  %237 = sub nsw i32 %236, 65
  %238 = load i32, ptr %3, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds i32, ptr %28, i64 %239
  store i32 %237, ptr %240, align 4, !tbaa !5
  br label %245

241:                                              ; preds = %222
  %242 = load i32, ptr %3, align 4, !tbaa !5
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds i32, ptr %28, i64 %243
  store i32 -20, ptr %244, align 4, !tbaa !5
  br label %245

245:                                              ; preds = %241, %230
  br label %246

246:                                              ; preds = %245
  %247 = load i32, ptr %3, align 4, !tbaa !5
  %248 = add nsw i32 %247, 1
  store i32 %248, ptr %3, align 4, !tbaa !5
  br label %216, !llvm.loop !16

249:                                              ; preds = %216
  %250 = load i32, ptr %7, align 4, !tbaa !5
  %251 = call i32 @CalculateMultiplicativeInverse(i32 noundef %250)
  store i32 %251, ptr %14, align 4, !tbaa !5
  %252 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %253

253:                                              ; preds = %302, %249
  %254 = load i32, ptr %3, align 4, !tbaa !5
  %255 = sext i32 %254 to i64
  %256 = load ptr, ptr %16, align 8, !tbaa !9
  %257 = call i64 @strlen(ptr noundef %256) #10
  %258 = icmp ult i64 %255, %257
  br i1 %258, label %259, label %305

259:                                              ; preds = %253
  %260 = load i32, ptr %3, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds i32, ptr %28, i64 %261
  %263 = load i32, ptr %262, align 4, !tbaa !5
  %264 = icmp ne i32 %263, -20
  br i1 %264, label %265, label %299

265:                                              ; preds = %259
  %266 = load i32, ptr %14, align 4, !tbaa !5
  %267 = load i32, ptr %3, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds i32, ptr %28, i64 %268
  %270 = load i32, ptr %269, align 4, !tbaa !5
  %271 = load i32, ptr %8, align 4, !tbaa !5
  %272 = sub nsw i32 %270, %271
  %273 = mul nsw i32 %266, %272
  %274 = srem i32 %273, 26
  %275 = load i32, ptr %3, align 4, !tbaa !5
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds i32, ptr %31, i64 %276
  store i32 %274, ptr %277, align 4, !tbaa !5
  %278 = load i32, ptr %3, align 4, !tbaa !5
  %279 = sext i32 %278 to i64
  %280 = getelementptr inbounds i32, ptr %31, i64 %279
  %281 = load i32, ptr %280, align 4, !tbaa !5
  %282 = icmp slt i32 %281, 0
  br i1 %282, label %283, label %292

283:                                              ; preds = %265
  %284 = load i32, ptr %3, align 4, !tbaa !5
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds i32, ptr %31, i64 %285
  %287 = load i32, ptr %286, align 4, !tbaa !5
  %288 = add nsw i32 %287, 26
  %289 = load i32, ptr %3, align 4, !tbaa !5
  %290 = sext i32 %289 to i64
  %291 = getelementptr inbounds i32, ptr %31, i64 %290
  store i32 %288, ptr %291, align 4, !tbaa !5
  br label %292

292:                                              ; preds = %283, %265
  %293 = load i32, ptr %3, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds i32, ptr %31, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !5
  %297 = add nsw i32 %296, 65
  %298 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %297)
  br label %301

299:                                              ; preds = %259
  %300 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  br label %301

301:                                              ; preds = %299, %292
  br label %302

302:                                              ; preds = %301
  %303 = load i32, ptr %3, align 4, !tbaa !5
  %304 = add nsw i32 %303, 1
  store i32 %304, ptr %3, align 4, !tbaa !5
  br label %253, !llvm.loop !17

305:                                              ; preds = %253
  %306 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  %307 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %307)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  %308 = load i32, ptr %1, align 4
  ret i32 %308
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() #6

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #7

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

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 nosync nounwind willreturn }
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 allocsize(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 #5 = { 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 #6 = { nounwind willreturn memory(none) "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 #7 = { noreturn 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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { nounwind willreturn memory(none) }
attributes #12 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}


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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #9
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = call noalias ptr @malloc(i64 noundef %8) #10
  %10 = icmp eq ptr %9, null
  br i1 %10, label %.thread, label %12

.thread:                                          ; preds = %0
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.lr.ph.preheader

12:                                               ; preds = %0
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %9)
  %char0101.pre = load i8, ptr %9, align 1
  %15 = icmp eq i8 %char0101.pre, 0
  br i1 %15, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.thread, %12
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %25
  %indvars.iv = phi i64 [ %indvars.iv.next, %25 ], [ 0, %.lr.ph.preheader ]
  %16 = getelementptr inbounds i8, ptr %9, i64 %indvars.iv
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %.not87 = icmp eq i8 %17, 32
  br i1 %.not87, label %25, label %18

18:                                               ; preds = %.lr.ph
  %19 = tail call ptr @__ctype_toupper_loc() #11
  %20 = load ptr, ptr %19, align 8, !tbaa !10
  %21 = sext i8 %17 to i64
  %22 = getelementptr inbounds i32, ptr %20, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = trunc i32 %23 to i8
  br label %25

25:                                               ; preds = %.lr.ph, %18
  %.sink = phi i8 [ %24, %18 ], [ 32, %.lr.ph ]
  store i8 %.sink, ptr %16, align 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #12
  %27 = icmp ugt i64 %26, %indvars.iv.next
  br i1 %27, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %25
  %28 = and i64 %indvars.iv.next, 4294967295
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %12
  %.066.lcssa = phi i64 [ 0, %12 ], [ %28, %._crit_edge.loopexit ]
  %29 = getelementptr inbounds i8, ptr %9, i64 %.066.lcssa
  store i8 0, ptr %29, align 1, !tbaa !9
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2)
  %32 = load i32, ptr %2, align 4
  %33 = add i32 %32, -26
  %or.cond = icmp ult i32 %33, -25
  br i1 %or.cond, label %34, label %36

34:                                               ; preds = %._crit_edge
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  call void @exit(i32 noundef 0) #13
  unreachable

36:                                               ; preds = %._crit_edge
  %37 = call i32 @CalculateGCD(i32 noundef %32)
  %.not = icmp eq i32 %37, 1
  br i1 %.not, label %41, label %38

38:                                               ; preds = %36
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %39, i32 noundef %37)
  call void @exit(i32 noundef 0) #13
  unreachable

41:                                               ; preds = %36
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %3)
  %44 = load i32, ptr %3, align 4
  %or.cond3 = icmp ugt i32 %44, 25
  br i1 %or.cond3, label %51, label %.preheader88

.preheader88:                                     ; preds = %41
  %45 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #12
  %.not103 = icmp eq i64 %45, 0
  br i1 %.not103, label %53, label %.lr.ph92.preheader

.lr.ph92.preheader:                               ; preds = %.preheader88
  %46 = getelementptr i8, ptr %9, i64 %45
  %47 = getelementptr i8, ptr %46, i64 -1
  %48 = load i8, ptr %47, align 1, !tbaa !9
  %.not85 = icmp eq i8 %48, 32
  %49 = sext i8 %48 to i32
  %50 = add nsw i32 %49, -65
  %storemerge86 = select i1 %.not85, i32 -20, i32 %50
  br label %53

51:                                               ; preds = %41
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @exit(i32 noundef 0) #13
  unreachable

53:                                               ; preds = %.lr.ph92.preheader, %.preheader88
  %54 = phi i32 [ %storemerge86, %.lr.ph92.preheader ], [ undef, %.preheader88 ]
  %55 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %char0 = load i8, ptr %9, align 1
  %.not82 = icmp ne i8 %char0, 0
  call void @llvm.assume(i1 %.not82)
  %.not84 = icmp eq i32 %54, -20
  br i1 %.not84, label %65, label %57

57:                                               ; preds = %53
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = mul nsw i32 %58, %54
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  %62 = srem i32 %61, 26
  %63 = add nsw i32 %62, 65
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %63)
  unreachable

65:                                               ; preds = %53
  %66 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  unreachable
}

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() local_unnamed_addr #5

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local i32 @CalculateGCD(i32 noundef) local_unnamed_addr #7

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #8

attributes #0 = { noreturn 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 = { 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 #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #6 = { noreturn 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 #7 = { 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 #8 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { nounwind willreturn memory(none) }
attributes #12 = { nounwind willreturn memory(read) }
attributes #13 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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