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

; 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] }

@RijEncSbox = external constant [256 x i8], align 64

; Function Attrs: nounwind uwtable
define dso_local void @cpProcessAES_ofb8(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca [8 x i32], align 16
  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 i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %15 = load ptr, ptr %11, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._cpRijndael128, ptr %15, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  store ptr %17, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #3
  %18 = load ptr, ptr %12, align 8, !tbaa !5
  %19 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %18, ptr noundef %19)
  br label %20

20:                                               ; preds = %93, %6
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = icmp sge i32 %21, %22
  br i1 %23, label %24, label %105

24:                                               ; preds = %20
  %25 = load ptr, ptr %13, align 8, !tbaa !5
  %26 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  %27 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  %28 = getelementptr inbounds i32, ptr %27, i64 4
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._cpRijndael128, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 4, !tbaa !13
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._cpRijndael128, ptr %32, i32 0, i32 8
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  call void %25(ptr noundef %26, ptr noundef %28, i32 noundef %31, ptr noundef %34, ptr noundef @RijEncSbox)
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 16
  br i1 %36, label %37, label %82

37:                                               ; preds = %24
  %38 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 4
  %39 = load i32, ptr %38, align 16, !tbaa !9
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds i32, ptr %40, i64 0
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = xor i32 %39, %42
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds i32, ptr %44, i64 0
  store i32 %43, ptr %45, align 4, !tbaa !9
  %46 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 5
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds i32, ptr %48, i64 1
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = xor i32 %47, %50
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds i32, ptr %52, i64 1
  store i32 %51, ptr %53, align 4, !tbaa !9
  %54 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 6
  %55 = load i32, ptr %54, align 8, !tbaa !9
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds i32, ptr %56, i64 2
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = xor i32 %55, %58
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds i32, ptr %60, i64 2
  store i32 %59, ptr %61, align 4, !tbaa !9
  %62 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 7
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds i32, ptr %64, i64 3
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = xor i32 %63, %66
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds i32, ptr %68, i64 3
  store i32 %67, ptr %69, align 4, !tbaa !9
  %70 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 4
  %71 = load i32, ptr %70, align 16, !tbaa !9
  %72 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  store i32 %71, ptr %72, align 16, !tbaa !9
  %73 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 5
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 1
  store i32 %74, ptr %75, align 4, !tbaa !9
  %76 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 6
  %77 = load i32, ptr %76, align 8, !tbaa !9
  %78 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 2
  store i32 %77, ptr %78, align 8, !tbaa !9
  %79 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 7
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 3
  store i32 %80, ptr %81, align 4, !tbaa !9
  br label %93

82:                                               ; preds = %24
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  %85 = getelementptr inbounds i32, ptr %84, i64 4
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load i32, ptr %10, align 4, !tbaa !9
  call void @XorBlock(ptr noundef %83, ptr noundef %85, ptr noundef %86, i32 noundef %87)
  %88 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i8, ptr %88, i64 %90
  %92 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %91, ptr noundef %92)
  br label %93

93:                                               ; preds = %82, %37
  %94 = load i32, ptr %10, align 4, !tbaa !9
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = sext i32 %94 to i64
  %97 = getelementptr inbounds i8, ptr %95, i64 %96
  store ptr %97, ptr %7, align 8, !tbaa !5
  %98 = load i32, ptr %10, align 4, !tbaa !9
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = sext i32 %98 to i64
  %101 = getelementptr inbounds i8, ptr %99, i64 %100
  store ptr %101, ptr %8, align 8, !tbaa !5
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = load i32, ptr %9, align 4, !tbaa !9
  %104 = sub nsw i32 %103, %102
  store i32 %104, ptr %9, align 4, !tbaa !9
  br label %20, !llvm.loop !15

105:                                              ; preds = %20
  %106 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  call void @CopyBlock16(ptr noundef %106, ptr noundef %107)
  %108 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  call void @PurgeBlock(ptr noundef %108, i32 noundef 32)
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret void
}

; 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 void @CopyBlock16(ptr noundef, ptr noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(ptr noundef, i32 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 = { 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 = !{!12, !6, i64 16}
!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}
!13 = !{!12, !10, i64 12}
!14 = !{!12, !6, i64 48}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@RijEncSbox = external constant [256 x i8], align 64

; Function Attrs: nounwind uwtable
define dso_local void @cpProcessAES_ofb8(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = alloca [8 x i32], align 16
  %8 = getelementptr inbounds i8, ptr %4, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #3
  call void @CopyBlock16(ptr noundef %5, ptr noundef nonnull %7)
  %.not29 = icmp slt i32 %2, %3
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %10 = getelementptr inbounds i8, ptr %7, i64 16
  %11 = getelementptr inbounds i8, ptr %4, i64 12
  %12 = getelementptr inbounds i8, ptr %4, i64 48
  %13 = icmp eq i32 %3, 16
  %14 = sext i32 %3 to i64
  %15 = getelementptr inbounds i8, ptr %7, i64 %14
  %16 = getelementptr inbounds i8, ptr %7, i64 20
  %17 = getelementptr inbounds i8, ptr %7, i64 24
  %18 = getelementptr inbounds i8, ptr %7, i64 28
  %19 = getelementptr inbounds i8, ptr %7, i64 4
  %20 = getelementptr inbounds i8, ptr %7, i64 8
  %21 = getelementptr inbounds i8, ptr %7, i64 12
  br i1 %13, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.032.us = phi ptr [ %42, %.lr.ph.split.us ], [ %0, %.lr.ph ]
  %.02631.us = phi ptr [ %43, %.lr.ph.split.us ], [ %1, %.lr.ph ]
  %.02730.us = phi i32 [ %44, %.lr.ph.split.us ], [ %2, %.lr.ph ]
  %22 = load i32, ptr %11, align 4, !tbaa !11
  %23 = load ptr, ptr %12, align 8, !tbaa !12
  call void %9(ptr noundef nonnull %7, ptr noundef nonnull %10, i32 noundef %22, ptr noundef %23, ptr noundef nonnull @RijEncSbox) #3
  %24 = load i32, ptr %10, align 16, !tbaa !13
  %25 = load i32, ptr %.032.us, align 4, !tbaa !13
  %26 = xor i32 %25, %24
  store i32 %26, ptr %.02631.us, align 4, !tbaa !13
  %27 = load i32, ptr %16, align 4, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %.032.us, i64 4
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = xor i32 %29, %27
  %31 = getelementptr inbounds i8, ptr %.02631.us, i64 4
  store i32 %30, ptr %31, align 4, !tbaa !13
  %32 = load i32, ptr %17, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %.032.us, i64 8
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = xor i32 %34, %32
  %36 = getelementptr inbounds i8, ptr %.02631.us, i64 8
  store i32 %35, ptr %36, align 4, !tbaa !13
  %37 = load i32, ptr %18, align 4, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %.032.us, i64 12
  %39 = load i32, ptr %38, align 4, !tbaa !13
  %40 = xor i32 %39, %37
  %41 = getelementptr inbounds i8, ptr %.02631.us, i64 12
  store i32 %40, ptr %41, align 4, !tbaa !13
  store i32 %24, ptr %7, align 16, !tbaa !13
  store i32 %27, ptr %19, align 4, !tbaa !13
  store i32 %32, ptr %20, align 8, !tbaa !13
  store i32 %37, ptr %21, align 4, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %.032.us, i64 %14
  %43 = getelementptr inbounds i8, ptr %.02631.us, i64 %14
  %44 = add nsw i32 %.02730.us, -16
  %.not.us = icmp slt i32 %.02730.us, 32
  br i1 %.not.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !14

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %.032 = phi ptr [ %47, %.lr.ph.split ], [ %0, %.lr.ph ]
  %.02631 = phi ptr [ %48, %.lr.ph.split ], [ %1, %.lr.ph ]
  %.02730 = phi i32 [ %49, %.lr.ph.split ], [ %2, %.lr.ph ]
  %45 = load i32, ptr %11, align 4, !tbaa !11
  %46 = load ptr, ptr %12, align 8, !tbaa !12
  call void %9(ptr noundef nonnull %7, ptr noundef nonnull %10, i32 noundef %45, ptr noundef %46, ptr noundef nonnull @RijEncSbox) #3
  call void @XorBlock(ptr noundef %.032, ptr noundef nonnull %10, ptr noundef %.02631, i32 noundef %3)
  call void @CopyBlock16(ptr noundef nonnull %15, ptr noundef nonnull %7)
  %47 = getelementptr inbounds i8, ptr %.032, i64 %14
  %48 = getelementptr inbounds i8, ptr %.02631, i64 %14
  %49 = sub nsw i32 %.02730, %3
  %.not = icmp slt i32 %49, %3
  br i1 %.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %6
  call void @CopyBlock16(ptr noundef nonnull %7, ptr noundef %5)
  call void @PurgeBlock(ptr noundef nonnull %7, i32 noundef 32)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #3
  ret void
}

; 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 void @CopyBlock16(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; 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 = { 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, !10, i64 16}
!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}
!11 = !{!6, !7, i64 12}
!12 = !{!6, !10, i64 48}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass