; LLVM IR from intel/cryptography-primitives :: sources/ippcp (pcpaes_cbcdecrypt)

; 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._cpRijndael128 = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, [124 x i32] }

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsAESDecryptCBC(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %5
  store i32 -8, ptr %6, align 4
  br label %55

16:                                               ; preds = %5
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._cpRijndael128, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = call i64 @IPP_UINT_PTR(ptr noundef %20)
  %22 = trunc i64 %21 to i32
  %23 = xor i32 %19, %22
  %24 = icmp eq i32 %23, 542263626
  br i1 %24, label %26, label %25

25:                                               ; preds = %16
  store i32 -13, ptr %6, align 4
  br label %55

26:                                               ; preds = %16
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = icmp eq ptr null, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 -8, ptr %6, align 4
  br label %55

30:                                               ; preds = %26
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = icmp eq ptr null, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 -8, ptr %6, align 4
  br label %55

34:                                               ; preds = %30
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = icmp eq ptr null, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  store i32 -8, ptr %6, align 4
  br label %55

38:                                               ; preds = %34
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = icmp slt i32 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 -15, ptr %6, align 4
  br label %55

42:                                               ; preds = %38
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = and i32 %43, 15
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  store i32 -1005, ptr %6, align 4
  br label %55

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = sdiv i32 %48, 16
  store i32 %49, ptr %12, align 4, !tbaa !9
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  call void @cpDecryptAES_cbc(ptr noundef %50, ptr noundef %51, ptr noundef %52, i32 noundef %53, ptr noundef %54)
  store i32 0, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %55

55:                                               ; preds = %47, %46, %41, %37, %33, %29, %25, %15
  %56 = load i32, ptr %6, align 4
  ret i32 %56
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) #1

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

declare void @cpDecryptAES_cbc(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

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 = { inlinehint 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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}
!11 = !{!12, !10, i64 0}
!12 = !{!"_cpRijndael128", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !7, i64 72}


; 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 range(i32 -1005, 1) i32 @ippsAESDecryptCBC(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq ptr %3, null
  br i1 %6, label %23, label %7

7:                                                ; preds = %5
  %8 = load i32, ptr %3, align 8, !tbaa !5
  %9 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %3)
  %10 = trunc i64 %9 to i32
  %11 = xor i32 %8, %10
  %12 = icmp eq i32 %11, 542263626
  br i1 %12, label %13, label %23

13:                                               ; preds = %7
  %14 = icmp eq ptr %0, null
  %15 = icmp eq ptr %4, null
  %or.cond = or i1 %14, %15
  %16 = icmp eq ptr %1, null
  %or.cond19 = or i1 %16, %or.cond
  br i1 %or.cond19, label %23, label %17

17:                                               ; preds = %13
  %18 = icmp slt i32 %2, 1
  br i1 %18, label %23, label %19

19:                                               ; preds = %17
  %20 = and i32 %2, 15
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %23

21:                                               ; preds = %19
  %22 = lshr exact i32 %2, 4
  tail call void @cpDecryptAES_cbc(ptr noundef nonnull %4, ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %22, ptr noundef nonnull %3) #3
  br label %23

23:                                               ; preds = %19, %17, %13, %7, %5, %21
  %.0 = phi i32 [ 0, %21 ], [ -8, %5 ], [ -13, %7 ], [ -8, %13 ], [ -15, %17 ], [ -1005, %19 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) local_unnamed_addr #1

declare void @cpDecryptAES_cbc(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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 = { inlinehint 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 #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, !7, i64 0}
!6 = !{!"_cpRijndael128", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 68, !8, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}


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