; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/lzma/C/Common/CRC.ll (ZN4CCRC9InitTableEv)

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

@_ZN4CCRC5TableE = external dso_local global [256 x i32], align 16

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

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

8:                                                ; preds = %5
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %38

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

11:                                               ; preds = %27, %9
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 8
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %30

15:                                               ; preds = %11
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = and i32 %16, 1
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = lshr i32 %20, 1
  %22 = xor i32 %21, -306674912
  store i32 %22, ptr %3, align 4, !tbaa !5
  br label %26

23:                                               ; preds = %15
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = lshr i32 %24, 1
  store i32 %25, ptr %3, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %23, %19
  br label %27

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

30:                                               ; preds = %14
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds [256 x i32], ptr @_ZN4CCRC5TableE, i64 0, i64 %33
  store i32 %31, ptr %34, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %35

35:                                               ; preds = %30
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = add i32 %36, 1
  store i32 %37, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !11

38:                                               ; preds = %8
  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 = { 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 #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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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

@_ZN4CCRC5TableE = external dso_local local_unnamed_addr global [256 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_ZN4CCRC9InitTableEv() local_unnamed_addr #0 align 2 {
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 <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %0 = and <4 x i32> %vec.ind, <i32 1, i32 1, i32 1, i32 1>
  %1 = icmp eq <4 x i32> %0, zeroinitializer
  %2 = lshr <4 x i32> %vec.ind, <i32 1, i32 1, i32 1, i32 1>
  %3 = xor <4 x i32> %2, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %4 = select <4 x i1> %1, <4 x i32> %2, <4 x i32> %3
  %5 = and <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
  %6 = icmp eq <4 x i32> %5, zeroinitializer
  %7 = lshr <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
  %8 = xor <4 x i32> %7, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %9 = select <4 x i1> %6, <4 x i32> %7, <4 x i32> %8
  %10 = and <4 x i32> %9, <i32 1, i32 1, i32 1, i32 1>
  %11 = icmp eq <4 x i32> %10, zeroinitializer
  %12 = lshr <4 x i32> %9, <i32 1, i32 1, i32 1, i32 1>
  %13 = xor <4 x i32> %12, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %14 = select <4 x i1> %11, <4 x i32> %12, <4 x i32> %13
  %15 = and <4 x i32> %14, <i32 1, i32 1, i32 1, i32 1>
  %16 = icmp eq <4 x i32> %15, zeroinitializer
  %17 = lshr <4 x i32> %14, <i32 1, i32 1, i32 1, i32 1>
  %18 = xor <4 x i32> %17, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %19 = select <4 x i1> %16, <4 x i32> %17, <4 x i32> %18
  %20 = and <4 x i32> %19, <i32 1, i32 1, i32 1, i32 1>
  %21 = icmp eq <4 x i32> %20, zeroinitializer
  %22 = lshr <4 x i32> %19, <i32 1, i32 1, i32 1, i32 1>
  %23 = xor <4 x i32> %22, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %24 = select <4 x i1> %21, <4 x i32> %22, <4 x i32> %23
  %25 = and <4 x i32> %24, <i32 1, i32 1, i32 1, i32 1>
  %26 = icmp eq <4 x i32> %25, zeroinitializer
  %27 = lshr <4 x i32> %24, <i32 1, i32 1, i32 1, i32 1>
  %28 = xor <4 x i32> %27, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %29 = select <4 x i1> %26, <4 x i32> %27, <4 x i32> %28
  %30 = and <4 x i32> %29, <i32 1, i32 1, i32 1, i32 1>
  %31 = icmp eq <4 x i32> %30, zeroinitializer
  %32 = lshr <4 x i32> %29, <i32 1, i32 1, i32 1, i32 1>
  %33 = xor <4 x i32> %32, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %34 = select <4 x i1> %31, <4 x i32> %32, <4 x i32> %33
  %35 = and <4 x i32> %34, <i32 1, i32 1, i32 1, i32 1>
  %36 = icmp eq <4 x i32> %35, zeroinitializer
  %37 = lshr <4 x i32> %34, <i32 1, i32 1, i32 1, i32 1>
  %38 = xor <4 x i32> %37, <i32 -306674912, i32 -306674912, i32 -306674912, i32 -306674912>
  %39 = select <4 x i1> %36, <4 x i32> %37, <4 x i32> %38
  %40 = getelementptr inbounds [256 x i32], ptr @_ZN4CCRC5TableE, i64 0, i64 %index
  store <4 x i32> %39, ptr %40, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %41 = icmp eq i64 %index.next, 256
  br i1 %41, label %middle.block, label %vector.body, !llvm.loop !9

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

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}


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