; 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.MD5_CTX = type { [2 x i32], [4 x i32], [64 x i8] }
%struct.AES_ctx = type { [176 x i8], [16 x i8] }

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 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

; 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 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 i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

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

; 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) #4

declare void @MD5Init(ptr noundef) #1

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

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

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

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

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

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

31:                                               ; preds = %28
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp sle i32 %32, 0
  br i1 %33, label %34, label %35

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

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

41:                                               ; preds = %35
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %188

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = add nsw i32 21, %43
  store i32 %44, ptr %11, align 4, !tbaa !9
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = srem i32 %45, 16
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %54

48:                                               ; preds = %42
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = srem i32 %49, 16
  %51 = sub nsw i32 16, %50
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = add nsw i32 %52, %51
  store i32 %53, ptr %11, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %48, %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 21, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 21, ptr %13) #6
  %55 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %55, i8 0, i64 21, i1 false)
  %56 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 0
  store i8 1, ptr %56, align 16, !tbaa !11
  %57 = call ptr @llvm.stacksave.p0()
  store ptr %57, ptr %14, align 8
  %58 = alloca i8, i64 16, align 16
  call void @llvm.lifetime.start.p0(i64 88, ptr %15) #6
  call void @MD5Init(ptr noundef %15)
  %59 = alloca i8, i64 16384, align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %60 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %60, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %61, ptr %18, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %71, %54
  %63 = load i32, ptr %17, align 4, !tbaa !9
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %65, label %84

65:                                               ; preds = %62
  call void @llvm.memset.p0.i64(ptr align 16 %59, i8 0, i64 16384, i1 false)
  %66 = load i32, ptr %17, align 4, !tbaa !9
  %67 = icmp slt i32 %66, 16384
  br i1 %67, label %68, label %70

68:                                               ; preds = %65
  %69 = load i32, ptr %17, align 4, !tbaa !9
  br label %71

70:                                               ; preds = %65
  br label %71

71:                                               ; preds = %70, %68
  %72 = phi i32 [ %69, %68 ], [ 16384, %70 ]
  store i32 %72, ptr %16, align 4, !tbaa !9
  %73 = load ptr, ptr %18, align 8, !tbaa !5
  %74 = load i32, ptr %16, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %59, ptr align 1 %73, i64 %75, i1 false)
  %76 = load i32, ptr %16, align 4, !tbaa !9
  call void @MD5Update(ptr noundef %15, ptr noundef %59, i32 noundef %76)
  %77 = load i32, ptr %16, align 4, !tbaa !9
  %78 = load i32, ptr %17, align 4, !tbaa !9
  %79 = sub nsw i32 %78, %77
  store i32 %79, ptr %17, align 4, !tbaa !9
  %80 = load i32, ptr %16, align 4, !tbaa !9
  %81 = load ptr, ptr %18, align 8, !tbaa !5
  %82 = sext i32 %80 to i64
  %83 = getelementptr inbounds i8, ptr %81, i64 %82
  store ptr %83, ptr %18, align 8, !tbaa !5
  br label %62, !llvm.loop !12

84:                                               ; preds = %62
  call void @MD5Final(ptr noundef %15, ptr noundef %58)
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = ashr i32 %85, 24
  %87 = and i32 %86, 255
  %88 = trunc i32 %87 to i8
  %89 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 1
  store i8 %88, ptr %89, align 1, !tbaa !11
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = ashr i32 %90, 16
  %92 = and i32 %91, 255
  %93 = trunc i32 %92 to i8
  %94 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 2
  store i8 %93, ptr %94, align 2, !tbaa !11
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = ashr i32 %95, 8
  %97 = and i32 %96, 255
  %98 = trunc i32 %97 to i8
  %99 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 3
  store i8 %98, ptr %99, align 1, !tbaa !11
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = and i32 %100, 255
  %102 = trunc i32 %101 to i8
  %103 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 4
  store i8 %102, ptr %103, align 4, !tbaa !11
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %104, ptr %18, align 8, !tbaa !5
  %105 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %105, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 192, ptr %19) #6
  call void @AES_init_ctx_iv(ptr noundef %19, ptr noundef @.str.2, ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #6
  store i8 1, ptr %20, align 1, !tbaa !14
  br label %106

106:                                              ; preds = %178, %84
  %107 = load i32, ptr %17, align 4, !tbaa !9
  %108 = icmp sgt i32 %107, 0
  br i1 %108, label %109, label %183

109:                                              ; preds = %106
  call void @llvm.memset.p0.i64(ptr align 16 %59, i8 0, i64 16384, i1 false)
  %110 = load i32, ptr %17, align 4, !tbaa !9
  %111 = icmp slt i32 %110, 16384
  br i1 %111, label %112, label %114

112:                                              ; preds = %109
  %113 = load i32, ptr %17, align 4, !tbaa !9
  br label %115

114:                                              ; preds = %109
  br label %115

115:                                              ; preds = %114, %112
  %116 = phi i32 [ %113, %112 ], [ 16384, %114 ]
  store i32 %116, ptr %16, align 4, !tbaa !9
  %117 = load ptr, ptr %18, align 8, !tbaa !5
  %118 = load i32, ptr %16, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %59, ptr align 1 %117, i64 %119, i1 false)
  %120 = load i32, ptr %16, align 4, !tbaa !9
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = sub nsw i32 %121, %120
  store i32 %122, ptr %17, align 4, !tbaa !9
  %123 = load i32, ptr %16, align 4, !tbaa !9
  %124 = load ptr, ptr %18, align 8, !tbaa !5
  %125 = sext i32 %123 to i64
  %126 = getelementptr inbounds i8, ptr %124, i64 %125
  store ptr %126, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %127 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %127, ptr %21, align 4, !tbaa !9
  %128 = load i32, ptr %16, align 4, !tbaa !9
  %129 = srem i32 %128, 16
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %137

131:                                              ; preds = %115
  %132 = load i32, ptr %16, align 4, !tbaa !9
  %133 = load i32, ptr %16, align 4, !tbaa !9
  %134 = srem i32 %133, 16
  %135 = sub nsw i32 16, %134
  %136 = add nsw i32 %132, %135
  store i32 %136, ptr %21, align 4, !tbaa !9
  br label %137

137:                                              ; preds = %131, %115
  %138 = load i32, ptr %21, align 4, !tbaa !9
  call void @AES_CBC_encrypt_buffer(ptr noundef %19, ptr noundef %59, i32 noundef %138)
  %139 = load i8, ptr %20, align 1, !tbaa !14, !range !16, !noundef !17
  %140 = trunc i8 %139 to i1
  br i1 %140, label %141, label %178

141:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %142 = load i32, ptr %21, align 4, !tbaa !9
  %143 = sdiv i32 %142, 1024
  store i32 %143, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %144

144:                                              ; preds = %167, %141
  %145 = load i32, ptr %23, align 4, !tbaa !9
  %146 = load i32, ptr %22, align 4, !tbaa !9
  %147 = icmp slt i32 %145, %146
  br i1 %147, label %149, label %148

148:                                              ; preds = %144
  store i32 6, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  br label %170

149:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #6
  %150 = load i32, ptr %23, align 4, !tbaa !9
  %151 = mul nsw i32 %150, 1024
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds i8, ptr %59, i64 %152
  %154 = load i8, ptr %153, align 1, !tbaa !11
  store i8 %154, ptr %24, align 1, !tbaa !11
  %155 = load i32, ptr %23, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds i8, ptr %58, i64 %156
  %158 = load i8, ptr %157, align 1, !tbaa !11
  %159 = load i32, ptr %23, align 4, !tbaa !9
  %160 = mul nsw i32 %159, 1024
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds i8, ptr %59, i64 %161
  store i8 %158, ptr %162, align 1, !tbaa !11
  %163 = load i8, ptr %24, align 1, !tbaa !11
  %164 = load i32, ptr %23, align 4, !tbaa !9
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds i8, ptr %58, i64 %165
  store i8 %163, ptr %166, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 1, ptr %24) #6
  br label %167

167:                                              ; preds = %149
  %168 = load i32, ptr %23, align 4, !tbaa !9
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %23, align 4, !tbaa !9
  br label %144, !llvm.loop !18

170:                                              ; preds = %148
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %171 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 5
  store ptr %171, ptr %25, align 8, !tbaa !5
  %172 = load ptr, ptr %25, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %172, ptr align 16 %58, i64 16, i1 false)
  %173 = load ptr, ptr %9, align 8, !tbaa !5
  %174 = call i32 @fseek(ptr noundef %173, i64 noundef 0, i32 noundef 0)
  %175 = getelementptr inbounds [21 x i8], ptr %13, i64 0, i64 0
  %176 = load ptr, ptr %9, align 8, !tbaa !5
  %177 = call i64 @fwrite(ptr noundef %175, i64 noundef 1, i64 noundef 21, ptr noundef %176)
  store i8 0, ptr %20, align 1, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  br label %178

178:                                              ; preds = %170, %137
  %179 = load i32, ptr %21, align 4, !tbaa !9
  %180 = sext i32 %179 to i64
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = call i64 @fwrite(ptr noundef %59, i64 noundef 1, i64 noundef %180, ptr noundef %181)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %106, !llvm.loop !19

183:                                              ; preds = %106
  %184 = load ptr, ptr %9, align 8, !tbaa !5
  %185 = call i32 @fclose(ptr noundef %184)
  %186 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %186, ptr %4, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 192, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 88, ptr %15) #6
  %187 = load ptr, ptr %14, align 8
  call void @llvm.stackrestore.p0(ptr %187)
  call void @llvm.lifetime.end.p0(i64 21, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %188

188:                                              ; preds = %183, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %189

189:                                              ; preds = %188, %34
  %190 = load i32, ptr %4, align 4
  ret i32 %190
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !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"

%struct.MD5_CTX = type { [2 x i32], [4 x i32], [64 x i8] }
%struct.AES_ctx = type { [176 x i8], [16 x i8] }

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 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: 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

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

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

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

; 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) #5

declare void @MD5Init(ptr noundef) local_unnamed_addr #4

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, -2147483648) i32 @AOECrypto_encryptAoeDataToFile_Version1(ptr noundef readonly %0, i32 noundef %1, ptr noundef readonly %2) local_unnamed_addr #6 {
  %4 = alloca [21 x i8], align 16
  %5 = alloca %struct.MD5_CTX, align 4
  %6 = alloca %struct.AES_ctx, align 1
  %7 = icmp eq ptr %0, null
  %8 = icmp eq ptr %2, null
  %or.cond = or i1 %7, %8
  %9 = icmp slt i32 %1, 1
  %or.cond3 = or i1 %9, %or.cond
  br i1 %or.cond3, label %69, label %10

10:                                               ; preds = %3
  %11 = tail call noalias ptr @fopen(ptr noundef nonnull %2, ptr noundef nonnull @.str.1)
  %12 = icmp eq ptr %11, null
  br i1 %12, label %69, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %10
  %13 = add nuw nsw i32 %1, 21
  %14 = and i32 %1, 15
  %.not = icmp eq i32 %14, 0
  %15 = and i32 %1, 2147483632
  %16 = add nuw i32 %15, 37
  %.064 = select i1 %.not, i32 %13, i32 %16
  call void @llvm.lifetime.start.p0(i64 21, ptr nonnull %4) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(21) %4, i8 0, i64 21, i1 false)
  store i8 1, ptr %4, align 16, !tbaa !5
  %17 = tail call ptr @llvm.stacksave.p0()
  %18 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %5) #8
  call void @MD5Init(ptr noundef nonnull %5) #8
  %19 = alloca [16384 x i8], align 16
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.06880 = phi ptr [ %23, %.lr.ph ], [ %0, %.lr.ph.preheader ]
  %.07079 = phi i32 [ %22, %.lr.ph ], [ %1, %.lr.ph.preheader ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16384) %19, i8 0, i64 16384, i1 false)
  %20 = call i32 @llvm.umin.i32(i32 %.07079, i32 16384)
  %21 = zext nneg i32 %20 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %19, ptr noundef nonnull align 1 dereferenceable(1) %.06880, i64 %21, i1 false)
  call void @MD5Update(ptr noundef nonnull %5, ptr noundef nonnull %19, i32 noundef %20) #8
  %22 = sub nsw i32 %.07079, %20
  %23 = getelementptr inbounds i8, ptr %.06880, i64 %21
  %24 = icmp sgt i32 %22, 0
  br i1 %24, label %.lr.ph, label %.lr.ph89, !llvm.loop !8

.lr.ph89:                                         ; preds = %.lr.ph
  call void @MD5Final(ptr noundef nonnull %5, ptr noundef nonnull %18) #8
  %25 = lshr i32 %1, 24
  %26 = trunc nuw nsw i32 %25 to i8
  %27 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 %26, ptr %27, align 1, !tbaa !5
  %28 = lshr i32 %1, 16
  %29 = trunc i32 %28 to i8
  %30 = getelementptr inbounds i8, ptr %4, i64 2
  store i8 %29, ptr %30, align 2, !tbaa !5
  %31 = lshr i32 %1, 8
  %32 = trunc i32 %31 to i8
  %33 = getelementptr inbounds i8, ptr %4, i64 3
  store i8 %32, ptr %33, align 1, !tbaa !5
  %34 = trunc i32 %1 to i8
  %35 = getelementptr inbounds i8, ptr %4, i64 4
  store i8 %34, ptr %35, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %6) #8
  call void @AES_init_ctx_iv(ptr noundef nonnull %6, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3) #8
  %36 = getelementptr inbounds i8, ptr %4, i64 5
  br label %37

37:                                               ; preds = %.lr.ph89, %64
  %.06687 = phi i1 [ true, %.lr.ph89 ], [ false, %64 ]
  %.16986 = phi ptr [ %0, %.lr.ph89 ], [ %41, %64 ]
  %.17185 = phi i32 [ %1, %.lr.ph89 ], [ %40, %64 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16384) %19, i8 0, i64 16384, i1 false)
  %38 = call i32 @llvm.umin.i32(i32 %.17185, i32 16384)
  %39 = zext nneg i32 %38 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %19, ptr align 1 %.16986, i64 %39, i1 false)
  %40 = sub nsw i32 %.17185, %38
  %41 = getelementptr inbounds i8, ptr %.16986, i64 %39
  %42 = and i32 %38, 15
  %.not78 = icmp eq i32 %42, 0
  %reass.sub = and i32 %38, 32752
  %43 = add nuw nsw i32 %reass.sub, 16
  %.065 = select i1 %.not78, i32 %38, i32 %43
  call void @AES_CBC_encrypt_buffer(ptr noundef nonnull %6, ptr noundef nonnull %19, i32 noundef %.065) #8
  br i1 %.06687, label %44, label %64

44:                                               ; preds = %37
  %.not91 = icmp ult i32 %.065, 1024
  br i1 %.not91, label %._crit_edge84, label %.lr.ph83.preheader

.lr.ph83.preheader:                               ; preds = %44
  %45 = lshr i32 %.065, 10
  %wide.trip.count = zext nneg i32 %45 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %._crit_edge84.loopexit.unr-lcssa, label %.lr.ph83.preheader.new

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

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

.lr.ph83.epil:                                    ; preds = %._crit_edge84.loopexit.unr-lcssa
  %47 = shl nsw i64 %indvars.iv.unr, 10
  %48 = getelementptr inbounds i8, ptr %19, i64 %47
  %49 = load i8, ptr %48, align 16, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %18, i64 %indvars.iv.unr
  %51 = load i8, ptr %50, align 1, !tbaa !5
  store i8 %51, ptr %48, align 16, !tbaa !5
  store i8 %49, ptr %50, align 1, !tbaa !5
  br label %._crit_edge84

._crit_edge84:                                    ; preds = %.lr.ph83.epil, %._crit_edge84.loopexit.unr-lcssa, %44
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) %36, ptr noundef nonnull align 16 dereferenceable(16) %18, i64 16, i1 false)
  %52 = call i32 @fseek(ptr noundef nonnull %11, i64 noundef 0, i32 noundef 0)
  %53 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 21, ptr noundef nonnull %11)
  br label %64

.lr.ph83:                                         ; preds = %.lr.ph83, %.lr.ph83.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph83.preheader.new ], [ %indvars.iv.next.1, %.lr.ph83 ]
  %niter = phi i64 [ 0, %.lr.ph83.preheader.new ], [ %niter.next.1, %.lr.ph83 ]
  %54 = shl nsw i64 %indvars.iv, 10
  %55 = getelementptr inbounds i8, ptr %19, i64 %54
  %56 = load i8, ptr %55, align 16, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %18, i64 %indvars.iv
  %58 = load i8, ptr %57, align 2, !tbaa !5
  store i8 %58, ptr %55, align 16, !tbaa !5
  store i8 %56, ptr %57, align 2, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %59 = shl nsw i64 %indvars.iv.next, 10
  %60 = getelementptr inbounds i8, ptr %19, i64 %59
  %61 = load i8, ptr %60, align 16, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %18, i64 %indvars.iv.next
  %63 = load i8, ptr %62, align 1, !tbaa !5
  store i8 %63, ptr %60, align 16, !tbaa !5
  store i8 %61, ptr %62, 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 %._crit_edge84.loopexit.unr-lcssa, label %.lr.ph83, !llvm.loop !10

64:                                               ; preds = %._crit_edge84, %37
  %65 = zext nneg i32 %.065 to i64
  %66 = call i64 @fwrite(ptr noundef nonnull %19, i64 noundef 1, i64 noundef %65, ptr noundef nonnull %11)
  %67 = icmp sgt i32 %40, 0
  br i1 %67, label %37, label %._crit_edge90, !llvm.loop !11

._crit_edge90:                                    ; preds = %64
  %68 = call i32 @fclose(ptr noundef nonnull %11)
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %5) #8
  call void @llvm.stackrestore.p0(ptr %17)
  call void @llvm.lifetime.end.p0(i64 21, ptr nonnull %4) #8
  br label %69

69:                                               ; preds = %._crit_edge90, %10, %3
  %.1 = phi i32 [ -1, %3 ], [ %.064, %._crit_edge90 ], [ -1, %10 ]
  ret i32 %.1
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = distinct !{!10, !9}
!11 = distinct !{!11, !9}


; 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