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

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

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

7:                                                ; preds = %31, %2
  %8 = load i8, ptr %6, align 1, !tbaa !9
  %9 = zext i8 %8 to i32
  %10 = load i8, ptr %4, align 1, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = icmp slt i32 %9, %11
  br i1 %12, label %13, label %34

13:                                               ; preds = %7
  %14 = load i64, ptr %3, align 8, !tbaa !5
  %15 = and i64 %14, 1
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %17, label %28

17:                                               ; preds = %13
  %18 = load i8, ptr %4, align 1, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = sub nsw i32 %19, 1
  %21 = load i8, ptr %6, align 1, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = sub nsw i32 %20, %22
  %24 = shl i32 1, %23
  %25 = sext i32 %24 to i64
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = or i64 %26, %25
  store i64 %27, ptr %5, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %17, %13
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %30 = lshr i64 %29, 1
  store i64 %30, ptr %3, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %28
  %32 = load i8, ptr %6, align 1, !tbaa !9
  %33 = add i8 %32, 1
  store i8 %33, ptr %6, align 1, !tbaa !9
  br label %7, !llvm.loop !10

34:                                               ; preds = %7
  %35 = load i64, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i64 %35
}

; 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 = !{!"long", !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"}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i64 @_Z7reflectmh(i64 noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = zext i8 %1 to i32
  %.not16 = icmp eq i8 %1, 0
  br i1 %.not16, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %xtraiter = and i32 %3, 1
  %4 = icmp eq i8 %1, 1
  br i1 %4, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %3, 254
  br label %.lr.ph

.lr.ph:                                           ; preds = %20, %.lr.ph.preheader.new
  %indvars.iv = phi i32 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %20 ]
  %.0914 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %.1.1, %20 ]
  %.01013 = phi i64 [ %0, %.lr.ph.preheader.new ], [ %12, %20 ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %20 ]
  %5 = and i64 %.01013, 1
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %.lr.ph.1, label %6

6:                                                ; preds = %.lr.ph
  %7 = xor i32 %indvars.iv, -1
  %8 = add nsw i32 %7, %3
  %9 = shl nuw i32 1, %8
  %10 = sext i32 %9 to i64
  %11 = or i64 %.0914, %10
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %6, %.lr.ph
  %.1 = phi i64 [ %11, %6 ], [ %.0914, %.lr.ph ]
  %12 = lshr i64 %.01013, 2
  %13 = and i64 %.01013, 2
  %.not.1 = icmp eq i64 %13, 0
  br i1 %.not.1, label %20, label %14

14:                                               ; preds = %.lr.ph.1
  %15 = xor i32 %indvars.iv, -2
  %16 = add nsw i32 %15, %3
  %17 = shl nuw i32 1, %16
  %18 = sext i32 %17 to i64
  %19 = or i64 %.1, %18
  br label %20

20:                                               ; preds = %14, %.lr.ph.1
  %.1.1 = phi i64 [ %19, %14 ], [ %.1, %.lr.ph.1 ]
  %indvars.iv.next.1 = add nuw nsw i32 %indvars.iv, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa.loopexit, label %.lr.ph, !llvm.loop !5

._crit_edge.loopexit.unr-lcssa.loopexit:          ; preds = %20
  %21 = sub nuw i32 -3, %indvars.iv
  br label %._crit_edge.loopexit.unr-lcssa

._crit_edge.loopexit.unr-lcssa:                   ; preds = %._crit_edge.loopexit.unr-lcssa.loopexit, %.lr.ph.preheader
  %.1.lcssa.ph = phi i64 [ poison, %.lr.ph.preheader ], [ %.1.1, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %indvars.iv.unr = phi i32 [ -1, %.lr.ph.preheader ], [ %21, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.0914.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %.1.1, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.01013.unr = phi i64 [ %0, %.lr.ph.preheader ], [ %12, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %22 = and i64 %.01013.unr, 1
  %.not.epil = icmp eq i64 %22, 0
  %23 = add nsw i32 %indvars.iv.unr, %3
  %24 = shl nuw i32 1, %23
  %25 = sext i32 %24 to i64
  %26 = or i64 %.0914.unr, %25
  %.1.epil = select i1 %.not.epil, i64 %.0914.unr, i64 %26
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %2
  %.09.lcssa = phi i64 [ 0, %2 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.1.epil, %.lr.ph.epil ]
  ret i64 %.09.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass