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

; 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 @ippsAES_S2V_CMAC(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5) #0 {
  %7 = alloca i32, align 4
  %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
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca [640 x i8], align 16
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  %20 = load ptr, ptr %13, align 8, !tbaa !5
  %21 = icmp eq ptr null, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %6
  store i32 -8, ptr %7, align 4
  br label %126

23:                                               ; preds = %6
  %24 = load i32, ptr %12, align 4, !tbaa !9
  %25 = icmp sgt i32 0, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store i32 -15, ptr %7, align 4
  br label %126

27:                                               ; preds = %23
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = icmp eq ptr null, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  store i32 -8, ptr %7, align 4
  br label %126

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

34:                                               ; preds = %31
  store i32 -8, ptr %7, align 4
  br label %126

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %64, %35
  %37 = load i32, ptr %14, align 4, !tbaa !9
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %67

40:                                               ; preds = %36
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = load i32, ptr %14, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %41, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %40
  store i32 -15, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %125

48:                                               ; preds = %40
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %49, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %63

55:                                               ; preds = %48
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load i32, ptr %14, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds ptr, ptr %56, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %63, label %62

62:                                               ; preds = %55
  store i32 -8, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %125

63:                                               ; preds = %55, %48
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %14, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %14, align 4, !tbaa !9
  br label %36, !llvm.loop !11

67:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 640, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %68 = getelementptr inbounds [640 x i8], ptr %16, i64 0, i64 0
  store ptr %68, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = call i32 @cpAES_S2V_init(ptr noundef %69, ptr noundef %70, i32 noundef %71, ptr noundef %72, i32 noundef 640)
  store i32 %73, ptr %18, align 4, !tbaa !9
  %74 = load i32, ptr %18, align 4, !tbaa !9
  %75 = icmp eq i32 0, %74
  br i1 %75, label %76, label %123

76:                                               ; preds = %67
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = icmp eq i32 0, %77
  br i1 %78, label %79, label %86

79:                                               ; preds = %76
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  call void @PadBlock(i8 noundef zeroext 0, ptr noundef %80, i32 noundef 16)
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %81, i64 15
  store i8 1, ptr %82, align 1, !tbaa !13
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  %85 = load ptr, ptr %17, align 8, !tbaa !5
  call void @cpAES_CMAC(ptr noundef %83, ptr noundef %84, i32 noundef 16, ptr noundef %85)
  br label %122

86:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !9
  %87 = load i32, ptr %12, align 4, !tbaa !9
  %88 = add nsw i32 %87, -1
  store i32 %88, ptr %12, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %106, %86
  %90 = load i32, ptr %19, align 4, !tbaa !9
  %91 = load i32, ptr %12, align 4, !tbaa !9
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %93, label %109

93:                                               ; preds = %89
  %94 = load ptr, ptr %13, align 8, !tbaa !5
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = load i32, ptr %19, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds ptr, ptr %95, i64 %97
  %99 = load ptr, ptr %98, align 8, !tbaa !5
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = load i32, ptr %19, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr %100, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !9
  %105 = load ptr, ptr %17, align 8, !tbaa !5
  call void @cpAES_S2V_update(ptr noundef %94, ptr noundef %99, i32 noundef %104, ptr noundef %105)
  br label %106

106:                                              ; preds = %93
  %107 = load i32, ptr %19, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %19, align 4, !tbaa !9
  br label %89, !llvm.loop !14

109:                                              ; preds = %89
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load i32, ptr %12, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds ptr, ptr %111, i64 %113
  %115 = load ptr, ptr %114, align 8, !tbaa !5
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = load i32, ptr %12, align 4, !tbaa !9
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %116, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !9
  %121 = load ptr, ptr %17, align 8, !tbaa !5
  call void @cpAES_S2V_final(ptr noundef %110, ptr noundef %115, i32 noundef %120, ptr noundef %121)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %122

122:                                              ; preds = %109, %79
  br label %123

123:                                              ; preds = %122, %67
  call void @PurgeBlock(ptr noundef %16, i32 noundef 640)
  %124 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %124, ptr %7, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 640, ptr %16) #3
  br label %125

125:                                              ; preds = %123, %62, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %126

126:                                              ; preds = %125, %34, %30, %26, %22
  %127 = load i32, ptr %7, align 4
  ret i32 %127
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpAES_S2V_init(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PadBlock(i8 noundef zeroext, ptr noundef, i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpAES_CMAC(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpAES_S2V_update(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @cpAES_S2V_final(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(ptr noundef, i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


; 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 @ippsAES_S2V_CMAC(ptr noundef %0, i32 noundef %1, ptr noundef readonly %2, ptr noundef readonly %3, i32 noundef %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = alloca [640 x i8], align 16
  %8 = icmp eq ptr %5, null
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %6
  %10 = icmp slt i32 %4, 0
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %9
  %12 = icmp eq ptr %2, null
  %13 = icmp eq ptr %3, null
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %11
  %.not55 = icmp eq i32 %4, 0
  br i1 %.not55, label %._crit_edge.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %4 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %21
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %21 ]
  %14 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %.loopexit, label %17

17:                                               ; preds = %.lr.ph
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %21, label %18

18:                                               ; preds = %17
  %19 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %.not49 = icmp eq ptr %20, null
  br i1 %.not49, label %.loopexit, label %21

21:                                               ; preds = %17, %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %21
  call void @llvm.lifetime.start.p0(i64 640, ptr nonnull %7) #3
  %22 = call i32 @cpAES_S2V_init(ptr noundef nonnull %5, ptr noundef %0, i32 noundef %1, ptr noundef nonnull %7, i32 noundef 640)
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %26, label %39

._crit_edge.thread:                               ; preds = %.preheader
  call void @llvm.lifetime.start.p0(i64 640, ptr nonnull %7) #3
  %24 = call i32 @cpAES_S2V_init(ptr noundef nonnull %5, ptr noundef %0, i32 noundef %1, ptr noundef nonnull %7, i32 noundef 640)
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %.thread, label %39

26:                                               ; preds = %._crit_edge
  br i1 %.not55, label %.thread, label %28

.thread:                                          ; preds = %._crit_edge.thread, %26
  call void @PadBlock(i8 noundef zeroext 0, ptr noundef nonnull %5, i32 noundef 16)
  %27 = getelementptr inbounds i8, ptr %5, i64 15
  store i8 1, ptr %27, align 1, !tbaa !13
  call void @cpAES_CMAC(ptr noundef nonnull %5, ptr noundef nonnull %5, i32 noundef 16, ptr noundef nonnull %7)
  br label %39

28:                                               ; preds = %26
  %29 = add nsw i32 %4, -1
  %30 = icmp sgt i32 %4, 1
  %wide.trip.count60 = zext nneg i32 %29 to i64
  br i1 %30, label %.lr.ph53, label %._crit_edge54

.lr.ph53:                                         ; preds = %28, %.lr.ph53
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %.lr.ph53 ], [ 0, %28 ]
  %31 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv57
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv57
  %34 = load i32, ptr %33, align 4, !tbaa !5
  call void @cpAES_S2V_update(ptr noundef nonnull %5, ptr noundef %32, i32 noundef %34, ptr noundef nonnull %7)
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %exitcond61.not = icmp eq i64 %indvars.iv.next58, %wide.trip.count60
  br i1 %exitcond61.not, label %._crit_edge54, label %.lr.ph53, !llvm.loop !14

._crit_edge54:                                    ; preds = %.lr.ph53, %28
  %35 = getelementptr inbounds ptr, ptr %2, i64 %wide.trip.count60
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds i32, ptr %3, i64 %wide.trip.count60
  %38 = load i32, ptr %37, align 4, !tbaa !5
  call void @cpAES_S2V_final(ptr noundef nonnull %5, ptr noundef %36, i32 noundef %38, ptr noundef nonnull %7)
  br label %39

39:                                               ; preds = %._crit_edge.thread, %.thread, %._crit_edge54, %._crit_edge
  %40 = phi i32 [ %24, %._crit_edge.thread ], [ 0, %.thread ], [ 0, %._crit_edge54 ], [ %22, %._crit_edge ]
  call void @PurgeBlock(ptr noundef nonnull %7, i32 noundef 640)
  call void @llvm.lifetime.end.p0(i64 640, ptr nonnull %7) #3
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %18, %39, %11, %9, %6
  %.1 = phi i32 [ -8, %6 ], [ -15, %9 ], [ -8, %11 ], [ %40, %39 ], [ -8, %18 ], [ -15, %.lr.ph ]
  ret i32 %.1
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpAES_S2V_init(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PadBlock(i8 noundef zeroext, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpAES_CMAC(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpAES_S2V_update(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @cpAES_S2V_final(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(ptr noundef, i32 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass