; LLVM IR from intel/cryptography-primitives :: sources/ippcp/sms4 (pcpsms4_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._cpSMS4 = type { i32, [32 x i32], [32 x i32] }

; Function Attrs: nounwind uwtable
define dso_local void @cpProcessSMS4_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 [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 32, ptr %13) #4
  %14 = load ptr, ptr %12, align 8, !tbaa !5
  %15 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %14, ptr noundef %15)
  br label %16

16:                                               ; preds = %85, %6
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = icmp sge i32 %17, %18
  br i1 %19, label %20, label %97

20:                                               ; preds = %16
  %21 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %23 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._cpSMS4, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds [32 x i32], ptr %25, i64 0, i64 0
  call void @cpSMS4_Cipher(ptr noundef %22, ptr noundef %23, ptr noundef %26)
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 16
  br i1 %28, label %29, label %74

29:                                               ; preds = %20
  %30 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 4
  %31 = load i32, ptr %30, align 16, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds i32, ptr %32, i64 0
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = xor i32 %31, %34
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds i32, ptr %36, i64 0
  store i32 %35, ptr %37, align 4, !tbaa !9
  %38 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 5
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds i32, ptr %40, i64 1
  %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 1
  store i32 %43, ptr %45, align 4, !tbaa !9
  %46 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 6
  %47 = load i32, ptr %46, align 8, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds i32, ptr %48, i64 2
  %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 2
  store i32 %51, ptr %53, align 4, !tbaa !9
  %54 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 7
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds i32, ptr %56, i64 3
  %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 3
  store i32 %59, ptr %61, align 4, !tbaa !9
  %62 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 4
  %63 = load i32, ptr %62, align 16, !tbaa !9
  %64 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  store i32 %63, ptr %64, align 16, !tbaa !9
  %65 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 5
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 1
  store i32 %66, ptr %67, align 4, !tbaa !9
  %68 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 6
  %69 = load i32, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 2
  store i32 %69, ptr %70, align 8, !tbaa !9
  %71 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 7
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 3
  store i32 %72, ptr %73, align 4, !tbaa !9
  br label %85

74:                                               ; preds = %20
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  %77 = getelementptr inbounds i32, ptr %76, i64 4
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = load i32, ptr %10, align 4, !tbaa !9
  call void @XorBlock(ptr noundef %75, ptr noundef %77, ptr noundef %78, i32 noundef %79)
  %80 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds i8, ptr %80, i64 %82
  %84 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %83, ptr noundef %84)
  br label %85

85:                                               ; preds = %74, %29
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = sext i32 %86 to i64
  %89 = getelementptr inbounds i8, ptr %87, i64 %88
  store ptr %89, ptr %7, align 8, !tbaa !5
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = sext i32 %90 to i64
  %93 = getelementptr inbounds i8, ptr %91, i64 %92
  store ptr %93, ptr %8, align 8, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !9
  %95 = load i32, ptr %9, align 4, !tbaa !9
  %96 = sub nsw i32 %95, %94
  store i32 %96, ptr %9, align 4, !tbaa !9
  br label %16, !llvm.loop !11

97:                                               ; preds = %16
  %98 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  call void @CopyBlock16(ptr noundef %98, ptr noundef %99)
  %100 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  call void @PurgeBlock(ptr noundef %100, i32 noundef 32)
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #4
  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

declare void @cpSMS4_Cipher(ptr noundef, ptr noundef, ptr noundef) #3

; 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 = { "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 = distinct !{!11, !12}
!12 = !{!"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"

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

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

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

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %.029 = phi ptr [ %40, %.lr.ph.split ], [ %0, %.lr.ph ]
  %.02328 = phi ptr [ %41, %.lr.ph.split ], [ %1, %.lr.ph ]
  %.02427 = phi i32 [ %42, %.lr.ph.split ], [ %2, %.lr.ph ]
  call void @cpSMS4_Cipher(ptr noundef nonnull %8, ptr noundef nonnull %7, ptr noundef nonnull %9) #4
  call void @XorBlock(ptr noundef %.029, ptr noundef nonnull %8, ptr noundef %.02328, i32 noundef %3)
  call void @CopyBlock16(ptr noundef nonnull %12, ptr noundef nonnull %7)
  %40 = getelementptr inbounds i8, ptr %.029, i64 %11
  %41 = getelementptr inbounds i8, ptr %.02328, i64 %11
  %42 = sub nsw i32 %.02427, %3
  %.not = icmp slt i32 %42, %3
  br i1 %.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !9

._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) #4
  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

declare void @cpSMS4_Cipher(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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