; LLVM IR from intel/QAT_Engine :: test (tests_aes_cbc_hmac_sha)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @compute_buff_size(i32 noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  %13 = load i32, ptr %9, align 4, !tbaa !5
  switch i32 %13, label %36 [
    i32 0, label %14
    i32 770, label %25
    i32 771, label %25
    i32 769, label %29
  ]

14:                                               ; preds = %5
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = load ptr, ptr %10, align 8, !tbaa !9
  %17 = call i32 @EVP_CIPHER_CTX_get_block_size(ptr noundef %16)
  %18 = sub nsw i32 %17, 1
  %19 = add nsw i32 %15, %18
  %20 = load ptr, ptr %10, align 8, !tbaa !9
  %21 = call i32 @EVP_CIPHER_CTX_get_block_size(ptr noundef %20)
  %22 = sub nsw i32 %21, 1
  %23 = xor i32 %22, -1
  %24 = and i32 %19, %23
  store i32 %24, ptr %11, align 4, !tbaa !5
  br label %38

25:                                               ; preds = %5, %5
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  %27 = call i32 @EVP_CIPHER_CTX_get_iv_length(ptr noundef %26)
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %27, ptr %28, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %25, %5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add i32 %31, %33
  %35 = add i32 %30, %34
  store i32 %35, ptr %11, align 4, !tbaa !5
  br label %38

36:                                               ; preds = %5
  store i32 0, ptr %11, align 4, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 0, ptr %37, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %36, %29, %14
  %39 = load i32, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %39
}

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

declare i32 @EVP_CIPHER_CTX_get_block_size(ptr noundef) #2

declare i32 @EVP_CIPHER_CTX_get_iv_length(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}


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

; Function Attrs: nounwind uwtable
define dso_local i32 @compute_buff_size(i32 noundef %0, ptr nocapture noundef writeonly %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  store i32 0, ptr %1, align 4, !tbaa !5
  switch i32 %3, label %19 [
    i32 0, label %6
    i32 770, label %13
    i32 771, label %13
    i32 769, label %15
  ]

6:                                                ; preds = %5
  %7 = tail call i32 @EVP_CIPHER_CTX_get_block_size(ptr noundef %4) #2
  %8 = add i32 %0, -1
  %9 = add i32 %8, %7
  %10 = tail call i32 @EVP_CIPHER_CTX_get_block_size(ptr noundef %4) #2
  %11 = sub i32 0, %10
  %12 = and i32 %9, %11
  br label %19

13:                                               ; preds = %5, %5
  %14 = tail call i32 @EVP_CIPHER_CTX_get_iv_length(ptr noundef %4) #2
  store i32 %14, ptr %1, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %13, %5
  %16 = phi i32 [ %14, %13 ], [ 0, %5 ]
  %17 = add i32 %2, %0
  %18 = add i32 %17, %16
  br label %19

19:                                               ; preds = %5, %15, %6
  %.0 = phi i32 [ %18, %15 ], [ %12, %6 ], [ 0, %5 ]
  ret i32 %.0
}

declare i32 @EVP_CIPHER_CTX_get_block_size(ptr noundef) local_unnamed_addr #1

declare i32 @EVP_CIPHER_CTX_get_iv_length(ptr noundef) local_unnamed_addr #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 = { "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 }

!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: DSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass