; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/lzma/C/7zip/Archive/7z_C (7zCrc)

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

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

; Function Attrs: nounwind uwtable
define dso_local void @InitCrcTable() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = 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 %4

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

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

9:                                                ; preds = %24, %7
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 8
  br i1 %11, label %12, label %27

12:                                               ; preds = %9
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = and i32 %13, 1
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %20

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = lshr i32 %17, 1
  %19 = xor i32 %18, -306674912
  store i32 %19, ptr %2, align 4, !tbaa !5
  br label %23

20:                                               ; preds = %12
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = lshr i32 %21, 1
  store i32 %22, ptr %2, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %20, %16
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %3, align 4, !tbaa !5
  br label %9, !llvm.loop !9

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

32:                                               ; preds = %27
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = add i32 %33, 1
  store i32 %34, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !11

35:                                               ; preds = %4
  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 = 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"

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

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @InitCrcTable() 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 <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 @g_CrcTable, 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 = { 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/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