; LLVM IR from square/subzero :: core/external-crypto/aes (aes_avs)

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

@mode_str = external dso_local global [4 x ptr], align 16
@type_str = external dso_local global [6 x ptr], align 16
@klen_str = external dso_local global [3 x ptr], align 16
@test_path = external dso_local global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @find_line2(ptr 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: 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 void @do_encrypt(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @run_aes_avs_test(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [128 x i8], align 16
  %6 = alloca [1024 x i8], align 16
  %7 = alloca [32 x i8], align 16
  %8 = alloca [16 x i8], align 16
  %9 = alloca [256 x i8], align 16
  %10 = alloca [256 x i8], align 16
  %11 = alloca [256 x i8], align 16
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %176, %2
  %23 = load i32, ptr %12, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 3
  br i1 %24, label %25, label %179

25:                                               ; preds = %22
  store i32 0, ptr %13, align 4, !tbaa !5
  %26 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %27 = load ptr, ptr @test_path, align 8, !tbaa !9
  %28 = call ptr @strcpy(ptr noundef %26, ptr noundef %27) #5
  %29 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds [4 x ptr], ptr @mode_str, i64 0, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call ptr @strcat(ptr noundef %29, ptr noundef %33) #5
  %35 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds [6 x ptr], ptr @type_str, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = call ptr @strcat(ptr noundef %35, ptr noundef %39) #5
  %41 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %42 = load i32, ptr %12, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [3 x ptr], ptr @klen_str, i64 0, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = call ptr @strcat(ptr noundef %41, ptr noundef %45) #5
  %47 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %48 = call ptr @strcat(ptr noundef %47, ptr noundef @.str.19) #5
  %49 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %50 = call i32 @fopen_s(ptr noundef %19, ptr noundef %49, ptr noundef @.str.20)
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %25
  %53 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.21, ptr noundef %53)
  store i32 1, ptr %21, align 4
  br label %180

55:                                               ; preds = %25
  br label %56

56:                                               ; preds = %166, %55
  %57 = load ptr, ptr %19, align 8, !tbaa !9
  %58 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %59 = call i32 @get_line(ptr noundef %57, ptr noundef %58, i32 noundef 1024)
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %167

61:                                               ; preds = %56
  %62 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %63 = call i32 @find_line2(ptr noundef %62)
  store i32 %63, ptr %20, align 4, !tbaa !5
  %64 = icmp ne i32 %63, -1
  br i1 %64, label %65, label %166

65:                                               ; preds = %61
  %66 = load i32, ptr %20, align 4, !tbaa !5
  switch i32 %66, label %159 [
    i32 0, label %67
    i32 1, label %71
    i32 2, label %75
    i32 3, label %79
    i32 4, label %119
  ]

67:                                               ; preds = %65
  store i32 0, ptr %18, align 4, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !5
  store i32 0, ptr %15, align 4, !tbaa !5
  %68 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %69 = call i64 @get_dec(ptr noundef %68)
  %70 = trunc i64 %69 to i32
  store i32 %70, ptr %14, align 4, !tbaa !5
  br label %159

71:                                               ; preds = %65
  %72 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 0
  %73 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %74 = call i32 @block_in(ptr noundef %72, ptr noundef %73)
  store i32 %74, ptr %15, align 4, !tbaa !5
  br label %159

75:                                               ; preds = %65
  %76 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %77 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %78 = call i32 @block_in(ptr noundef %76, ptr noundef %77)
  store i32 %78, ptr %16, align 4, !tbaa !5
  br label %159

79:                                               ; preds = %65
  %80 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %81 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %82 = call i32 @block_in(ptr noundef %80, ptr noundef %81)
  store i32 %82, ptr %17, align 4, !tbaa !5
  %83 = load i32, ptr %17, align 4, !tbaa !5
  %84 = load i32, ptr %18, align 4, !tbaa !5
  %85 = icmp eq i32 %83, %84
  br i1 %85, label %86, label %118

86:                                               ; preds = %79
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = icmp eq i32 %87, 2
  br i1 %88, label %89, label %96

89:                                               ; preds = %86
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 0
  %92 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %93 = getelementptr inbounds [256 x i8], ptr %10, i64 0, i64 0
  %94 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %95 = load i32, ptr %15, align 4, !tbaa !5
  call void @do_mct_decrypt(i32 noundef %90, ptr noundef %91, ptr noundef %92, ptr noundef %93, ptr noundef %94, i32 noundef %95)
  br label %104

96:                                               ; preds = %86
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 0
  %99 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %100 = getelementptr inbounds [256 x i8], ptr %10, i64 0, i64 0
  %101 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %102 = load i32, ptr %15, align 4, !tbaa !5
  %103 = load i32, ptr %17, align 4, !tbaa !5
  call void @do_decrypt(i32 noundef %97, ptr noundef %98, ptr noundef %99, ptr noundef %100, ptr noundef %101, i32 noundef %102, i32 noundef %103)
  br label %104

104:                                              ; preds = %96, %89
  %105 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %106 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %107 = load i32, ptr %17, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = call i32 @memcmp(ptr noundef %105, ptr noundef %106, i64 noundef %108) #6
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %117

111:                                              ; preds = %104
  %112 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %113 = load i32, ptr %14, align 4, !tbaa !5
  %114 = call i32 (ptr, ...) @printf(ptr noundef @.str.22, ptr noundef %112, i32 noundef %113)
  %115 = load i32, ptr %13, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %13, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %111, %104
  br label %118

118:                                              ; preds = %117, %79
  br label %159

119:                                              ; preds = %65
  %120 = getelementptr inbounds [256 x i8], ptr %10, i64 0, i64 0
  %121 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %122 = call i32 @block_in(ptr noundef %120, ptr noundef %121)
  store i32 %122, ptr %18, align 4, !tbaa !5
  %123 = load i32, ptr %18, align 4, !tbaa !5
  %124 = load i32, ptr %17, align 4, !tbaa !5
  %125 = icmp eq i32 %123, %124
  br i1 %125, label %126, label %158

126:                                              ; preds = %119
  %127 = load i32, ptr %4, align 4, !tbaa !5
  %128 = icmp eq i32 %127, 2
  br i1 %128, label %129, label %136

129:                                              ; preds = %126
  %130 = load i32, ptr %3, align 4, !tbaa !5
  %131 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 0
  %132 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %133 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %134 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %135 = load i32, ptr %15, align 4, !tbaa !5
  call void @do_mct_encrypt(i32 noundef %130, ptr noundef %131, ptr noundef %132, ptr noundef %133, ptr noundef %134, i32 noundef %135)
  br label %144

136:                                              ; preds = %126
  %137 = load i32, ptr %3, align 4, !tbaa !5
  %138 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 0
  %139 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %140 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %141 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %142 = load i32, ptr %15, align 4, !tbaa !5
  %143 = load i32, ptr %17, align 4, !tbaa !5
  call void @do_encrypt(i32 noundef %137, ptr noundef %138, ptr noundef %139, ptr noundef %140, ptr noundef %141, i32 noundef %142, i32 noundef %143)
  br label %144

144:                                              ; preds = %136, %129
  %145 = getelementptr inbounds [256 x i8], ptr %10, i64 0, i64 0
  %146 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %147 = load i32, ptr %17, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = call i32 @memcmp(ptr noundef %145, ptr noundef %146, i64 noundef %148) #6
  %150 = icmp ne i32 %149, 0
  br i1 %150, label %151, label %157

151:                                              ; preds = %144
  %152 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %153 = load i32, ptr %14, align 4, !tbaa !5
  %154 = call i32 (ptr, ...) @printf(ptr noundef @.str.22, ptr noundef %152, i32 noundef %153)
  %155 = load i32, ptr %13, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %13, align 4, !tbaa !5
  br label %157

157:                                              ; preds = %151, %144
  br label %158

158:                                              ; preds = %157, %119
  br label %159

159:                                              ; preds = %158, %118, %75, %71, %67, %65
  %160 = load i32, ptr %13, align 4, !tbaa !5
  %161 = icmp sgt i32 %160, 5
  br i1 %161, label %162, label %165

162:                                              ; preds = %159
  %163 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %164 = call i32 (ptr, ...) @printf(ptr noundef @.str.23, ptr noundef %163)
  br label %167

165:                                              ; preds = %159
  br label %166

166:                                              ; preds = %165, %61
  br label %56, !llvm.loop !11

167:                                              ; preds = %162, %56
  %168 = load ptr, ptr %19, align 8, !tbaa !9
  %169 = call i32 @fclose(ptr noundef %168)
  %170 = load i32, ptr %13, align 4, !tbaa !5
  %171 = icmp ne i32 %170, 0
  br i1 %171, label %175, label %172

172:                                              ; preds = %167
  %173 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.24, ptr noundef %173)
  br label %175

175:                                              ; preds = %172, %167
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %12, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %12, align 4, !tbaa !5
  br label %22, !llvm.loop !13

179:                                              ; preds = %22
  store i32 0, ptr %21, align 4
  br label %180

180:                                              ; preds = %179, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %5) #5
  %181 = load i32, ptr %21, align 4
  switch i32 %181, label %183 [
    i32 0, label %182
    i32 1, label %182
  ]

182:                                              ; preds = %180, %180
  ret void

183:                                              ; preds = %180
  unreachable
}

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #2

declare i32 @fopen_s(ptr noundef, ptr noundef, ptr noundef) #3

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

declare i32 @get_line(ptr noundef, ptr noundef, i32 noundef) #3

declare i64 @get_dec(ptr noundef) #3

declare i32 @block_in(ptr noundef, ptr noundef) #3

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

declare i32 @fclose(ptr noundef) #3

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 = { 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 = { "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 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 #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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@mode_str = external dso_local local_unnamed_addr global [4 x ptr], align 16
@type_str = external dso_local local_unnamed_addr global [6 x ptr], align 16
@klen_str = external dso_local local_unnamed_addr global [3 x ptr], align 16
@test_path = external dso_local local_unnamed_addr global ptr, align 8
@.str.19 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @find_line2(ptr 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: 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 void @do_encrypt(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @run_aes_avs_test(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [128 x i8], align 16
  %4 = alloca [1024 x i8], align 16
  %5 = alloca [32 x i8], align 16
  %6 = alloca [16 x i8], align 16
  %7 = alloca [256 x i8], align 16
  %8 = alloca [256 x i8], align 16
  %9 = alloca [256 x i8], align 16
  %10 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #6
  %11 = zext i32 %0 to i64
  %12 = getelementptr inbounds [4 x ptr], ptr @mode_str, i64 0, i64 %11
  %13 = zext i32 %1 to i64
  %14 = getelementptr inbounds [6 x ptr], ptr @type_str, i64 0, i64 %13
  %15 = icmp eq i32 %1, 2
  br label %16

16:                                               ; preds = %2, %78
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %78 ]
  %.03087 = phi i32 [ undef, %2 ], [ %.469, %78 ]
  %.03186 = phi i32 [ undef, %2 ], [ %.43568, %78 ]
  %.03685 = phi i32 [ undef, %2 ], [ %.44067, %78 ]
  %.04184 = phi i32 [ undef, %2 ], [ %.44566, %78 ]
  %17 = load ptr, ptr @test_path, align 8, !tbaa !5
  %18 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %17) #6
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  %20 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %19) #6
  %21 = load ptr, ptr %14, align 8, !tbaa !5
  %22 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %21) #6
  %23 = getelementptr inbounds [3 x ptr], ptr @klen_str, i64 0, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %24) #6
  %26 = call ptr @strcat(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.19) #6
  %27 = call i32 @fopen_s(ptr noundef nonnull %10, ptr noundef nonnull %3, ptr noundef nonnull @.str.20) #6
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %.preheader, label %33

.preheader:                                       ; preds = %16
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = call i32 @get_line(ptr noundef %28, ptr noundef nonnull %4, i32 noundef 1024) #6
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %.preheader
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = call i32 @fclose(ptr noundef %31)
  br label %76

33:                                               ; preds = %16
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21, ptr noundef nonnull %3)
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %70
  %.179 = phi i32 [ %.3, %70 ], [ %.03087, %.preheader ]
  %.13278 = phi i32 [ %.334, %70 ], [ %.03186, %.preheader ]
  %.13777 = phi i32 [ %.339, %70 ], [ %.03685, %.preheader ]
  %.14276 = phi i32 [ %.344, %70 ], [ %.04184, %.preheader ]
  %.04675 = phi i32 [ %.248, %70 ], [ 0, %.preheader ]
  %35 = call i32 @find_line2(ptr noundef nonnull %4)
  switch i32 %35, label %65 [
    i32 -1, label %70
    i32 0, label %36
    i32 1, label %39
    i32 2, label %41
    i32 3, label %43
    i32 4, label %54
  ]

36:                                               ; preds = %.lr.ph
  %37 = call i64 @get_dec(ptr noundef nonnull %4) #6
  %38 = trunc i64 %37 to i32
  br label %65

39:                                               ; preds = %.lr.ph
  %40 = call i32 @block_in(ptr noundef nonnull %5, ptr noundef nonnull %4) #6
  br label %65

41:                                               ; preds = %.lr.ph
  %42 = call i32 @block_in(ptr noundef nonnull %6, ptr noundef nonnull %4) #6
  br label %65

43:                                               ; preds = %.lr.ph
  %44 = call i32 @block_in(ptr noundef nonnull %7, ptr noundef nonnull %4) #6
  %45 = icmp eq i32 %44, %.179
  br i1 %45, label %46, label %65

46:                                               ; preds = %43
  br i1 %15, label %47, label %48

47:                                               ; preds = %46
  call void @do_mct_decrypt(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %8, ptr noundef nonnull %9, i32 noundef %.13777)
  br label %49

48:                                               ; preds = %46
  call void @do_decrypt(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %8, ptr noundef nonnull %9, i32 noundef %.13777, i32 noundef %.179)
  br label %49

49:                                               ; preds = %48, %47
  %50 = sext i32 %.179 to i64
  %bcmp57 = call i32 @bcmp(ptr nonnull %7, ptr nonnull %9, i64 %50)
  %.not58 = icmp eq i32 %bcmp57, 0
  br i1 %.not58, label %65, label %51

51:                                               ; preds = %49
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22, ptr noundef nonnull %3, i32 noundef %.14276)
  %53 = add nsw i32 %.04675, 1
  br label %65

54:                                               ; preds = %.lr.ph
  %55 = call i32 @block_in(ptr noundef nonnull %8, ptr noundef nonnull %4) #6
  %56 = icmp eq i32 %55, %.13278
  br i1 %56, label %57, label %65

57:                                               ; preds = %54
  br i1 %15, label %58, label %59

58:                                               ; preds = %57
  call void @do_mct_encrypt(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %9, i32 noundef %.13777)
  br label %60

59:                                               ; preds = %57
  call void @do_encrypt(i32 noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %9, i32 noundef %.13777, i32 noundef %.13278)
  br label %60

60:                                               ; preds = %59, %58
  %61 = sext i32 %.13278 to i64
  %bcmp = call i32 @bcmp(ptr nonnull %8, ptr nonnull %9, i64 %61)
  %.not56 = icmp eq i32 %bcmp, 0
  br i1 %.not56, label %65, label %62

62:                                               ; preds = %60
  %63 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22, ptr noundef nonnull %3, i32 noundef %.14276)
  %64 = add nsw i32 %.04675, 1
  br label %65

65:                                               ; preds = %.lr.ph, %54, %62, %60, %43, %51, %49, %41, %39, %36
  %.147 = phi i32 [ %64, %62 ], [ %.04675, %60 ], [ %.04675, %54 ], [ %53, %51 ], [ %.04675, %49 ], [ %.04675, %43 ], [ %.04675, %41 ], [ %.04675, %39 ], [ %.04675, %36 ], [ %.04675, %.lr.ph ]
  %.243 = phi i32 [ %.14276, %62 ], [ %.14276, %60 ], [ %.14276, %54 ], [ %.14276, %51 ], [ %.14276, %49 ], [ %.14276, %43 ], [ %.14276, %41 ], [ %.14276, %39 ], [ %38, %36 ], [ %.14276, %.lr.ph ]
  %.238 = phi i32 [ %.13777, %62 ], [ %.13777, %60 ], [ %.13777, %54 ], [ %.13777, %51 ], [ %.13777, %49 ], [ %.13777, %43 ], [ %.13777, %41 ], [ %40, %39 ], [ 0, %36 ], [ %.13777, %.lr.ph ]
  %.233 = phi i32 [ %.13278, %62 ], [ %.13278, %60 ], [ %.13278, %54 ], [ %.179, %51 ], [ %.179, %49 ], [ %44, %43 ], [ %.13278, %41 ], [ %.13278, %39 ], [ 0, %36 ], [ %.13278, %.lr.ph ]
  %.2 = phi i32 [ %.13278, %62 ], [ %.13278, %60 ], [ %55, %54 ], [ %.179, %51 ], [ %.179, %49 ], [ %.179, %43 ], [ %.179, %41 ], [ %.179, %39 ], [ 0, %36 ], [ %.179, %.lr.ph ]
  %66 = icmp sgt i32 %.147, 5
  br i1 %66, label %.thread, label %70

.thread:                                          ; preds = %65
  %67 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.23, ptr noundef nonnull %3)
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = call i32 @fclose(ptr noundef %68)
  br label %78

70:                                               ; preds = %.lr.ph, %65
  %.248 = phi i32 [ %.147, %65 ], [ %.04675, %.lr.ph ]
  %.344 = phi i32 [ %.243, %65 ], [ %.14276, %.lr.ph ]
  %.339 = phi i32 [ %.238, %65 ], [ %.13777, %.lr.ph ]
  %.334 = phi i32 [ %.233, %65 ], [ %.13278, %.lr.ph ]
  %.3 = phi i32 [ %.2, %65 ], [ %.179, %.lr.ph ]
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = call i32 @get_line(ptr noundef %71, ptr noundef nonnull %4, i32 noundef 1024) #6
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %70
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = call i32 @fclose(ptr noundef %74)
  %.not59 = icmp eq i32 %.248, 0
  br i1 %.not59, label %76, label %78

76:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %.1.lcssa99 = phi i32 [ %.03087, %._crit_edge.thread ], [ %.3, %._crit_edge ]
  %.132.lcssa98 = phi i32 [ %.03186, %._crit_edge.thread ], [ %.334, %._crit_edge ]
  %.137.lcssa97 = phi i32 [ %.03685, %._crit_edge.thread ], [ %.339, %._crit_edge ]
  %.142.lcssa96 = phi i32 [ %.04184, %._crit_edge.thread ], [ %.344, %._crit_edge ]
  %77 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24, ptr noundef nonnull %3)
  br label %78

78:                                               ; preds = %.thread, %._crit_edge, %76
  %.469 = phi i32 [ %.2, %.thread ], [ %.3, %._crit_edge ], [ %.1.lcssa99, %76 ]
  %.43568 = phi i32 [ %.233, %.thread ], [ %.334, %._crit_edge ], [ %.132.lcssa98, %76 ]
  %.44067 = phi i32 [ %.238, %.thread ], [ %.339, %._crit_edge ], [ %.137.lcssa97, %76 ]
  %.44566 = phi i32 [ %.243, %.thread ], [ %.344, %._crit_edge ], [ %.142.lcssa96, %76 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 3
  br i1 %exitcond.not, label %.loopexit, label %16, !llvm.loop !11

.loopexit:                                        ; preds = %78, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #6
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

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

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

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

declare i64 @get_dec(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

; 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 nofree nounwind willreturn memory(argmem: readwrite) "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 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass