; LLVM IR from didi/AoE :: linux/src/plugin (AOECrypto)

; 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.AES_ctx = type { [176 x i8], [16 x i8] }

@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

declare i32 @fgetc(ptr noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

declare void @AES_init_ctx_iv(ptr noundef, ptr noundef, ptr noundef) #1

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

declare void @AES_CBC_decrypt_buffer(ptr noundef, ptr noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @AOECrypto_decryptAoeFile_cbc_mem(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #4 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca %struct.AES_ctx, align 1
  %20 = alloca i64, align 8
  %21 = alloca i8, align 1
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i8, align 1
  %25 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp eq ptr null, %26
  br i1 %27, label %34, label %28

28:                                               ; preds = %4
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = icmp eq ptr null, %29
  br i1 %30, label %34, label %31

31:                                               ; preds = %28
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = icmp eq ptr null, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %31, %28, %4
  store i32 -1, ptr %5, align 4
  br label %187

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call noalias ptr @fopen(ptr noundef %36, ptr noundef @.str)
  store ptr %37, ptr %10, align 8, !tbaa !5
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = icmp eq ptr null, %38
  br i1 %39, label %40, label %43

40:                                               ; preds = %35
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = call i32 @fclose(ptr noundef %41)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %186

43:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = call i32 @fgetc(ptr noundef %44)
  store i32 %45, ptr %12, align 4, !tbaa !9
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %182

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 20, ptr %13, align 4, !tbaa !9
  %49 = call ptr @llvm.stacksave.p0()
  store ptr %49, ptr %14, align 8
  %50 = alloca i8, i64 20, align 16
  call void @llvm.memset.p0.i64(ptr align 16 %50, i8 0, i64 20, i1 false)
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = call i64 @fread(ptr noundef %50, i64 noundef 1, i64 noundef 20, ptr noundef %51)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %53 = getelementptr inbounds i8, ptr %50, i64 0
  %54 = load i8, ptr %53, align 16, !tbaa !11
  %55 = zext i8 %54 to i32
  %56 = shl i32 %55, 24
  %57 = and i32 %56, -16777216
  %58 = getelementptr inbounds i8, ptr %50, i64 1
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = zext i8 %59 to i32
  %61 = shl i32 %60, 16
  %62 = and i32 %61, 16711680
  %63 = or i32 %57, %62
  %64 = getelementptr inbounds i8, ptr %50, i64 2
  %65 = load i8, ptr %64, align 2, !tbaa !11
  %66 = zext i8 %65 to i32
  %67 = shl i32 %66, 8
  %68 = and i32 %67, 65280
  %69 = or i32 %63, %68
  %70 = getelementptr inbounds i8, ptr %50, i64 3
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = zext i8 %71 to i32
  %73 = and i32 %72, 255
  %74 = or i32 %69, %73
  store i32 %74, ptr %15, align 4, !tbaa !9
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = icmp sle i32 %75, 0
  br i1 %76, label %77, label %80

77:                                               ; preds = %48
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = call i32 @fclose(ptr noundef %78)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %180

80:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %81 = load i32, ptr %15, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = call noalias ptr @malloc(i64 noundef %82) #8
  store ptr %83, ptr %16, align 8, !tbaa !5
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  %85 = icmp eq ptr null, %84
  br i1 %85, label %86, label %89

86:                                               ; preds = %80
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = call i32 @fclose(ptr noundef %87)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %179

89:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %90, ptr %17, align 8, !tbaa !5
  %91 = alloca i8, i64 16384, align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 192, ptr %19) #7
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  call void @AES_init_ctx_iv(ptr noundef %19, ptr noundef %92, ptr noundef %93)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  store i64 0, ptr %20, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #7
  store i8 1, ptr %21, align 1, !tbaa !14
  br label %94

94:                                               ; preds = %171, %89
  call void @llvm.memset.p0.i64(ptr align 16 %91, i8 0, i64 16384, i1 false)
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = call i64 @fread(ptr noundef %91, i64 noundef 1, i64 noundef 16384, ptr noundef %95)
  %97 = trunc i64 %96 to i32
  store i32 %97, ptr %18, align 4, !tbaa !9
  %98 = load i32, ptr %18, align 4, !tbaa !9
  %99 = icmp sle i32 %98, 0
  br i1 %99, label %100, label %101

100:                                              ; preds = %94
  br label %174

101:                                              ; preds = %94
  %102 = load i32, ptr %18, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = load i64, ptr %20, align 8, !tbaa !12
  %105 = add nsw i64 %104, %103
  store i64 %105, ptr %20, align 8, !tbaa !12
  %106 = load i8, ptr %21, align 1, !tbaa !14, !range !16, !noundef !17
  %107 = trunc i8 %106 to i1
  br i1 %107, label %108, label %140

108:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  %109 = load i32, ptr %18, align 4, !tbaa !9
  %110 = sdiv i32 %109, 1024
  store i32 %110, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %136, %108
  %112 = load i32, ptr %23, align 4, !tbaa !9
  %113 = load i32, ptr %22, align 4, !tbaa !9
  %114 = icmp slt i32 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  store i32 4, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %139

116:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #7
  %117 = load i32, ptr %23, align 4, !tbaa !9
  %118 = mul nsw i32 %117, 1024
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i8, ptr %91, i64 %119
  %121 = load i8, ptr %120, align 1, !tbaa !11
  store i8 %121, ptr %24, align 1, !tbaa !11
  %122 = load i32, ptr %23, align 4, !tbaa !9
  %123 = add nsw i32 4, %122
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i8, ptr %50, i64 %124
  %126 = load i8, ptr %125, align 1, !tbaa !11
  %127 = load i32, ptr %23, align 4, !tbaa !9
  %128 = mul nsw i32 %127, 1024
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i8, ptr %91, i64 %129
  store i8 %126, ptr %130, align 1, !tbaa !11
  %131 = load i8, ptr %24, align 1, !tbaa !11
  %132 = load i32, ptr %23, align 4, !tbaa !9
  %133 = add nsw i32 4, %132
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds i8, ptr %50, i64 %134
  store i8 %131, ptr %135, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 1, ptr %24) #7
  br label %136

136:                                              ; preds = %116
  %137 = load i32, ptr %23, align 4, !tbaa !9
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %23, align 4, !tbaa !9
  br label %111, !llvm.loop !18

139:                                              ; preds = %115
  store i8 0, ptr %21, align 1, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %140

140:                                              ; preds = %139, %101
  %141 = load i32, ptr %18, align 4, !tbaa !9
  call void @AES_CBC_decrypt_buffer(ptr noundef %19, ptr noundef %91, i32 noundef %141)
  %142 = load i64, ptr %20, align 8, !tbaa !12
  %143 = load i32, ptr %15, align 4, !tbaa !9
  %144 = sext i32 %143 to i64
  %145 = icmp slt i64 %142, %144
  br i1 %145, label %146, label %154

146:                                              ; preds = %140
  %147 = load ptr, ptr %17, align 8, !tbaa !5
  %148 = load i32, ptr %18, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %147, ptr align 16 %91, i64 %149, i1 false)
  %150 = load i32, ptr %18, align 4, !tbaa !9
  %151 = load ptr, ptr %17, align 8, !tbaa !5
  %152 = sext i32 %150 to i64
  %153 = getelementptr inbounds i8, ptr %151, i64 %152
  store ptr %153, ptr %17, align 8, !tbaa !5
  br label %170

154:                                              ; preds = %140
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %155 = load i32, ptr %18, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = load i64, ptr %20, align 8, !tbaa !12
  %158 = load i32, ptr %15, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = sub nsw i64 %157, %159
  %161 = sub nsw i64 %156, %160
  %162 = trunc i64 %161 to i32
  store i32 %162, ptr %25, align 4, !tbaa !9
  %163 = load ptr, ptr %17, align 8, !tbaa !5
  %164 = load i32, ptr %25, align 4, !tbaa !9
  %165 = sext i32 %164 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %163, ptr align 16 %91, i64 %165, i1 false)
  %166 = load i32, ptr %25, align 4, !tbaa !9
  %167 = load ptr, ptr %17, align 8, !tbaa !5
  %168 = sext i32 %166 to i64
  %169 = getelementptr inbounds i8, ptr %167, i64 %168
  store ptr %169, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  br label %170

170:                                              ; preds = %154, %146
  br label %171

171:                                              ; preds = %170
  %172 = load i32, ptr %18, align 4, !tbaa !9
  %173 = icmp sgt i32 %172, 0
  br i1 %173, label %94, label %174, !llvm.loop !20

174:                                              ; preds = %171, %100
  %175 = load ptr, ptr %10, align 8, !tbaa !5
  %176 = call i32 @fclose(ptr noundef %175)
  %177 = load ptr, ptr %16, align 8, !tbaa !5
  %178 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %177, ptr %178, align 8, !tbaa !5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 192, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %179

179:                                              ; preds = %174, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %180

180:                                              ; preds = %179, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  %181 = load ptr, ptr %14, align 8
  call void @llvm.stackrestore.p0(ptr %181)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %185

182:                                              ; preds = %43
  %183 = load ptr, ptr %10, align 8, !tbaa !5
  %184 = call i32 @fclose(ptr noundef %183)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %185

185:                                              ; preds = %182, %180
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %186

186:                                              ; preds = %185, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %187

187:                                              ; preds = %186, %34
  %188 = load i32, ptr %5, align 4
  ret i32 %188
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.AES_ctx = type { [176 x i8], [16 x i8] }

@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

declare void @AES_init_ctx_iv(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

declare void @AES_CBC_decrypt_buffer(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @AOECrypto_decryptAoeFile_cbc_mem(ptr noundef readonly %0, ptr nocapture noundef writeonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #5 {
  %5 = alloca %struct.AES_ctx, align 1
  %6 = icmp eq ptr %0, null
  %7 = icmp eq ptr %2, null
  %or.cond = or i1 %6, %7
  %8 = icmp eq ptr %3, null
  %or.cond3 = or i1 %or.cond, %8
  br i1 %or.cond3, label %81, label %9

9:                                                ; preds = %4
  %10 = tail call noalias ptr @fopen(ptr noundef nonnull %0, ptr noundef nonnull @.str)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %14

12:                                               ; preds = %9
  %13 = tail call i32 @fclose(ptr noundef null)
  br label %81

14:                                               ; preds = %9
  %15 = tail call i32 @fgetc(ptr noundef nonnull %10)
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %79

17:                                               ; preds = %14
  %18 = tail call ptr @llvm.stacksave.p0()
  %19 = alloca [20 x i8], align 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %19, i8 0, i64 20, i1 false)
  %20 = call i64 @fread(ptr noundef nonnull %19, i64 noundef 1, i64 noundef 20, ptr noundef nonnull %10)
  %21 = load i8, ptr %19, align 16, !tbaa !5
  %22 = zext i8 %21 to i32
  %23 = shl nuw i32 %22, 24
  %24 = getelementptr inbounds i8, ptr %19, i64 1
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = zext i8 %25 to i32
  %27 = shl nuw nsw i32 %26, 16
  %28 = or disjoint i32 %27, %23
  %29 = getelementptr inbounds i8, ptr %19, i64 2
  %30 = load i8, ptr %29, align 2, !tbaa !5
  %31 = zext i8 %30 to i32
  %32 = shl nuw nsw i32 %31, 8
  %33 = or disjoint i32 %28, %32
  %34 = getelementptr inbounds i8, ptr %19, i64 3
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = zext i8 %35 to i32
  %37 = or disjoint i32 %33, %36
  %38 = icmp slt i32 %37, 1
  br i1 %38, label %39, label %41

39:                                               ; preds = %17
  %40 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %78

41:                                               ; preds = %17
  %42 = zext nneg i32 %37 to i64
  %43 = tail call noalias ptr @malloc(i64 noundef %42) #8
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %47

45:                                               ; preds = %41
  %46 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %78

47:                                               ; preds = %41
  %48 = alloca [16384 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %5) #9
  call void @AES_init_ctx_iv(ptr noundef nonnull %5, ptr noundef nonnull %2, ptr noundef nonnull %3) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16384) %48, i8 0, i64 16384, i1 false)
  %49 = call i64 @fread(ptr noundef nonnull %48, i64 noundef 1, i64 noundef 16384, ptr noundef nonnull %10)
  %50 = trunc i64 %49 to i32
  %51 = icmp slt i32 %50, 1
  br i1 %51, label %._crit_edge, label %.lr.ph75

.lr.ph75:                                         ; preds = %47
  %invariant.gep = getelementptr inbounds i8, ptr %19, i64 4
  br label %52

52:                                               ; preds = %.lr.ph75, %.loopexit
  %53 = phi i32 [ %50, %.lr.ph75 ], [ %75, %.loopexit ]
  %54 = phi i64 [ %49, %.lr.ph75 ], [ %74, %.loopexit ]
  %.05574 = phi ptr [ %43, %.lr.ph75 ], [ %.156, %.loopexit ]
  %.05773.not = phi i1 [ false, %.lr.ph75 ], [ true, %.loopexit ]
  %.05972 = phi i64 [ 0, %.lr.ph75 ], [ %56, %.loopexit ]
  %55 = and i64 %54, 2147483647
  %56 = add nuw nsw i64 %55, %.05972
  %.not = icmp ult i32 %53, 1024
  %or.cond77 = or i1 %.05773.not, %.not
  br i1 %or.cond77, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %52
  %57 = lshr i32 %53, 10
  %wide.trip.count = zext nneg i32 %57 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2097150
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %59 = shl nsw i64 %indvars.iv, 10
  %60 = getelementptr inbounds i8, ptr %48, i64 %59
  %61 = load i8, ptr %60, align 16, !tbaa !5
  %gep = getelementptr inbounds i8, ptr %invariant.gep, i64 %indvars.iv
  %62 = load i8, ptr %gep, align 2, !tbaa !5
  store i8 %62, ptr %60, align 16, !tbaa !5
  store i8 %61, ptr %gep, align 2, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %63 = shl nsw i64 %indvars.iv.next, 10
  %64 = getelementptr inbounds i8, ptr %48, i64 %63
  %65 = load i8, ptr %64, align 16, !tbaa !5
  %gep.1 = getelementptr inbounds i8, ptr %invariant.gep, i64 %indvars.iv.next
  %66 = load i8, ptr %gep.1, align 1, !tbaa !5
  store i8 %66, ptr %64, align 16, !tbaa !5
  store i8 %65, ptr %gep.1, align 1, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !8

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa
  %67 = shl nsw i64 %indvars.iv.unr, 10
  %68 = getelementptr inbounds i8, ptr %48, i64 %67
  %69 = load i8, ptr %68, align 16, !tbaa !5
  %gep.epil = getelementptr inbounds i8, ptr %invariant.gep, i64 %indvars.iv.unr
  %70 = load i8, ptr %gep.epil, align 1, !tbaa !5
  store i8 %70, ptr %68, align 16, !tbaa !5
  store i8 %69, ptr %gep.epil, align 1, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.epil, %.loopexit.loopexit.unr-lcssa, %52
  call void @AES_CBC_decrypt_buffer(ptr noundef nonnull %5, ptr noundef nonnull %48, i32 noundef %53) #9
  %71 = icmp ult i64 %56, %42
  %.neg = add i64 %54, %42
  %72 = sub i64 %.neg, %56
  %sext = shl i64 %72, 32
  %73 = ashr exact i64 %sext, 32
  %.sink = select i1 %71, i64 %55, i64 %73
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.05574, ptr nonnull align 16 %48, i64 %.sink, i1 false)
  %.156 = getelementptr inbounds i8, ptr %.05574, i64 %.sink
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16384) %48, i8 0, i64 16384, i1 false)
  %74 = call i64 @fread(ptr noundef nonnull %48, i64 noundef 1, i64 noundef 16384, ptr noundef nonnull %10)
  %75 = trunc i64 %74 to i32
  %76 = icmp slt i32 %75, 1
  br i1 %76, label %._crit_edge, label %52

._crit_edge:                                      ; preds = %.loopexit, %47
  %77 = call i32 @fclose(ptr noundef nonnull %10)
  store ptr %43, ptr %1, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %5) #9
  br label %78

78:                                               ; preds = %45, %._crit_edge, %39
  %.1 = phi i32 [ -1, %39 ], [ -1, %45 ], [ 0, %._crit_edge ]
  call void @llvm.stackrestore.p0(ptr %18)
  br label %81

79:                                               ; preds = %14
  %80 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %81

81:                                               ; preds = %12, %79, %78, %4
  %.4 = phi i32 [ -1, %4 ], [ -1, %12 ], [ %.1, %78 ], [ -1, %79 ]
  ret i32 %.4
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #7

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


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