; LLVM IR from openluopworld/aes_128 :: lut (gen_dec_key_table)

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

@I9 = external hidden global [256 x i8], align 16
@Ib = external hidden global [256 x i8], align 16
@Id = external hidden global [256 x i8], align 16
@Ie = external hidden global [256 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local void @generate_mix() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i8, align 1
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  store i8 0, ptr %2, align 1, !tbaa !9
  br label %6

6:                                                ; preds = %106, %0
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 256
  br i1 %8, label %9, label %111

9:                                                ; preds = %6
  %10 = load i8, ptr %2, align 1, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = and i32 %11, 128
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %9
  %15 = load i8, ptr %2, align 1, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = shl i32 %16, 1
  %18 = xor i32 %17, 27
  br label %23

19:                                               ; preds = %9
  %20 = load i8, ptr %2, align 1, !tbaa !9
  %21 = zext i8 %20 to i32
  %22 = shl i32 %21, 1
  br label %23

23:                                               ; preds = %19, %14
  %24 = phi i32 [ %18, %14 ], [ %22, %19 ]
  %25 = trunc i32 %24 to i8
  store i8 %25, ptr %3, align 1, !tbaa !9
  %26 = load i8, ptr %3, align 1, !tbaa !9
  %27 = zext i8 %26 to i32
  %28 = and i32 %27, 128
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %35

30:                                               ; preds = %23
  %31 = load i8, ptr %3, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = shl i32 %32, 1
  %34 = xor i32 %33, 27
  br label %39

35:                                               ; preds = %23
  %36 = load i8, ptr %3, align 1, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = shl i32 %37, 1
  br label %39

39:                                               ; preds = %35, %30
  %40 = phi i32 [ %34, %30 ], [ %38, %35 ]
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %4, align 1, !tbaa !9
  %42 = load i8, ptr %4, align 1, !tbaa !9
  %43 = zext i8 %42 to i32
  %44 = and i32 %43, 128
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %51

46:                                               ; preds = %39
  %47 = load i8, ptr %4, align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = shl i32 %48, 1
  %50 = xor i32 %49, 27
  br label %55

51:                                               ; preds = %39
  %52 = load i8, ptr %4, align 1, !tbaa !9
  %53 = zext i8 %52 to i32
  %54 = shl i32 %53, 1
  br label %55

55:                                               ; preds = %51, %46
  %56 = phi i32 [ %50, %46 ], [ %54, %51 ]
  %57 = trunc i32 %56 to i8
  store i8 %57, ptr %5, align 1, !tbaa !9
  %58 = load i8, ptr %5, align 1, !tbaa !9
  %59 = zext i8 %58 to i32
  %60 = load i8, ptr %2, align 1, !tbaa !9
  %61 = zext i8 %60 to i32
  %62 = xor i32 %59, %61
  %63 = trunc i32 %62 to i8
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [256 x i8], ptr @I9, i64 0, i64 %65
  store i8 %63, ptr %66, align 1, !tbaa !9
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [256 x i8], ptr @I9, i64 0, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !9
  %71 = zext i8 %70 to i32
  %72 = load i8, ptr %3, align 1, !tbaa !9
  %73 = zext i8 %72 to i32
  %74 = xor i32 %71, %73
  %75 = trunc i32 %74 to i8
  %76 = load i32, ptr %1, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [256 x i8], ptr @Ib, i64 0, i64 %77
  store i8 %75, ptr %78, align 1, !tbaa !9
  %79 = load i32, ptr %1, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [256 x i8], ptr @I9, i64 0, i64 %80
  %82 = load i8, ptr %81, align 1, !tbaa !9
  %83 = zext i8 %82 to i32
  %84 = load i8, ptr %4, align 1, !tbaa !9
  %85 = zext i8 %84 to i32
  %86 = xor i32 %83, %85
  %87 = trunc i32 %86 to i8
  %88 = load i32, ptr %1, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [256 x i8], ptr @Id, i64 0, i64 %89
  store i8 %87, ptr %90, align 1, !tbaa !9
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [256 x i8], ptr @Id, i64 0, i64 %92
  %94 = load i8, ptr %93, align 1, !tbaa !9
  %95 = zext i8 %94 to i32
  %96 = load i8, ptr %3, align 1, !tbaa !9
  %97 = zext i8 %96 to i32
  %98 = xor i32 %95, %97
  %99 = load i8, ptr %2, align 1, !tbaa !9
  %100 = zext i8 %99 to i32
  %101 = xor i32 %98, %100
  %102 = trunc i32 %101 to i8
  %103 = load i32, ptr %1, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [256 x i8], ptr @Ie, i64 0, i64 %104
  store i8 %102, ptr %105, align 1, !tbaa !9
  br label %106

106:                                              ; preds = %55
  %107 = load i32, ptr %1, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %1, align 4, !tbaa !5
  %109 = load i8, ptr %2, align 1, !tbaa !9
  %110 = add i8 %109, 1
  store i8 %110, ptr %2, align 1, !tbaa !9
  br label %6, !llvm.loop !10

111:                                              ; preds = %6
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  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 = !{!"int", !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"

@I9 = external hidden local_unnamed_addr global [256 x i8], align 16
@Ib = external hidden local_unnamed_addr global [256 x i8], align 16
@Id = external hidden local_unnamed_addr global [256 x i8], align 16
@Ie = external hidden local_unnamed_addr global [256 x i8], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @generate_mix() local_unnamed_addr #0 {
vector.ph:
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %0 = shl <16 x i8> %vec.ind, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %1 = xor <16 x i8> %0, <i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27>
  %2 = icmp slt <16 x i8> %vec.ind, zeroinitializer
  %3 = select <16 x i1> %2, <16 x i8> %1, <16 x i8> %0
  %4 = shl <16 x i8> %3, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %5 = xor <16 x i8> %4, <i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27>
  %6 = icmp slt <16 x i8> %3, zeroinitializer
  %7 = select <16 x i1> %6, <16 x i8> %5, <16 x i8> %4
  %8 = shl <16 x i8> %7, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %9 = xor <16 x i8> %8, <i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27, i8 27>
  %10 = icmp slt <16 x i8> %7, zeroinitializer
  %11 = select <16 x i1> %10, <16 x i8> %9, <16 x i8> %8
  %12 = xor <16 x i8> %11, %vec.ind
  %13 = getelementptr inbounds [256 x i8], ptr @I9, i64 0, i64 %index
  store <16 x i8> %12, ptr %13, align 16, !tbaa !5
  %14 = xor <16 x i8> %12, %3
  %15 = getelementptr inbounds [256 x i8], ptr @Ib, i64 0, i64 %index
  store <16 x i8> %14, ptr %15, align 16, !tbaa !5
  %16 = xor <16 x i8> %12, %7
  %17 = getelementptr inbounds [256 x i8], ptr @Id, i64 0, i64 %index
  store <16 x i8> %16, ptr %17, align 16, !tbaa !5
  %18 = xor <16 x i8> %3, %vec.ind
  %19 = xor <16 x i8> %18, %16
  %20 = getelementptr inbounds [256 x i8], ptr @Ie, i64 0, i64 %index
  store <16 x i8> %19, ptr %20, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 16
  %vec.ind.next = add <16 x i8> %vec.ind, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
  %21 = icmp eq i64 %index.next, 256
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) 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"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass