; LLVM IR from quarkslab/crypto-condor :: tests/harness/AES_openssl_decrypt_aead.harness (CC_AES_CCM_256_decrypt)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @EVP_CIPHER_CTX_new() #1

declare i32 @EVP_DecryptInit_ex(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

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

declare void @EVP_CIPHER_CTX_free(ptr noundef) #1

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

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

32:                                               ; preds = %12
  br label %92

33:                                               ; preds = %12
  %34 = load ptr, ptr %26, align 8, !tbaa !5
  %35 = call ptr @EVP_aes_256_ccm()
  %36 = call i32 @EVP_DecryptInit_ex(ptr noundef %34, ptr noundef %35, ptr noundef null, ptr noundef null, ptr noundef null)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %33
  br label %92

39:                                               ; preds = %33
  %40 = load ptr, ptr %26, align 8, !tbaa !5
  %41 = load i64, ptr %23, align 8, !tbaa !9
  %42 = trunc i64 %41 to i32
  %43 = call i32 @EVP_CIPHER_CTX_ctrl(ptr noundef %40, i32 noundef 9, i32 noundef %42, ptr noundef null)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %39
  br label %92

46:                                               ; preds = %39
  %47 = load ptr, ptr %26, align 8, !tbaa !5
  %48 = load i64, ptr %19, align 8, !tbaa !9
  %49 = trunc i64 %48 to i32
  %50 = load ptr, ptr %18, align 8, !tbaa !5
  %51 = call i32 @EVP_CIPHER_CTX_ctrl(ptr noundef %47, i32 noundef 17, i32 noundef %49, ptr noundef %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %54, label %53

53:                                               ; preds = %46
  br label %92

54:                                               ; preds = %46
  %55 = load ptr, ptr %26, align 8, !tbaa !5
  %56 = load ptr, ptr %20, align 8, !tbaa !5
  %57 = load ptr, ptr %22, align 8, !tbaa !5
  %58 = call i32 @EVP_DecryptInit_ex(ptr noundef %55, ptr noundef null, ptr noundef null, ptr noundef %56, ptr noundef %57)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %54
  br label %92

61:                                               ; preds = %54
  %62 = load ptr, ptr %26, align 8, !tbaa !5
  %63 = load i64, ptr %17, align 8, !tbaa !9
  %64 = trunc i64 %63 to i32
  %65 = call i32 @EVP_DecryptUpdate(ptr noundef %62, ptr noundef null, ptr noundef %27, ptr noundef null, i32 noundef %64)
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %68, label %67

67:                                               ; preds = %61
  br label %92

68:                                               ; preds = %61
  %69 = load i64, ptr %25, align 8, !tbaa !9
  %70 = icmp ugt i64 %69, 0
  br i1 %70, label %71, label %80

71:                                               ; preds = %68
  %72 = load ptr, ptr %26, align 8, !tbaa !5
  %73 = load ptr, ptr %24, align 8, !tbaa !5
  %74 = load i64, ptr %25, align 8, !tbaa !9
  %75 = trunc i64 %74 to i32
  %76 = call i32 @EVP_DecryptUpdate(ptr noundef %72, ptr noundef null, ptr noundef %27, ptr noundef %73, i32 noundef %75)
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %79, label %78

78:                                               ; preds = %71
  br label %92

79:                                               ; preds = %71
  br label %80

80:                                               ; preds = %79, %68
  %81 = load ptr, ptr %26, align 8, !tbaa !5
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load ptr, ptr %16, align 8, !tbaa !5
  %84 = load i64, ptr %17, align 8, !tbaa !9
  %85 = trunc i64 %84 to i32
  %86 = call i32 @EVP_DecryptUpdate(ptr noundef %81, ptr noundef %82, ptr noundef %27, ptr noundef %83, i32 noundef %85)
  %87 = icmp ne i32 1, %86
  br i1 %87, label %88, label %90

88:                                               ; preds = %80
  %89 = load ptr, ptr %26, align 8, !tbaa !5
  call void @EVP_CIPHER_CTX_free(ptr noundef %89)
  store i32 -1, ptr %13, align 4
  store i32 1, ptr %28, align 4
  br label %94

90:                                               ; preds = %80
  %91 = load ptr, ptr %26, align 8, !tbaa !5
  call void @EVP_CIPHER_CTX_free(ptr noundef %91)
  store i32 1, ptr %13, align 4
  store i32 1, ptr %28, align 4
  br label %94

92:                                               ; preds = %78, %67, %60, %53, %45, %38, %32
  %93 = load ptr, ptr %26, align 8, !tbaa !5
  call void @EVP_CIPHER_CTX_free(ptr noundef %93)
  store i32 0, ptr %13, align 4
  store i32 1, ptr %28, align 4
  br label %94

94:                                               ; preds = %92, %90, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #3
  %95 = load i32, ptr %13, align 4
  ret i32 %95
}

declare ptr @EVP_aes_256_ccm() #1

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 = { 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @EVP_CIPHER_CTX_new() local_unnamed_addr #1

declare i32 @EVP_DecryptInit_ex(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

declare void @EVP_CIPHER_CTX_free(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @CC_AES_CCM_256_decrypt(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, i64 noundef %11) local_unnamed_addr #2 {
  %13 = alloca i32, align 4
  %14 = tail call ptr @EVP_CIPHER_CTX_new() #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #3
  store i32 0, ptr %13, align 4, !tbaa !5
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %35, label %15

15:                                               ; preds = %12
  %16 = tail call ptr @EVP_aes_256_ccm() #3
  %17 = tail call i32 @EVP_DecryptInit_ex(ptr noundef nonnull %14, ptr noundef %16, ptr noundef null, ptr noundef null, ptr noundef null) #3
  %.not25 = icmp eq i32 %17, 0
  br i1 %.not25, label %35, label %18

18:                                               ; preds = %15
  %19 = trunc i64 %9 to i32
  %20 = tail call i32 @EVP_CIPHER_CTX_ctrl(ptr noundef nonnull %14, i32 noundef 9, i32 noundef %19, ptr noundef null) #3
  %.not26 = icmp eq i32 %20, 0
  br i1 %.not26, label %35, label %21

21:                                               ; preds = %18
  %22 = trunc i64 %5 to i32
  %23 = tail call i32 @EVP_CIPHER_CTX_ctrl(ptr noundef nonnull %14, i32 noundef 17, i32 noundef %22, ptr noundef %4) #3
  %.not27 = icmp eq i32 %23, 0
  br i1 %.not27, label %35, label %24

24:                                               ; preds = %21
  %25 = tail call i32 @EVP_DecryptInit_ex(ptr noundef nonnull %14, ptr noundef null, ptr noundef null, ptr noundef %6, ptr noundef %8) #3
  %.not28 = icmp eq i32 %25, 0
  br i1 %.not28, label %35, label %26

26:                                               ; preds = %24
  %27 = trunc i64 %3 to i32
  %28 = call i32 @EVP_DecryptUpdate(ptr noundef nonnull %14, ptr noundef null, ptr noundef nonnull %13, ptr noundef null, i32 noundef %27) #3
  %.not29 = icmp eq i32 %28, 0
  br i1 %.not29, label %35, label %29

29:                                               ; preds = %26
  %.not30 = icmp eq i64 %11, 0
  br i1 %.not30, label %33, label %30

30:                                               ; preds = %29
  %31 = trunc i64 %11 to i32
  %32 = call i32 @EVP_DecryptUpdate(ptr noundef nonnull %14, ptr noundef null, ptr noundef nonnull %13, ptr noundef %10, i32 noundef %31) #3
  %.not31 = icmp eq i32 %32, 0
  br i1 %.not31, label %35, label %33

33:                                               ; preds = %30, %29
  %34 = call i32 @EVP_DecryptUpdate(ptr noundef nonnull %14, ptr noundef %0, ptr noundef nonnull %13, ptr noundef %2, i32 noundef %27) #3
  %.not32 = icmp eq i32 %34, 1
  call void @EVP_CIPHER_CTX_free(ptr noundef nonnull %14) #3
  %. = select i1 %.not32, i32 1, i32 -1
  br label %36

35:                                               ; preds = %30, %26, %24, %21, %18, %15, %12
  call void @EVP_CIPHER_CTX_free(ptr noundef %14) #3
  br label %36

36:                                               ; preds = %33, %35
  %.0 = phi i32 [ 0, %35 ], [ %., %33 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #3
  ret i32 %.0
}

declare ptr @EVP_aes_256_ccm() local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 = { 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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass