; LLVM IR from openanolis/openssl :: demos/cipher (ariacbc)

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

@libctx = external dso_local global ptr, align 8
@propq = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@stdout = external global ptr, align 8
@cbc_pt = external hidden constant [16 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@cbc_key = external hidden constant [32 x i8], align 16
@cbc_iv = external hidden constant [16 x i8], align 16
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@cbc_ct = external hidden constant [32 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [51 x i8], align 1
@stderr = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @aria_cbc_encrypt() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca [1024 x i8], align 16
  %8 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store ptr null, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 16, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1024, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %11 = load ptr, ptr @stdout, align 8, !tbaa !9
  %12 = call i32 @BIO_dump_fp(ptr noundef %11, ptr noundef @cbc_pt, i32 noundef 16)
  %13 = call ptr @EVP_CIPHER_CTX_new()
  store ptr %13, ptr %2, align 8, !tbaa !9
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %0
  br label %67

16:                                               ; preds = %0
  %17 = load ptr, ptr @libctx, align 8, !tbaa !9
  %18 = load ptr, ptr @propq, align 8, !tbaa !9
  %19 = call ptr @EVP_CIPHER_fetch(ptr noundef %17, ptr noundef @.str.2, ptr noundef %18)
  store ptr %19, ptr %3, align 8, !tbaa !9
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  br label %67

22:                                               ; preds = %16
  %23 = load ptr, ptr %2, align 8, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = call i32 @EVP_EncryptInit_ex2(ptr noundef %23, ptr noundef %24, ptr noundef @cbc_key, ptr noundef @cbc_iv, ptr noundef null)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  br label %67

28:                                               ; preds = %22
  %29 = load ptr, ptr %2, align 8, !tbaa !9
  %30 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %31 = call i32 @EVP_EncryptUpdate(ptr noundef %29, ptr noundef %30, ptr noundef %4, ptr noundef @cbc_pt, i32 noundef 16)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  br label %67

34:                                               ; preds = %28
  %35 = load ptr, ptr %2, align 8, !tbaa !9
  %36 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %36, i64 %38
  %40 = call i32 @EVP_EncryptFinal_ex(ptr noundef %35, ptr noundef %39, ptr noundef %5)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %34
  br label %67

43:                                               ; preds = %34
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %47)
  %49 = load ptr, ptr @stdout, align 8, !tbaa !9
  %50 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = call i32 @BIO_dump_fp(ptr noundef %49, ptr noundef %50, i32 noundef %51)
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = icmp eq i64 32, %54
  br i1 %55, label %56, label %64

56:                                               ; preds = %43
  %57 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = call i32 @CRYPTO_memcmp(ptr noundef %57, ptr noundef @cbc_ct, i64 noundef %59)
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %64, label %62

62:                                               ; preds = %56
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %66

64:                                               ; preds = %56, %43
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %66

66:                                               ; preds = %64, %62
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %66, %42, %33, %27, %21, %15
  %68 = load i32, ptr %1, align 4, !tbaa !5
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %72, label %70

70:                                               ; preds = %67
  %71 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void @ERR_print_errors_fp(ptr noundef %71)
  br label %72

72:                                               ; preds = %70, %67
  %73 = load ptr, ptr %3, align 8, !tbaa !9
  call void @EVP_CIPHER_free(ptr noundef %73)
  %74 = load ptr, ptr %2, align 8, !tbaa !9
  call void @EVP_CIPHER_CTX_free(ptr noundef %74)
  %75 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1024, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret i32 %75
}

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

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

declare i32 @BIO_dump_fp(ptr noundef, ptr noundef, i32 noundef) #2

declare ptr @EVP_CIPHER_CTX_new() #2

declare ptr @EVP_CIPHER_fetch(ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @EVP_EncryptInit_ex2(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @EVP_EncryptUpdate(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @EVP_EncryptFinal_ex(ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @CRYPTO_memcmp(ptr noundef, ptr noundef, i64 noundef) #2

declare void @ERR_print_errors_fp(ptr noundef) #2

declare void @EVP_CIPHER_free(ptr noundef) #2

declare void @EVP_CIPHER_CTX_free(ptr noundef) #2

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

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 = { "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 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


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

@libctx = external dso_local local_unnamed_addr global ptr, align 8
@propq = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@cbc_pt = external hidden constant [16 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@cbc_key = external hidden constant [32 x i8], align 16
@cbc_iv = external hidden constant [16 x i8], align 16
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@cbc_ct = external hidden constant [32 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [51 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @aria_cbc_encrypt() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #4
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = tail call i32 @BIO_dump_fp(ptr noundef %6, ptr noundef nonnull @cbc_pt, i32 noundef 16) #4
  %8 = tail call ptr @EVP_CIPHER_CTX_new() #4
  %9 = icmp eq ptr %8, null
  br i1 %9, label %40, label %10

10:                                               ; preds = %0
  %11 = load ptr, ptr @libctx, align 8, !tbaa !5
  %12 = load ptr, ptr @propq, align 8, !tbaa !5
  %13 = tail call ptr @EVP_CIPHER_fetch(ptr noundef %11, ptr noundef nonnull @.str.2, ptr noundef %12) #4
  %14 = icmp eq ptr %13, null
  br i1 %14, label %40, label %15

15:                                               ; preds = %10
  %16 = tail call i32 @EVP_EncryptInit_ex2(ptr noundef nonnull %8, ptr noundef nonnull %13, ptr noundef nonnull @cbc_key, ptr noundef nonnull @cbc_iv, ptr noundef null) #4
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %40, label %17

17:                                               ; preds = %15
  %18 = call i32 @EVP_EncryptUpdate(ptr noundef nonnull %8, ptr noundef nonnull %3, ptr noundef nonnull %1, ptr noundef nonnull @cbc_pt, i32 noundef 16) #4
  %.not11 = icmp eq i32 %18, 0
  br i1 %.not11, label %40, label %19

19:                                               ; preds = %17
  %20 = load i32, ptr %1, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %3, i64 %21
  %23 = call i32 @EVP_EncryptFinal_ex(ptr noundef nonnull %8, ptr noundef nonnull %22, ptr noundef nonnull %2) #4
  %.not12 = icmp eq i32 %23, 0
  br i1 %.not12, label %40, label %24

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = load i32, ptr %1, align 4, !tbaa !9
  %27 = add nsw i32 %26, %25
  store i32 %27, ptr %1, align 4, !tbaa !9
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %27)
  %29 = load ptr, ptr @stdout, align 8, !tbaa !5
  %30 = load i32, ptr %1, align 4, !tbaa !9
  %31 = call i32 @BIO_dump_fp(ptr noundef %29, ptr noundef nonnull %3, i32 noundef %30) #4
  %32 = load i32, ptr %1, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 32
  br i1 %33, label %34, label %38

34:                                               ; preds = %24
  %35 = call i32 @CRYPTO_memcmp(ptr noundef nonnull %3, ptr noundef nonnull @cbc_ct, i64 noundef 32) #4
  %.not13 = icmp eq i32 %35, 0
  br i1 %.not13, label %36, label %38

36:                                               ; preds = %34
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %42

38:                                               ; preds = %34, %24
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %42

40:                                               ; preds = %0, %10, %19, %17, %15
  %.07.ph = phi ptr [ %13, %15 ], [ %13, %17 ], [ %13, %19 ], [ null, %10 ], [ null, %0 ]
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void @ERR_print_errors_fp(ptr noundef %41) #4
  br label %42

42:                                               ; preds = %38, %36, %40
  %.020 = phi i32 [ 0, %40 ], [ 1, %38 ], [ 1, %36 ]
  %.0718 = phi ptr [ %.07.ph, %40 ], [ %13, %38 ], [ %13, %36 ]
  call void @EVP_CIPHER_free(ptr noundef %.0718) #4
  call void @EVP_CIPHER_CTX_free(ptr noundef %8) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 %.020
}

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

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

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

declare ptr @EVP_CIPHER_CTX_new() local_unnamed_addr #3

declare ptr @EVP_CIPHER_fetch(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

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

declare i32 @CRYPTO_memcmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @ERR_print_errors_fp(ptr noundef) local_unnamed_addr #3

declare void @EVP_CIPHER_free(ptr noundef) local_unnamed_addr #3

declare void @EVP_CIPHER_CTX_free(ptr noundef) local_unnamed_addr #3

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

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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 }

!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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass