; LLVM IR from gem5/gem5 :: src/arch/arm/insts/crypto.ll (ZN4gem56ArmISA6Crypto11aesSubBytesEPhS2_)

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

@_ZN4gem56ArmISA6Crypto7aesSBOXE = external dso_local constant [256 x i8], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4gem56ArmISA6Crypto11aesSubBytesEPhS2_(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  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
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %26, %3
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 16
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %29

13:                                               ; preds = %9
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i8, ptr %14, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = zext i8 %18 to i64
  %20 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  store i8 %21, ptr %25, align 1, !tbaa !11
  br label %26

26:                                               ; preds = %13
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %7, align 4, !tbaa !9
  br label %9, !llvm.loop !12

29:                                               ; preds = %12
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@_ZN4gem56ArmISA6Crypto7aesSBOXE = external dso_local local_unnamed_addr constant [256 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4gem56ArmISA6Crypto11aesSubBytesEPhS2_(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 align 2 {
  %4 = load i8, ptr %2, align 1, !tbaa !5
  %5 = zext i8 %4 to i64
  %6 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !5
  store i8 %7, ptr %1, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = zext i8 %9 to i64
  %11 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %10
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %12, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %2, i64 2
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = zext i8 %15 to i64
  %17 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 %18, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %2, i64 3
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = zext i8 %21 to i64
  %23 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %2, i64 4
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 %30, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %2, i64 5
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = zext i8 %33 to i64
  %35 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %2, i64 6
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = zext i8 %39 to i64
  %41 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %42, ptr %43, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %2, i64 7
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = zext i8 %45 to i64
  %47 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %48, ptr %49, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %2, i64 8
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = zext i8 %51 to i64
  %53 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %52
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %54, ptr %55, align 1, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %2, i64 9
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = zext i8 %57 to i64
  %59 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 %60, ptr %61, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %2, i64 10
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = zext i8 %63 to i64
  %65 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 %66, ptr %67, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %2, i64 11
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %70 = zext i8 %69 to i64
  %71 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 %72, ptr %73, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %2, i64 12
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = zext i8 %75 to i64
  %77 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %78, ptr %79, align 1, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %2, i64 13
  %81 = load i8, ptr %80, align 1, !tbaa !5
  %82 = zext i8 %81 to i64
  %83 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %84, ptr %85, align 1, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %2, i64 14
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = zext i8 %87 to i64
  %89 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 %90, ptr %91, align 1, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %2, i64 15
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = zext i8 %93 to i64
  %95 = getelementptr inbounds [256 x i8], ptr @_ZN4gem56ArmISA6Crypto7aesSBOXE, i64 0, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 %96, ptr %97, align 1, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass