; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/machsuite-aes (aes)

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

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

; Function Attrs: nounwind uwtable
define dso_local void @aes_subBytes(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i8 16, ptr %3, align 1, !tbaa !9
  br label %5

5:                                                ; preds = %23, %4
  %6 = load i8, ptr %3, align 1, !tbaa !9
  %7 = zext i8 %6 to i32
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %10, label %9

9:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  br label %26

10:                                               ; preds = %5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = load i8, ptr %3, align 1, !tbaa !9
  %13 = zext i8 %12 to i64
  %14 = getelementptr inbounds i8, ptr %11, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !9
  %16 = zext i8 %15 to i64
  %17 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = load i8, ptr %3, align 1, !tbaa !9
  %21 = zext i8 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  store i8 %18, ptr %22, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %10
  %24 = load i8, ptr %3, align 1, !tbaa !9
  %25 = add i8 %24, -1
  store i8 %25, ptr %3, align 1, !tbaa !9
  br label %5, !llvm.loop !10

26:                                               ; preds = %9
  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: 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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@sbox = 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 @aes_subBytes(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i8, ptr %2, align 1, !tbaa !5
  %4 = zext i8 %3 to i64
  %5 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %4
  %6 = load i8, ptr %5, align 1, !tbaa !5
  store i8 %6, ptr %2, align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 15
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !5
  store i8 %11, ptr %7, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 14
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = zext i8 %13 to i64
  %15 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !5
  store i8 %16, ptr %12, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 13
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = zext i8 %18 to i64
  %20 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !5
  store i8 %21, ptr %17, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 12
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = zext i8 %23 to i64
  %25 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !5
  store i8 %26, ptr %22, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 11
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = zext i8 %28 to i64
  %30 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !5
  store i8 %31, ptr %27, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 10
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = zext i8 %33 to i64
  %35 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !5
  store i8 %36, ptr %32, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %0, i64 9
  %38 = load i8, ptr %37, align 1, !tbaa !5
  %39 = zext i8 %38 to i64
  %40 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !5
  store i8 %41, ptr %37, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %0, i64 8
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = zext i8 %43 to i64
  %45 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !5
  store i8 %46, ptr %42, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %0, i64 7
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = zext i8 %48 to i64
  %50 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !5
  store i8 %51, ptr %47, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %0, i64 6
  %53 = load i8, ptr %52, align 1, !tbaa !5
  %54 = zext i8 %53 to i64
  %55 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !5
  store i8 %56, ptr %52, align 1, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %0, i64 5
  %58 = load i8, ptr %57, align 1, !tbaa !5
  %59 = zext i8 %58 to i64
  %60 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !5
  store i8 %61, ptr %57, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %0, i64 4
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = zext i8 %63 to i64
  %65 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !5
  store i8 %66, ptr %62, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %0, i64 3
  %68 = load i8, ptr %67, align 1, !tbaa !5
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !5
  store i8 %71, ptr %67, align 1, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %0, i64 2
  %73 = load i8, ptr %72, align 1, !tbaa !5
  %74 = zext i8 %73 to i64
  %75 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !5
  store i8 %76, ptr %72, align 1, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %0, i64 1
  %78 = load i8, ptr %77, align 1, !tbaa !5
  %79 = zext i8 %78 to i64
  %80 = getelementptr inbounds [256 x i8], ptr @sbox, i64 0, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !5
  store i8 %81, ptr %77, 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/C++ TBAA"}


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