; LLVM IR from dhuertas/AES :: aes (aes_inv_cipher)

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

@Nb = external dso_local global i32, align 4
@Nr = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @add_round_key(ptr noundef, ptr noundef, i8 noundef zeroext) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @inv_mix_columns(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @inv_shift_rows(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @inv_sub_bytes(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

; Function Attrs: nounwind uwtable
define dso_local void @aes_inv_cipher(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load i32, ptr @Nb, align 4, !tbaa !9
  %13 = mul nsw i32 4, %12
  %14 = zext i32 %13 to i64
  %15 = call ptr @llvm.stacksave.p0()
  store ptr %15, ptr %7, align 8
  %16 = alloca i8, i64 %14, align 16
  store i64 %14, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  store i8 0, ptr %10, align 1, !tbaa !11
  br label %17

17:                                               ; preds = %51, %3
  %18 = load i8, ptr %10, align 1, !tbaa !11
  %19 = zext i8 %18 to i32
  %20 = icmp slt i32 %19, 4
  br i1 %20, label %21, label %54

21:                                               ; preds = %17
  store i8 0, ptr %11, align 1, !tbaa !11
  br label %22

22:                                               ; preds = %47, %21
  %23 = load i8, ptr %11, align 1, !tbaa !11
  %24 = zext i8 %23 to i32
  %25 = load i32, ptr @Nb, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %27, label %50

27:                                               ; preds = %22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i8, ptr %10, align 1, !tbaa !11
  %30 = zext i8 %29 to i32
  %31 = load i8, ptr %11, align 1, !tbaa !11
  %32 = zext i8 %31 to i32
  %33 = mul nsw i32 4, %32
  %34 = add nsw i32 %30, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %28, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = load i32, ptr @Nb, align 4, !tbaa !9
  %39 = load i8, ptr %10, align 1, !tbaa !11
  %40 = zext i8 %39 to i32
  %41 = mul nsw i32 %38, %40
  %42 = load i8, ptr %11, align 1, !tbaa !11
  %43 = zext i8 %42 to i32
  %44 = add nsw i32 %41, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %16, i64 %45
  store i8 %37, ptr %46, align 1, !tbaa !11
  br label %47

47:                                               ; preds = %27
  %48 = load i8, ptr %11, align 1, !tbaa !11
  %49 = add i8 %48, 1
  store i8 %49, ptr %11, align 1, !tbaa !11
  br label %22, !llvm.loop !12

50:                                               ; preds = %22
  br label %51

51:                                               ; preds = %50
  %52 = load i8, ptr %10, align 1, !tbaa !11
  %53 = add i8 %52, 1
  store i8 %53, ptr %10, align 1, !tbaa !11
  br label %17, !llvm.loop !14

54:                                               ; preds = %17
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load i32, ptr @Nr, align 4, !tbaa !9
  %57 = trunc i32 %56 to i8
  call void @add_round_key(ptr noundef %16, ptr noundef %55, i8 noundef zeroext %57)
  %58 = load i32, ptr @Nr, align 4, !tbaa !9
  %59 = sub nsw i32 %58, 1
  %60 = trunc i32 %59 to i8
  store i8 %60, ptr %9, align 1, !tbaa !11
  br label %61

61:                                               ; preds = %68, %54
  %62 = load i8, ptr %9, align 1, !tbaa !11
  %63 = zext i8 %62 to i32
  %64 = icmp sge i32 %63, 1
  br i1 %64, label %65, label %71

65:                                               ; preds = %61
  call void @inv_shift_rows(ptr noundef %16)
  call void @inv_sub_bytes(ptr noundef %16)
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load i8, ptr %9, align 1, !tbaa !11
  call void @add_round_key(ptr noundef %16, ptr noundef %66, i8 noundef zeroext %67)
  call void @inv_mix_columns(ptr noundef %16)
  br label %68

68:                                               ; preds = %65
  %69 = load i8, ptr %9, align 1, !tbaa !11
  %70 = add i8 %69, -1
  store i8 %70, ptr %9, align 1, !tbaa !11
  br label %61, !llvm.loop !15

71:                                               ; preds = %61
  call void @inv_shift_rows(ptr noundef %16)
  call void @inv_sub_bytes(ptr noundef %16)
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  call void @add_round_key(ptr noundef %16, ptr noundef %72, i8 noundef zeroext 0)
  store i8 0, ptr %10, align 1, !tbaa !11
  br label %73

73:                                               ; preds = %107, %71
  %74 = load i8, ptr %10, align 1, !tbaa !11
  %75 = zext i8 %74 to i32
  %76 = icmp slt i32 %75, 4
  br i1 %76, label %77, label %110

77:                                               ; preds = %73
  store i8 0, ptr %11, align 1, !tbaa !11
  br label %78

78:                                               ; preds = %103, %77
  %79 = load i8, ptr %11, align 1, !tbaa !11
  %80 = zext i8 %79 to i32
  %81 = load i32, ptr @Nb, align 4, !tbaa !9
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %83, label %106

83:                                               ; preds = %78
  %84 = load i32, ptr @Nb, align 4, !tbaa !9
  %85 = load i8, ptr %10, align 1, !tbaa !11
  %86 = zext i8 %85 to i32
  %87 = mul nsw i32 %84, %86
  %88 = load i8, ptr %11, align 1, !tbaa !11
  %89 = zext i8 %88 to i32
  %90 = add nsw i32 %87, %89
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i8, ptr %16, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !11
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load i8, ptr %10, align 1, !tbaa !11
  %96 = zext i8 %95 to i32
  %97 = load i8, ptr %11, align 1, !tbaa !11
  %98 = zext i8 %97 to i32
  %99 = mul nsw i32 4, %98
  %100 = add nsw i32 %96, %99
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds i8, ptr %94, i64 %101
  store i8 %93, ptr %102, align 1, !tbaa !11
  br label %103

103:                                              ; preds = %83
  %104 = load i8, ptr %11, align 1, !tbaa !11
  %105 = add i8 %104, 1
  store i8 %105, ptr %11, align 1, !tbaa !11
  br label %78, !llvm.loop !16

106:                                              ; preds = %78
  br label %107

107:                                              ; preds = %106
  %108 = load i8, ptr %10, align 1, !tbaa !11
  %109 = add i8 %108, 1
  store i8 %109, ptr %10, align 1, !tbaa !11
  br label %73, !llvm.loop !17

110:                                              ; preds = %73
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  %111 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %111)
  ret void
}

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 = { nocallback nofree nosync nounwind willreturn }
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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}


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

@Nb = external dso_local local_unnamed_addr global i32, align 4
@Nr = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @add_round_key(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @inv_mix_columns(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @inv_shift_rows(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @inv_sub_bytes(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @aes_inv_cipher(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr @Nb, align 4, !tbaa !5
  %5 = shl nsw i32 %4, 2
  %6 = zext i32 %5 to i64
  %7 = alloca i8, i64 %6, align 16
  %8 = icmp sgt i32 %4, 0
  br i1 %8, label %iter.check, label %.split37.us

iter.check:                                       ; preds = %3
  %min.iters.check = icmp ult i32 %4, 9
  br i1 %min.iters.check, label %.preheader33.us.preheader.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %iter.check
  %9 = add nsw i32 %4, -1
  %10 = and i32 %9, 255
  %11 = icmp eq i32 %10, 255
  %12 = icmp ugt i32 %9, 255
  %13 = or i1 %11, %12
  br i1 %13, label %.preheader33.us.preheader.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %vector.scevcheck
  %min.iters.check56 = icmp ult i32 %4, 17
  br i1 %min.iters.check56, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.mod.vf = and i32 %4, 15
  %14 = icmp eq i32 %n.mod.vf, 0
  %15 = select i1 %14, i32 16, i32 %n.mod.vf
  %n.vec = sub nsw i32 %4, %15
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %16 = shl nuw nsw i32 %index, 2
  %17 = zext nneg i32 %16 to i64
  %18 = getelementptr inbounds i8, ptr %0, i64 %17
  %wide.vec = load <64 x i8>, ptr %18, align 1, !tbaa !9
  %strided.vec = shufflevector <64 x i8> %wide.vec, <64 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60>
  %19 = zext nneg i32 %index to i64
  %20 = getelementptr inbounds i8, ptr %7, i64 %19
  store <16 x i8> %strided.vec, ptr %20, align 16, !tbaa !9
  %index.next = add nuw i32 %index, 16
  %21 = icmp eq i32 %index.next, %n.vec
  br i1 %21, label %vec.epilog.iter.check, label %vector.body, !llvm.loop !10

vec.epilog.iter.check:                            ; preds = %vector.body
  %ind.end59 = trunc i32 %n.vec to i8
  %min.epilog.iters.check = icmp ult i32 %15, 9
  br i1 %min.epilog.iters.check, label %.preheader33.us.preheader.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i32 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.mod.vf57 = and i32 %4, 7
  %22 = icmp eq i32 %n.mod.vf57, 0
  %23 = select i1 %22, i32 8, i32 %n.mod.vf57
  %n.vec58 = sub nsw i32 %4, %23
  %ind.end = trunc i32 %n.vec58 to i8
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index61 = phi i32 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next64, %vec.epilog.vector.body ]
  %24 = shl nuw nsw i32 %index61, 2
  %25 = zext nneg i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %0, i64 %25
  %wide.vec62 = load <32 x i8>, ptr %26, align 1, !tbaa !9
  %strided.vec63 = shufflevector <32 x i8> %wide.vec62, <32 x i8> poison, <8 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28>
  %27 = zext nneg i32 %index61 to i64
  %28 = getelementptr inbounds i8, ptr %7, i64 %27
  store <8 x i8> %strided.vec63, ptr %28, align 1, !tbaa !9
  %index.next64 = add nuw i32 %index61, 8
  %29 = icmp eq i32 %index.next64, %n.vec58
  br i1 %29, label %.preheader33.us.preheader.preheader, label %vec.epilog.vector.body, !llvm.loop !14

.preheader33.us.preheader.preheader:              ; preds = %vec.epilog.vector.body, %vector.scevcheck, %iter.check, %vec.epilog.iter.check
  %.ph169 = phi i32 [ 0, %iter.check ], [ 0, %vector.scevcheck ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec58, %vec.epilog.vector.body ]
  %.034.us.ph = phi i8 [ 0, %iter.check ], [ 0, %vector.scevcheck ], [ %ind.end59, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.vector.body ]
  br label %.preheader33.us.preheader

.preheader33.us.preheader:                        ; preds = %.preheader33.us.preheader.preheader, %.preheader33.us.preheader
  %30 = phi i32 [ %38, %.preheader33.us.preheader ], [ %.ph169, %.preheader33.us.preheader.preheader ]
  %.034.us = phi i8 [ %37, %.preheader33.us.preheader ], [ %.034.us.ph, %.preheader33.us.preheader.preheader ]
  %31 = shl nuw nsw i32 %30, 2
  %32 = zext nneg i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = zext nneg i32 %30 to i64
  %36 = getelementptr inbounds i8, ptr %7, i64 %35
  store i8 %34, ptr %36, align 1, !tbaa !9
  %37 = add i8 %.034.us, 1
  %38 = zext i8 %37 to i32
  %39 = icmp ugt i32 %4, %38
  br i1 %39, label %.preheader33.us.preheader, label %iter.check70, !llvm.loop !15

iter.check70:                                     ; preds = %.preheader33.us.preheader
  %umax66 = tail call i32 @llvm.umax.i32(i32 %4, i32 1)
  %min.iters.check68 = icmp ult i32 %4, 9
  br i1 %min.iters.check68, label %._crit_edge.us.preheader, label %vector.scevcheck65

vector.scevcheck65:                               ; preds = %iter.check70
  %40 = add nsw i32 %4, -1
  %41 = and i32 %40, 255
  %42 = icmp eq i32 %41, 255
  %43 = icmp ugt i32 %40, 255
  %44 = or i1 %42, %43
  br i1 %44, label %._crit_edge.us.preheader, label %vector.main.loop.iter.check72

vector.main.loop.iter.check72:                    ; preds = %vector.scevcheck65
  %min.iters.check71 = icmp ult i32 %4, 17
  br i1 %min.iters.check71, label %vec.epilog.ph83, label %vector.ph73

vector.ph73:                                      ; preds = %vector.main.loop.iter.check72
  %n.mod.vf74 = and i32 %umax66, 15
  %45 = icmp eq i32 %n.mod.vf74, 0
  %46 = select i1 %45, i32 16, i32 %n.mod.vf74
  %n.vec75 = sub nsw i32 %umax66, %46
  br label %vector.body76

vector.body76:                                    ; preds = %vector.body76, %vector.ph73
  %index77 = phi i32 [ 0, %vector.ph73 ], [ %index.next80, %vector.body76 ]
  %47 = shl nuw nsw i32 %index77, 2
  %48 = or disjoint i32 %47, 1
  %49 = zext nneg i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %0, i64 %49
  %wide.vec78 = load <64 x i8>, ptr %50, align 1, !tbaa !9
  %strided.vec79 = shufflevector <64 x i8> %wide.vec78, <64 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60>
  %51 = add nuw nsw i32 %index77, %4
  %52 = zext nneg i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %7, i64 %52
  store <16 x i8> %strided.vec79, ptr %53, align 1, !tbaa !9
  %index.next80 = add nuw i32 %index77, 16
  %54 = icmp eq i32 %index.next80, %n.vec75
  br i1 %54, label %vec.epilog.iter.check84, label %vector.body76, !llvm.loop !16

vec.epilog.iter.check84:                          ; preds = %vector.body76
  %ind.end92 = trunc i32 %n.vec75 to i8
  %min.epilog.iters.check86 = icmp ult i32 %46, 9
  br i1 %min.epilog.iters.check86, label %._crit_edge.us.preheader, label %vec.epilog.ph83

vec.epilog.ph83:                                  ; preds = %vector.main.loop.iter.check72, %vec.epilog.iter.check84
  %vec.epilog.resume.val87 = phi i32 [ %n.vec75, %vec.epilog.iter.check84 ], [ 0, %vector.main.loop.iter.check72 ]
  %n.mod.vf88 = and i32 %umax66, 7
  %55 = icmp eq i32 %n.mod.vf88, 0
  %56 = select i1 %55, i32 8, i32 %n.mod.vf88
  %n.vec89 = sub nsw i32 %umax66, %56
  %ind.end91 = trunc i32 %n.vec89 to i8
  br label %vec.epilog.vector.body94

vec.epilog.vector.body94:                         ; preds = %vec.epilog.vector.body94, %vec.epilog.ph83
  %index95 = phi i32 [ %vec.epilog.resume.val87, %vec.epilog.ph83 ], [ %index.next98, %vec.epilog.vector.body94 ]
  %57 = shl nuw nsw i32 %index95, 2
  %58 = or disjoint i32 %57, 1
  %59 = zext nneg i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %0, i64 %59
  %wide.vec96 = load <32 x i8>, ptr %60, align 1, !tbaa !9
  %strided.vec97 = shufflevector <32 x i8> %wide.vec96, <32 x i8> poison, <8 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28>
  %61 = add nuw nsw i32 %index95, %4
  %62 = zext nneg i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %7, i64 %62
  store <8 x i8> %strided.vec97, ptr %63, align 1, !tbaa !9
  %index.next98 = add nuw i32 %index95, 8
  %64 = icmp eq i32 %index.next98, %n.vec89
  br i1 %64, label %._crit_edge.us.preheader, label %vec.epilog.vector.body94, !llvm.loop !17

._crit_edge.us.preheader:                         ; preds = %vec.epilog.vector.body94, %vector.scevcheck65, %iter.check70, %vec.epilog.iter.check84
  %.ph168 = phi i32 [ 0, %iter.check70 ], [ 0, %vector.scevcheck65 ], [ %n.vec75, %vec.epilog.iter.check84 ], [ %n.vec89, %vec.epilog.vector.body94 ]
  %.034.us.1.ph = phi i8 [ 0, %iter.check70 ], [ 0, %vector.scevcheck65 ], [ %ind.end92, %vec.epilog.iter.check84 ], [ %ind.end91, %vec.epilog.vector.body94 ]
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.preheader, %._crit_edge.us
  %65 = phi i32 [ %75, %._crit_edge.us ], [ %.ph168, %._crit_edge.us.preheader ]
  %.034.us.1 = phi i8 [ %74, %._crit_edge.us ], [ %.034.us.1.ph, %._crit_edge.us.preheader ]
  %66 = shl nuw nsw i32 %65, 2
  %67 = or disjoint i32 %66, 1
  %68 = zext nneg i32 %67 to i64
  %69 = getelementptr inbounds i8, ptr %0, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !9
  %71 = add nuw nsw i32 %65, %4
  %72 = zext nneg i32 %71 to i64
  %73 = getelementptr inbounds i8, ptr %7, i64 %72
  store i8 %70, ptr %73, align 1, !tbaa !9
  %74 = add i8 %.034.us.1, 1
  %75 = zext i8 %74 to i32
  %76 = icmp ugt i32 %4, %75
  br i1 %76, label %._crit_edge.us, label %iter.check103, !llvm.loop !18

iter.check103:                                    ; preds = %._crit_edge.us
  %77 = shl nuw nsw i32 %4, 1
  %min.iters.check101 = icmp ult i32 %4, 9
  br i1 %min.iters.check101, label %vec.epilog.scalar.ph115.preheader, label %vector.scevcheck99

vector.scevcheck99:                               ; preds = %iter.check103
  %78 = add nsw i32 %umax66, -1
  %79 = and i32 %78, 255
  %80 = icmp eq i32 %79, 255
  %81 = icmp ugt i32 %78, 255
  %82 = or i1 %80, %81
  br i1 %82, label %vec.epilog.scalar.ph115.preheader, label %vector.main.loop.iter.check105

vector.main.loop.iter.check105:                   ; preds = %vector.scevcheck99
  %min.iters.check104 = icmp ult i32 %4, 17
  br i1 %min.iters.check104, label %vec.epilog.ph116, label %vector.ph106

vector.ph106:                                     ; preds = %vector.main.loop.iter.check105
  %n.mod.vf107 = and i32 %umax66, 15
  %83 = icmp eq i32 %n.mod.vf107, 0
  %84 = select i1 %83, i32 16, i32 %n.mod.vf107
  %n.vec108 = sub nsw i32 %umax66, %84
  br label %vector.body109

vector.body109:                                   ; preds = %vector.body109, %vector.ph106
  %index110 = phi i32 [ 0, %vector.ph106 ], [ %index.next113, %vector.body109 ]
  %85 = shl nuw nsw i32 %index110, 2
  %86 = or disjoint i32 %85, 2
  %87 = zext nneg i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %0, i64 %87
  %wide.vec111 = load <64 x i8>, ptr %88, align 1, !tbaa !9
  %strided.vec112 = shufflevector <64 x i8> %wide.vec111, <64 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60>
  %89 = add nuw nsw i32 %index110, %77
  %90 = zext nneg i32 %89 to i64
  %91 = getelementptr inbounds i8, ptr %7, i64 %90
  store <16 x i8> %strided.vec112, ptr %91, align 2, !tbaa !9
  %index.next113 = add nuw i32 %index110, 16
  %92 = icmp eq i32 %index.next113, %n.vec108
  br i1 %92, label %vec.epilog.iter.check117, label %vector.body109, !llvm.loop !19

vec.epilog.iter.check117:                         ; preds = %vector.body109
  %ind.end125 = trunc i32 %n.vec108 to i8
  %min.epilog.iters.check119 = icmp ult i32 %84, 9
  br i1 %min.epilog.iters.check119, label %vec.epilog.scalar.ph115.preheader, label %vec.epilog.ph116

vec.epilog.ph116:                                 ; preds = %vector.main.loop.iter.check105, %vec.epilog.iter.check117
  %vec.epilog.resume.val120 = phi i32 [ %n.vec108, %vec.epilog.iter.check117 ], [ 0, %vector.main.loop.iter.check105 ]
  %n.mod.vf121 = and i32 %umax66, 7
  %93 = icmp eq i32 %n.mod.vf121, 0
  %94 = select i1 %93, i32 8, i32 %n.mod.vf121
  %n.vec122 = sub nsw i32 %umax66, %94
  %ind.end124 = trunc i32 %n.vec122 to i8
  br label %vec.epilog.vector.body127

vec.epilog.vector.body127:                        ; preds = %vec.epilog.vector.body127, %vec.epilog.ph116
  %index128 = phi i32 [ %vec.epilog.resume.val120, %vec.epilog.ph116 ], [ %index.next131, %vec.epilog.vector.body127 ]
  %95 = shl nuw nsw i32 %index128, 2
  %96 = or disjoint i32 %95, 2
  %97 = zext nneg i32 %96 to i64
  %98 = getelementptr inbounds i8, ptr %0, i64 %97
  %wide.vec129 = load <32 x i8>, ptr %98, align 1, !tbaa !9
  %strided.vec130 = shufflevector <32 x i8> %wide.vec129, <32 x i8> poison, <8 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28>
  %99 = add nuw nsw i32 %index128, %77
  %100 = zext nneg i32 %99 to i64
  %101 = getelementptr inbounds i8, ptr %7, i64 %100
  store <8 x i8> %strided.vec130, ptr %101, align 1, !tbaa !9
  %index.next131 = add nuw i32 %index128, 8
  %102 = icmp eq i32 %index.next131, %n.vec122
  br i1 %102, label %vec.epilog.scalar.ph115.preheader, label %vec.epilog.vector.body127, !llvm.loop !20

vec.epilog.scalar.ph115.preheader:                ; preds = %vec.epilog.vector.body127, %vector.scevcheck99, %iter.check103, %vec.epilog.iter.check117
  %.ph167 = phi i32 [ 0, %iter.check103 ], [ 0, %vector.scevcheck99 ], [ %n.vec108, %vec.epilog.iter.check117 ], [ %n.vec122, %vec.epilog.vector.body127 ]
  %.034.us.2.ph = phi i8 [ 0, %iter.check103 ], [ 0, %vector.scevcheck99 ], [ %ind.end125, %vec.epilog.iter.check117 ], [ %ind.end124, %vec.epilog.vector.body127 ]
  br label %vec.epilog.scalar.ph115

vec.epilog.scalar.ph115:                          ; preds = %vec.epilog.scalar.ph115.preheader, %vec.epilog.scalar.ph115
  %103 = phi i32 [ %113, %vec.epilog.scalar.ph115 ], [ %.ph167, %vec.epilog.scalar.ph115.preheader ]
  %.034.us.2 = phi i8 [ %112, %vec.epilog.scalar.ph115 ], [ %.034.us.2.ph, %vec.epilog.scalar.ph115.preheader ]
  %104 = shl nuw nsw i32 %103, 2
  %105 = or disjoint i32 %104, 2
  %106 = zext nneg i32 %105 to i64
  %107 = getelementptr inbounds i8, ptr %0, i64 %106
  %108 = load i8, ptr %107, align 1, !tbaa !9
  %109 = add nuw nsw i32 %103, %77
  %110 = zext nneg i32 %109 to i64
  %111 = getelementptr inbounds i8, ptr %7, i64 %110
  store i8 %108, ptr %111, align 1, !tbaa !9
  %112 = add i8 %.034.us.2, 1
  %113 = zext i8 %112 to i32
  %114 = icmp ugt i32 %4, %113
  br i1 %114, label %vec.epilog.scalar.ph115, label %iter.check136, !llvm.loop !21

iter.check136:                                    ; preds = %vec.epilog.scalar.ph115
  %115 = mul nuw nsw i32 %4, 3
  %min.iters.check134 = icmp ult i32 %4, 9
  br i1 %min.iters.check134, label %vec.epilog.scalar.ph148.preheader, label %vector.scevcheck132

vector.scevcheck132:                              ; preds = %iter.check136
  %116 = add nsw i32 %umax66, -1
  %117 = and i32 %116, 255
  %118 = icmp eq i32 %117, 255
  %119 = icmp ugt i32 %116, 255
  %120 = or i1 %118, %119
  br i1 %120, label %vec.epilog.scalar.ph148.preheader, label %vector.main.loop.iter.check138

vector.main.loop.iter.check138:                   ; preds = %vector.scevcheck132
  %min.iters.check137 = icmp ult i32 %4, 17
  br i1 %min.iters.check137, label %vec.epilog.ph149, label %vector.ph139

vector.ph139:                                     ; preds = %vector.main.loop.iter.check138
  %n.mod.vf140 = and i32 %umax66, 15
  %121 = icmp eq i32 %n.mod.vf140, 0
  %122 = select i1 %121, i32 16, i32 %n.mod.vf140
  %n.vec141 = sub nsw i32 %umax66, %122
  br label %vector.body142

vector.body142:                                   ; preds = %vector.body142, %vector.ph139
  %index143 = phi i32 [ 0, %vector.ph139 ], [ %index.next146, %vector.body142 ]
  %123 = shl nuw nsw i32 %index143, 2
  %124 = or disjoint i32 %123, 3
  %125 = zext nneg i32 %124 to i64
  %126 = getelementptr inbounds i8, ptr %0, i64 %125
  %wide.vec144 = load <64 x i8>, ptr %126, align 1, !tbaa !9
  %strided.vec145 = shufflevector <64 x i8> %wide.vec144, <64 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60>
  %127 = add nuw nsw i32 %index143, %115
  %128 = zext nneg i32 %127 to i64
  %129 = getelementptr inbounds i8, ptr %7, i64 %128
  store <16 x i8> %strided.vec145, ptr %129, align 1, !tbaa !9
  %index.next146 = add nuw i32 %index143, 16
  %130 = icmp eq i32 %index.next146, %n.vec141
  br i1 %130, label %vec.epilog.iter.check150, label %vector.body142, !llvm.loop !22

vec.epilog.iter.check150:                         ; preds = %vector.body142
  %ind.end158 = trunc i32 %n.vec141 to i8
  %min.epilog.iters.check152 = icmp ult i32 %122, 9
  br i1 %min.epilog.iters.check152, label %vec.epilog.scalar.ph148.preheader, label %vec.epilog.ph149

vec.epilog.ph149:                                 ; preds = %vector.main.loop.iter.check138, %vec.epilog.iter.check150
  %vec.epilog.resume.val153 = phi i32 [ %n.vec141, %vec.epilog.iter.check150 ], [ 0, %vector.main.loop.iter.check138 ]
  %n.mod.vf154 = and i32 %umax66, 7
  %131 = icmp eq i32 %n.mod.vf154, 0
  %132 = select i1 %131, i32 8, i32 %n.mod.vf154
  %n.vec155 = sub nsw i32 %umax66, %132
  %ind.end157 = trunc i32 %n.vec155 to i8
  br label %vec.epilog.vector.body160

vec.epilog.vector.body160:                        ; preds = %vec.epilog.vector.body160, %vec.epilog.ph149
  %index161 = phi i32 [ %vec.epilog.resume.val153, %vec.epilog.ph149 ], [ %index.next164, %vec.epilog.vector.body160 ]
  %133 = shl nuw nsw i32 %index161, 2
  %134 = or disjoint i32 %133, 3
  %135 = zext nneg i32 %134 to i64
  %136 = getelementptr inbounds i8, ptr %0, i64 %135
  %wide.vec162 = load <32 x i8>, ptr %136, align 1, !tbaa !9
  %strided.vec163 = shufflevector <32 x i8> %wide.vec162, <32 x i8> poison, <8 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28>
  %137 = add nuw nsw i32 %index161, %115
  %138 = zext nneg i32 %137 to i64
  %139 = getelementptr inbounds i8, ptr %7, i64 %138
  store <8 x i8> %strided.vec163, ptr %139, align 1, !tbaa !9
  %index.next164 = add nuw i32 %index161, 8
  %140 = icmp eq i32 %index.next164, %n.vec155
  br i1 %140, label %vec.epilog.scalar.ph148.preheader, label %vec.epilog.vector.body160, !llvm.loop !23

vec.epilog.scalar.ph148.preheader:                ; preds = %vec.epilog.vector.body160, %vector.scevcheck132, %iter.check136, %vec.epilog.iter.check150
  %.ph = phi i32 [ 0, %iter.check136 ], [ 0, %vector.scevcheck132 ], [ %n.vec141, %vec.epilog.iter.check150 ], [ %n.vec155, %vec.epilog.vector.body160 ]
  %.034.us.3.ph = phi i8 [ 0, %iter.check136 ], [ 0, %vector.scevcheck132 ], [ %ind.end158, %vec.epilog.iter.check150 ], [ %ind.end157, %vec.epilog.vector.body160 ]
  br label %vec.epilog.scalar.ph148

vec.epilog.scalar.ph148:                          ; preds = %vec.epilog.scalar.ph148.preheader, %vec.epilog.scalar.ph148
  %141 = phi i32 [ %151, %vec.epilog.scalar.ph148 ], [ %.ph, %vec.epilog.scalar.ph148.preheader ]
  %.034.us.3 = phi i8 [ %150, %vec.epilog.scalar.ph148 ], [ %.034.us.3.ph, %vec.epilog.scalar.ph148.preheader ]
  %142 = shl nuw nsw i32 %141, 2
  %143 = or disjoint i32 %142, 3
  %144 = zext nneg i32 %143 to i64
  %145 = getelementptr inbounds i8, ptr %0, i64 %144
  %146 = load i8, ptr %145, align 1, !tbaa !9
  %147 = add nuw nsw i32 %141, %115
  %148 = zext nneg i32 %147 to i64
  %149 = getelementptr inbounds i8, ptr %7, i64 %148
  store i8 %146, ptr %149, align 1, !tbaa !9
  %150 = add i8 %.034.us.3, 1
  %151 = zext i8 %150 to i32
  %152 = icmp ugt i32 %4, %151
  br i1 %152, label %vec.epilog.scalar.ph148, label %.split37.us, !llvm.loop !24

.split37.us:                                      ; preds = %vec.epilog.scalar.ph148, %3
  %153 = load i32, ptr @Nr, align 4, !tbaa !5
  %154 = trunc i32 %153 to i8
  call void @add_round_key(ptr noundef nonnull %7, ptr noundef %2, i8 noundef zeroext %154)
  %155 = load i32, ptr @Nr, align 4, !tbaa !5
  %156 = trunc i32 %155 to i8
  %.02638 = add i8 %156, -1
  %.not39 = icmp eq i8 %.02638, 0
  br i1 %.not39, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.split37.us, %.lr.ph
  %.02640 = phi i8 [ %.026, %.lr.ph ], [ %.02638, %.split37.us ]
  call void @inv_shift_rows(ptr noundef nonnull %7)
  call void @inv_sub_bytes(ptr noundef nonnull %7)
  call void @add_round_key(ptr noundef nonnull %7, ptr noundef %2, i8 noundef zeroext %.02640)
  call void @inv_mix_columns(ptr noundef nonnull %7)
  %.026 = add i8 %.02640, -1
  %.not = icmp eq i8 %.026, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph, %.split37.us
  call void @inv_shift_rows(ptr noundef nonnull %7)
  call void @inv_sub_bytes(ptr noundef nonnull %7)
  call void @add_round_key(ptr noundef nonnull %7, ptr noundef %2, i8 noundef zeroext 0)
  %157 = load i32, ptr @Nb, align 4, !tbaa !5
  %158 = icmp sgt i32 %157, 0
  br i1 %158, label %.lr.ph42, label %.split47.us

.lr.ph42:                                         ; preds = %._crit_edge, %.lr.ph42
  %159 = phi i32 [ %167, %.lr.ph42 ], [ 0, %._crit_edge ]
  %.141 = phi i8 [ %166, %.lr.ph42 ], [ 0, %._crit_edge ]
  %160 = zext nneg i32 %159 to i64
  %161 = getelementptr inbounds i8, ptr %7, i64 %160
  %162 = load i8, ptr %161, align 1, !tbaa !9
  %163 = shl nuw nsw i32 %159, 2
  %164 = zext nneg i32 %163 to i64
  %165 = getelementptr inbounds i8, ptr %1, i64 %164
  store i8 %162, ptr %165, align 1, !tbaa !9
  %166 = add i8 %.141, 1
  %167 = zext i8 %166 to i32
  %168 = load i32, ptr @Nb, align 4, !tbaa !5
  %169 = icmp sgt i32 %168, %167
  br i1 %169, label %.lr.ph42, label %._crit_edge43, !llvm.loop !26

._crit_edge43:                                    ; preds = %.lr.ph42
  %170 = icmp sgt i32 %168, 0
  br i1 %170, label %.lr.ph42.1, label %.split47.us

.lr.ph42.1:                                       ; preds = %._crit_edge43, %.lr.ph42.1
  %171 = phi i32 [ %183, %.lr.ph42.1 ], [ %168, %._crit_edge43 ]
  %172 = phi i32 [ %182, %.lr.ph42.1 ], [ 0, %._crit_edge43 ]
  %.141.1 = phi i8 [ %181, %.lr.ph42.1 ], [ 0, %._crit_edge43 ]
  %173 = add nuw nsw i32 %171, %172
  %174 = zext nneg i32 %173 to i64
  %175 = getelementptr inbounds i8, ptr %7, i64 %174
  %176 = load i8, ptr %175, align 1, !tbaa !9
  %177 = shl nuw nsw i32 %172, 2
  %178 = or disjoint i32 %177, 1
  %179 = zext nneg i32 %178 to i64
  %180 = getelementptr inbounds i8, ptr %1, i64 %179
  store i8 %176, ptr %180, align 1, !tbaa !9
  %181 = add i8 %.141.1, 1
  %182 = zext i8 %181 to i32
  %183 = load i32, ptr @Nb, align 4, !tbaa !5
  %184 = icmp sgt i32 %183, %182
  br i1 %184, label %.lr.ph42.1, label %._crit_edge43.1, !llvm.loop !26

._crit_edge43.1:                                  ; preds = %.lr.ph42.1
  %185 = icmp sgt i32 %183, 0
  br i1 %185, label %.lr.ph42.2, label %.split47.us

.lr.ph42.2:                                       ; preds = %._crit_edge43.1, %.lr.ph42.2
  %186 = phi i32 [ %199, %.lr.ph42.2 ], [ %183, %._crit_edge43.1 ]
  %187 = phi i32 [ %198, %.lr.ph42.2 ], [ 0, %._crit_edge43.1 ]
  %.141.2 = phi i8 [ %197, %.lr.ph42.2 ], [ 0, %._crit_edge43.1 ]
  %188 = shl nuw nsw i32 %186, 1
  %189 = add nuw nsw i32 %188, %187
  %190 = zext nneg i32 %189 to i64
  %191 = getelementptr inbounds i8, ptr %7, i64 %190
  %192 = load i8, ptr %191, align 1, !tbaa !9
  %193 = shl nuw nsw i32 %187, 2
  %194 = or disjoint i32 %193, 2
  %195 = zext nneg i32 %194 to i64
  %196 = getelementptr inbounds i8, ptr %1, i64 %195
  store i8 %192, ptr %196, align 1, !tbaa !9
  %197 = add i8 %.141.2, 1
  %198 = zext i8 %197 to i32
  %199 = load i32, ptr @Nb, align 4, !tbaa !5
  %200 = icmp sgt i32 %199, %198
  br i1 %200, label %.lr.ph42.2, label %._crit_edge43.2, !llvm.loop !26

._crit_edge43.2:                                  ; preds = %.lr.ph42.2
  %201 = icmp sgt i32 %199, 0
  br i1 %201, label %.lr.ph42.3, label %.split47.us

.lr.ph42.3:                                       ; preds = %._crit_edge43.2, %.lr.ph42.3
  %202 = phi i32 [ %215, %.lr.ph42.3 ], [ %199, %._crit_edge43.2 ]
  %203 = phi i32 [ %214, %.lr.ph42.3 ], [ 0, %._crit_edge43.2 ]
  %.141.3 = phi i8 [ %213, %.lr.ph42.3 ], [ 0, %._crit_edge43.2 ]
  %204 = mul nsw i32 %202, 3
  %205 = add nuw nsw i32 %204, %203
  %206 = zext nneg i32 %205 to i64
  %207 = getelementptr inbounds i8, ptr %7, i64 %206
  %208 = load i8, ptr %207, align 1, !tbaa !9
  %209 = shl nuw nsw i32 %203, 2
  %210 = or disjoint i32 %209, 3
  %211 = zext nneg i32 %210 to i64
  %212 = getelementptr inbounds i8, ptr %1, i64 %211
  store i8 %208, ptr %212, align 1, !tbaa !9
  %213 = add i8 %.141.3, 1
  %214 = zext i8 %213 to i32
  %215 = load i32, ptr @Nb, align 4, !tbaa !5
  %216 = icmp sgt i32 %215, %214
  br i1 %216, label %.lr.ph42.3, label %.split47.us, !llvm.loop !26

.split47.us:                                      ; preds = %.lr.ph42.3, %._crit_edge43, %._crit_edge43.1, %._crit_edge43.2, %._crit_edge
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #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 speculatable willreturn memory(none) }

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11, !12, !13}
!15 = distinct !{!15, !11, !12}
!16 = distinct !{!16, !11, !12, !13}
!17 = distinct !{!17, !11, !12, !13}
!18 = distinct !{!18, !11, !12}
!19 = distinct !{!19, !11, !12, !13}
!20 = distinct !{!20, !11, !12, !13}
!21 = distinct !{!21, !11, !12}
!22 = distinct !{!22, !11, !12, !13}
!23 = distinct !{!23, !11, !12, !13}
!24 = distinct !{!24, !11, !12}
!25 = distinct !{!25, !11}
!26 = distinct !{!26, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass