; LLVM IR from Tinker-Twins/3D-LIDAR-Localization :: fast_gicp/thirdparty/nvbio/contrib/crc/crc.ll (Z7crcInitv)

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

@crcTable = external dso_local global [256 x i32], 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 @_Z7crcInitv() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %34, %0
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 256
  br i1 %6, label %7, label %37

7:                                                ; preds = %4
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = shl i32 %8, 24
  store i32 %9, ptr %1, align 4, !tbaa !5
  store i8 8, ptr %3, align 1, !tbaa !9
  br label %10

10:                                               ; preds = %26, %7
  %11 = load i8, ptr %3, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %29

14:                                               ; preds = %10
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = and i32 %15, -2147483648
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %14
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = shl i32 %19, 1
  %21 = xor i32 %20, 79764919
  store i32 %21, ptr %1, align 4, !tbaa !5
  br label %25

22:                                               ; preds = %14
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = shl i32 %23, 1
  store i32 %24, ptr %1, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %22, %18
  br label %26

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

29:                                               ; preds = %10
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [256 x i32], ptr @crcTable, i64 0, i64 %32
  store i32 %30, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %29
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %4, !llvm.loop !12

37:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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

@crcTable = 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 @_Z7crcInitv() 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 = shl <4 x i32> %vec.ind, <i32 25, i32 25, i32 25, i32 25>
  %1 = xor <4 x i32> %0, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %2 = and <4 x i32> %vec.ind, <i32 128, i32 128, i32 128, i32 128>
  %3 = icmp eq <4 x i32> %2, zeroinitializer
  %4 = select <4 x i1> %3, <4 x i32> %0, <4 x i32> %1
  %5 = shl <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
  %6 = xor <4 x i32> %5, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %7 = icmp slt <4 x i32> %4, zeroinitializer
  %8 = select <4 x i1> %7, <4 x i32> %6, <4 x i32> %5
  %9 = shl <4 x i32> %8, <i32 1, i32 1, i32 1, i32 1>
  %10 = xor <4 x i32> %9, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %11 = icmp slt <4 x i32> %8, zeroinitializer
  %12 = select <4 x i1> %11, <4 x i32> %10, <4 x i32> %9
  %13 = shl <4 x i32> %12, <i32 1, i32 1, i32 1, i32 1>
  %14 = xor <4 x i32> %13, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %15 = icmp slt <4 x i32> %12, zeroinitializer
  %16 = select <4 x i1> %15, <4 x i32> %14, <4 x i32> %13
  %17 = shl <4 x i32> %16, <i32 1, i32 1, i32 1, i32 1>
  %18 = xor <4 x i32> %17, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %19 = icmp slt <4 x i32> %16, zeroinitializer
  %20 = select <4 x i1> %19, <4 x i32> %18, <4 x i32> %17
  %21 = shl <4 x i32> %20, <i32 1, i32 1, i32 1, i32 1>
  %22 = xor <4 x i32> %21, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %23 = icmp slt <4 x i32> %20, zeroinitializer
  %24 = select <4 x i1> %23, <4 x i32> %22, <4 x i32> %21
  %25 = shl <4 x i32> %24, <i32 1, i32 1, i32 1, i32 1>
  %26 = xor <4 x i32> %25, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %27 = icmp slt <4 x i32> %24, zeroinitializer
  %28 = select <4 x i1> %27, <4 x i32> %26, <4 x i32> %25
  %29 = shl <4 x i32> %28, <i32 1, i32 1, i32 1, i32 1>
  %30 = xor <4 x i32> %29, <i32 79764919, i32 79764919, i32 79764919, i32 79764919>
  %31 = icmp slt <4 x i32> %28, zeroinitializer
  %32 = select <4 x i1> %31, <4 x i32> %30, <4 x i32> %29
  %33 = getelementptr inbounds [256 x i32], ptr @crcTable, i64 0, i64 %index
  store <4 x i32> %32, ptr %33, 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>
  %34 = icmp eq i64 %index.next, 256
  br i1 %34, 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,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass