; LLVM IR from PacktPublishing/Demystifying-Cryptography-with-OpenSSL-3 :: Chapter02 (decrypt-with-extended-error-checking)

; 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.11 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [31 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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @decrypt(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !11
  %27 = call ptr @llvm.stacksave.p0()
  store ptr %27, ptr %13, align 8
  %28 = alloca i8, i64 12, align 16
  %29 = alloca i8, i64 16, align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 65536, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 16, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %30 = call noalias ptr @malloc(i64 noundef 65536) #7
  store ptr %30, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %31 = call noalias ptr @malloc(i64 noundef 65552) #7
  store ptr %31, ptr %18, align 8, !tbaa !5
  %32 = load ptr, ptr %17, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %5
  %35 = load ptr, ptr %18, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %44, label %37

37:                                               ; preds = %34, %5
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.11) #6
  br label %43

43:                                               ; preds = %40, %37
  br label %211

44:                                               ; preds = %34
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call i64 @fread(ptr noundef %28, i64 noundef 1, i64 noundef 12, ptr noundef %45)
  store i64 %46, ptr %19, align 8, !tbaa !9
  %47 = load i64, ptr %19, align 8, !tbaa !9
  %48 = icmp ne i64 %47, 12
  br i1 %48, label %53, label %49

49:                                               ; preds = %44
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = call i32 @ferror(ptr noundef %50) #6
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %60

53:                                               ; preds = %49, %44
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %59

56:                                               ; preds = %53
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef @.str.12) #6
  br label %59

59:                                               ; preds = %56, %53
  br label %211

60:                                               ; preds = %49
  %61 = load i64, ptr %19, align 8, !tbaa !9
  store i64 %61, ptr %20, align 8, !tbaa !9
  %62 = call ptr @EVP_CIPHER_CTX_new()
  store ptr %62, ptr %14, align 8, !tbaa !5
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = call ptr @EVP_aes_256_gcm()
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = call i32 @EVP_DecryptInit(ptr noundef %63, ptr noundef %64, ptr noundef %65, ptr noundef %28)
  store i32 %66, ptr %21, align 4, !tbaa !11
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %72

69:                                               ; preds = %60
  %70 = load i32, ptr %21, align 4, !tbaa !11
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %79, label %72

72:                                               ; preds = %69, %60
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %75, label %78

75:                                               ; preds = %72
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef @.str.13) #6
  br label %78

78:                                               ; preds = %75, %72
  br label %211

79:                                               ; preds = %69
  br label %80

80:                                               ; preds = %152, %79
  %81 = load i64, ptr %20, align 8, !tbaa !9
  %82 = load i64, ptr %10, align 8, !tbaa !9
  %83 = icmp ult i64 %81, %82
  br i1 %83, label %84, label %153

84:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %85 = load i64, ptr %10, align 8, !tbaa !9
  %86 = load i64, ptr %20, align 8, !tbaa !9
  %87 = sub i64 %85, %86
  store i64 %87, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %88 = load i64, ptr %22, align 8, !tbaa !9
  %89 = icmp ult i64 %88, 65536
  br i1 %89, label %90, label %92

90:                                               ; preds = %84
  %91 = load i64, ptr %22, align 8, !tbaa !9
  br label %93

92:                                               ; preds = %84
  br label %93

93:                                               ; preds = %92, %90
  %94 = phi i64 [ %91, %90 ], [ 65536, %92 ]
  store i64 %94, ptr %23, align 8, !tbaa !9
  %95 = load ptr, ptr %17, align 8, !tbaa !5
  %96 = load i64, ptr %23, align 8, !tbaa !9
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = call i64 @fread(ptr noundef %95, i64 noundef 1, i64 noundef %96, ptr noundef %97)
  store i64 %98, ptr %19, align 8, !tbaa !9
  %99 = load i64, ptr %19, align 8, !tbaa !9
  %100 = load i64, ptr %23, align 8, !tbaa !9
  %101 = icmp ne i64 %99, %100
  br i1 %101, label %106, label %102

102:                                              ; preds = %93
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = call i32 @ferror(ptr noundef %103) #6
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %113

106:                                              ; preds = %102, %93
  %107 = load ptr, ptr %11, align 8, !tbaa !5
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %112

109:                                              ; preds = %106
  %110 = load ptr, ptr %11, align 8, !tbaa !5
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %110, ptr noundef @.str.14) #6
  br label %112

112:                                              ; preds = %109, %106
  store i32 2, ptr %25, align 4
  br label %150

113:                                              ; preds = %102
  %114 = load i64, ptr %19, align 8, !tbaa !9
  %115 = load i64, ptr %20, align 8, !tbaa !9
  %116 = add i64 %115, %114
  store i64 %116, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  store i32 0, ptr %24, align 4, !tbaa !11
  %117 = load ptr, ptr %14, align 8, !tbaa !5
  %118 = load ptr, ptr %18, align 8, !tbaa !5
  %119 = load ptr, ptr %17, align 8, !tbaa !5
  %120 = load i64, ptr %19, align 8, !tbaa !9
  %121 = trunc i64 %120 to i32
  %122 = call i32 @EVP_DecryptUpdate(ptr noundef %117, ptr noundef %118, ptr noundef %24, ptr noundef %119, i32 noundef %121)
  store i32 %122, ptr %21, align 4, !tbaa !11
  %123 = load i32, ptr %21, align 4, !tbaa !11
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %132, label %125

125:                                              ; preds = %113
  %126 = load ptr, ptr %11, align 8, !tbaa !5
  %127 = icmp ne ptr %126, null
  br i1 %127, label %128, label %131

128:                                              ; preds = %125
  %129 = load ptr, ptr %11, align 8, !tbaa !5
  %130 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %129, ptr noundef @.str.15) #6
  br label %131

131:                                              ; preds = %128, %125
  store i32 2, ptr %25, align 4
  br label %149

132:                                              ; preds = %113
  %133 = load ptr, ptr %18, align 8, !tbaa !5
  %134 = load i32, ptr %24, align 4, !tbaa !11
  %135 = sext i32 %134 to i64
  %136 = load ptr, ptr %8, align 8, !tbaa !5
  %137 = call i64 @fwrite(ptr noundef %133, i64 noundef 1, i64 noundef %135, ptr noundef %136)
  %138 = load ptr, ptr %8, align 8, !tbaa !5
  %139 = call i32 @ferror(ptr noundef %138) #6
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %148

141:                                              ; preds = %132
  %142 = load ptr, ptr %11, align 8, !tbaa !5
  %143 = icmp ne ptr %142, null
  br i1 %143, label %144, label %147

144:                                              ; preds = %141
  %145 = load ptr, ptr %11, align 8, !tbaa !5
  %146 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %145, ptr noundef @.str.16) #6
  br label %147

147:                                              ; preds = %144, %141
  store i32 2, ptr %25, align 4
  br label %149

148:                                              ; preds = %132
  store i32 0, ptr %25, align 4
  br label %149

149:                                              ; preds = %148, %147, %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  br label %150

150:                                              ; preds = %149, %112
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  %151 = load i32, ptr %25, align 4
  switch i32 %151, label %217 [
    i32 0, label %152
    i32 2, label %211
  ]

152:                                              ; preds = %150
  br label %80, !llvm.loop !13

153:                                              ; preds = %80
  %154 = load ptr, ptr %7, align 8, !tbaa !5
  %155 = call i64 @fread(ptr noundef %29, i64 noundef 1, i64 noundef 16, ptr noundef %154)
  store i64 %155, ptr %19, align 8, !tbaa !9
  %156 = load i64, ptr %19, align 8, !tbaa !9
  %157 = icmp ne i64 %156, 16
  br i1 %157, label %162, label %158

158:                                              ; preds = %153
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = call i32 @ferror(ptr noundef %159) #6
  %161 = icmp ne i32 %160, 0
  br i1 %161, label %162, label %169

162:                                              ; preds = %158, %153
  %163 = load ptr, ptr %11, align 8, !tbaa !5
  %164 = icmp ne ptr %163, null
  br i1 %164, label %165, label %168

165:                                              ; preds = %162
  %166 = load ptr, ptr %11, align 8, !tbaa !5
  %167 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %166, ptr noundef @.str.17) #6
  br label %168

168:                                              ; preds = %165, %162
  br label %211

169:                                              ; preds = %158
  %170 = load ptr, ptr %14, align 8, !tbaa !5
  %171 = call i32 @EVP_CIPHER_CTX_ctrl(ptr noundef %170, i32 noundef 17, i32 noundef 16, ptr noundef %29)
  store i32 %171, ptr %21, align 4, !tbaa !11
  %172 = load i32, ptr %21, align 4, !tbaa !11
  %173 = icmp ne i32 %172, 0
  br i1 %173, label %181, label %174

174:                                              ; preds = %169
  %175 = load ptr, ptr %11, align 8, !tbaa !5
  %176 = icmp ne ptr %175, null
  br i1 %176, label %177, label %180

177:                                              ; preds = %174
  %178 = load ptr, ptr %11, align 8, !tbaa !5
  %179 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %178, ptr noundef @.str.18) #6
  br label %180

180:                                              ; preds = %177, %174
  store i32 1, ptr %12, align 4, !tbaa !11
  br label %211

181:                                              ; preds = %169
  store i32 0, ptr %26, align 4, !tbaa !11
  %182 = load ptr, ptr %14, align 8, !tbaa !5
  %183 = load ptr, ptr %18, align 8, !tbaa !5
  %184 = call i32 @EVP_DecryptFinal(ptr noundef %182, ptr noundef %183, ptr noundef %26)
  store i32 %184, ptr %21, align 4, !tbaa !11
  %185 = load i32, ptr %21, align 4, !tbaa !11
  %186 = icmp ne i32 %185, 0
  br i1 %186, label %194, label %187

187:                                              ; preds = %181
  %188 = load ptr, ptr %11, align 8, !tbaa !5
  %189 = icmp ne ptr %188, null
  br i1 %189, label %190, label %193

190:                                              ; preds = %187
  %191 = load ptr, ptr %11, align 8, !tbaa !5
  %192 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %191, ptr noundef @.str.19) #6
  br label %193

193:                                              ; preds = %190, %187
  br label %211

194:                                              ; preds = %181
  %195 = load ptr, ptr %18, align 8, !tbaa !5
  %196 = load i32, ptr %26, align 4, !tbaa !11
  %197 = sext i32 %196 to i64
  %198 = load ptr, ptr %8, align 8, !tbaa !5
  %199 = call i64 @fwrite(ptr noundef %195, i64 noundef 1, i64 noundef %197, ptr noundef %198)
  %200 = load ptr, ptr %8, align 8, !tbaa !5
  %201 = call i32 @ferror(ptr noundef %200) #6
  %202 = icmp ne i32 %201, 0
  br i1 %202, label %203, label %210

203:                                              ; preds = %194
  %204 = load ptr, ptr %11, align 8, !tbaa !5
  %205 = icmp ne ptr %204, null
  br i1 %205, label %206, label %209

206:                                              ; preds = %203
  %207 = load ptr, ptr %11, align 8, !tbaa !5
  %208 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %207, ptr noundef @.str.16) #6
  br label %209

209:                                              ; preds = %206, %203
  br label %211

210:                                              ; preds = %194
  br label %212

211:                                              ; preds = %209, %193, %180, %168, %150, %78, %59, %43
  store i32 1, ptr %12, align 4, !tbaa !11
  br label %212

212:                                              ; preds = %211, %210
  %213 = load ptr, ptr %14, align 8, !tbaa !5
  call void @EVP_CIPHER_CTX_free(ptr noundef %213)
  %214 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %214) #6
  %215 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %215) #6
  %216 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %216, ptr %6, align 4
  store i32 1, ptr %25, align 4
  br label %217

217:                                              ; preds = %212, %150
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  %218 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %218)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %219 = load i32, ptr %6, align 4
  ret i32 %219
}

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

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

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

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

; Function Attrs: nounwind
declare i32 @ferror(ptr noundef) #1

declare ptr @EVP_CIPHER_CTX_new() #5

declare i32 @EVP_DecryptInit(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

declare ptr @EVP_aes_256_gcm() #5

declare i32 @EVP_DecryptUpdate(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #5

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

declare i32 @EVP_CIPHER_CTX_ctrl(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #5

declare i32 @EVP_DecryptFinal(ptr noundef, ptr noundef, ptr noundef) #5

declare void @EVP_CIPHER_CTX_free(ptr noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
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 = { "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 }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.11 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [31 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 noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @decrypt(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [12 x i8], align 16
  %9 = alloca [16 x i8], align 16
  %10 = tail call noalias dereferenceable_or_null(65536) ptr @malloc(i64 noundef 65536) #8
  %11 = tail call noalias dereferenceable_or_null(65552) ptr @malloc(i64 noundef 65552) #8
  %12 = icmp ne ptr %10, null
  %13 = icmp ne ptr %11, null
  %or.cond = and i1 %12, %13
  br i1 %or.cond, label %17, label %14

14:                                               ; preds = %5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.thread, label %15

15:                                               ; preds = %14
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.11) #9
  br label %.thread

17:                                               ; preds = %5
  %18 = call i64 @fread(ptr noundef nonnull %8, i64 noundef 1, i64 noundef 12, ptr noundef %0)
  %.not85 = icmp eq i64 %18, 12
  br i1 %.not85, label %19, label %21

19:                                               ; preds = %17
  %20 = tail call i32 @ferror(ptr noundef %0) #9
  %.not86 = icmp eq i32 %20, 0
  br i1 %.not86, label %24, label %21

21:                                               ; preds = %19, %17
  %.not104 = icmp eq ptr %4, null
  br i1 %.not104, label %.thread, label %22

22:                                               ; preds = %21
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.12) #9
  br label %.thread

24:                                               ; preds = %19
  %25 = tail call ptr @EVP_CIPHER_CTX_new() #9
  %26 = tail call ptr @EVP_aes_256_gcm() #9
  %27 = call i32 @EVP_DecryptInit(ptr noundef %25, ptr noundef %26, ptr noundef %2, ptr noundef nonnull %8) #9
  %28 = icmp ne ptr %25, null
  %29 = icmp ne i32 %27, 0
  %or.cond3 = select i1 %28, i1 %29, i1 false
  br i1 %or.cond3, label %.preheader, label %31

.preheader:                                       ; preds = %24
  %30 = icmp ugt i64 %3, 12
  br i1 %30, label %.lr.ph, label %._crit_edge

31:                                               ; preds = %24
  %.not87 = icmp eq ptr %4, null
  br i1 %.not87, label %.thread, label %32

32:                                               ; preds = %31
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.13) #9
  br label %.thread

.lr.ph:                                           ; preds = %.preheader, %54
  %.074110 = phi i64 [ %43, %54 ], [ 12, %.preheader ]
  %34 = sub i64 %3, %.074110
  %35 = call i64 @llvm.umin.i64(i64 %34, i64 65536)
  %36 = call i64 @fread(ptr noundef nonnull %10, i64 noundef 1, i64 noundef %35, ptr noundef %0)
  %.not97 = icmp eq i64 %36, %35
  br i1 %.not97, label %37, label %39

37:                                               ; preds = %.lr.ph
  %38 = call i32 @ferror(ptr noundef %0) #9
  %.not98 = icmp eq i32 %38, 0
  br i1 %.not98, label %42, label %39

39:                                               ; preds = %37, %.lr.ph
  %.not103 = icmp eq ptr %4, null
  br i1 %.not103, label %.thread, label %40

40:                                               ; preds = %39
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.14) #9
  br label %.thread

42:                                               ; preds = %37
  %43 = add i64 %35, %.074110
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  store i32 0, ptr %6, align 4, !tbaa !5
  %44 = trunc nuw nsw i64 %35 to i32
  %45 = call i32 @EVP_DecryptUpdate(ptr noundef nonnull %25, ptr noundef nonnull %11, ptr noundef nonnull %6, ptr noundef nonnull %10, i32 noundef %44) #9
  %.not99 = icmp eq i32 %45, 0
  br i1 %.not99, label %46, label %47

46:                                               ; preds = %42
  %.not100 = icmp eq ptr %4, null
  br i1 %.not100, label %.thread108, label %.thread108.sink.split

47:                                               ; preds = %42
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = call i64 @fwrite(ptr noundef nonnull %11, i64 noundef 1, i64 noundef %49, ptr noundef %1)
  %51 = call i32 @ferror(ptr noundef %1) #9
  %.not101 = icmp eq i32 %51, 0
  br i1 %.not101, label %54, label %52

52:                                               ; preds = %47
  %.not102 = icmp eq ptr %4, null
  br i1 %.not102, label %.thread108, label %.thread108.sink.split

.thread108.sink.split:                            ; preds = %52, %46
  %.str.15.sink = phi ptr [ @.str.15, %46 ], [ @.str.16, %52 ]
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull %.str.15.sink) #9
  br label %.thread108

.thread108:                                       ; preds = %.thread108.sink.split, %46, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  br label %.thread

54:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  %55 = icmp ult i64 %43, %3
  br i1 %55, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %54, %.preheader
  %56 = call i64 @fread(ptr noundef nonnull %9, i64 noundef 1, i64 noundef 16, ptr noundef %0)
  %.not88 = icmp eq i64 %56, 16
  br i1 %.not88, label %57, label %59

57:                                               ; preds = %._crit_edge
  %58 = call i32 @ferror(ptr noundef %0) #9
  %.not89 = icmp eq i32 %58, 0
  br i1 %.not89, label %62, label %59

59:                                               ; preds = %57, %._crit_edge
  %.not96 = icmp eq ptr %4, null
  br i1 %.not96, label %.thread, label %60

60:                                               ; preds = %59
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.17) #9
  br label %.thread

62:                                               ; preds = %57
  %63 = call i32 @EVP_CIPHER_CTX_ctrl(ptr noundef nonnull %25, i32 noundef 17, i32 noundef 16, ptr noundef nonnull %9) #9
  %.not90 = icmp eq i32 %63, 0
  br i1 %.not90, label %64, label %67

64:                                               ; preds = %62
  %.not91 = icmp eq ptr %4, null
  br i1 %.not91, label %.thread, label %65

65:                                               ; preds = %64
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.18) #9
  br label %.thread

67:                                               ; preds = %62
  store i32 0, ptr %7, align 4, !tbaa !5
  %68 = call i32 @EVP_DecryptFinal(ptr noundef nonnull %25, ptr noundef nonnull %11, ptr noundef nonnull %7) #9
  %.not92 = icmp eq i32 %68, 0
  br i1 %.not92, label %69, label %72

69:                                               ; preds = %67
  %.not93 = icmp eq ptr %4, null
  br i1 %.not93, label %.thread, label %70

70:                                               ; preds = %69
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.19) #9
  br label %.thread

72:                                               ; preds = %67
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = call i64 @fwrite(ptr noundef nonnull %11, i64 noundef 1, i64 noundef %74, ptr noundef %1)
  %76 = call i32 @ferror(ptr noundef %1) #9
  %.not94 = icmp eq i32 %76, 0
  br i1 %.not94, label %.thread, label %77

77:                                               ; preds = %72
  %.not95 = icmp eq ptr %4, null
  br i1 %.not95, label %.thread, label %78

78:                                               ; preds = %77
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.16) #9
  br label %.thread

.thread:                                          ; preds = %39, %40, %72, %64, %65, %77, %78, %69, %70, %59, %60, %31, %32, %21, %22, %14, %15, %.thread108
  %.177 = phi ptr [ %25, %72 ], [ null, %22 ], [ null, %21 ], [ %25, %60 ], [ %25, %59 ], [ %25, %78 ], [ %25, %77 ], [ %25, %70 ], [ %25, %69 ], [ %25, %32 ], [ %25, %31 ], [ null, %15 ], [ null, %14 ], [ %25, %65 ], [ %25, %64 ], [ %25, %.thread108 ], [ %25, %40 ], [ %25, %39 ]
  %.073 = phi i32 [ 0, %72 ], [ 1, %22 ], [ 1, %21 ], [ 1, %60 ], [ 1, %59 ], [ 1, %78 ], [ 1, %77 ], [ 1, %70 ], [ 1, %69 ], [ 1, %32 ], [ 1, %31 ], [ 1, %15 ], [ 1, %14 ], [ 1, %65 ], [ 1, %64 ], [ 1, %.thread108 ], [ 1, %40 ], [ 1, %39 ]
  call void @EVP_CIPHER_CTX_free(ptr noundef %.177) #9
  call void @free(ptr noundef %11) #9
  call void @free(ptr noundef %10) #9
  ret i32 %.073
}

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

; 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: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

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

declare ptr @EVP_CIPHER_CTX_new() local_unnamed_addr #5

declare i32 @EVP_DecryptInit(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare ptr @EVP_aes_256_gcm() local_unnamed_addr #5

declare i32 @EVP_DecryptUpdate(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

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

declare i32 @EVP_CIPHER_CTX_ctrl(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

declare i32 @EVP_DecryptFinal(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @EVP_CIPHER_CTX_free(ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { nofree nounwind 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 = { "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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass