; LLVM IR from dmr-goncalves/HumanAwareRobotNavigation :: src/husky/husky_base/src/horizon_legacy/Number.ll (ZN9clearpath4btouEPvm)

; 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: 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 noundef i64 @_ZN9clearpath4btouEPvm(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !9
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = icmp ne i64 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  store i64 0, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %31

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = sub i64 %13, 1
  store i64 %14, ptr %8, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %25, %12
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = shl i64 %16, 8
  store i64 %17, ptr %6, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %18, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = zext i8 %21 to i64
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = or i64 %23, %22
  store i64 %24, ptr %6, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %15
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = add i64 %26, -1
  store i64 %27, ptr %8, align 8, !tbaa !9
  %28 = icmp ne i64 %26, 0
  br i1 %28, label %15, label %29, !llvm.loop !12

29:                                               ; preds = %25
  %30 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %30, ptr %3, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %31

31:                                               ; preds = %29, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %32 = load i64, ptr %3, align 8
  ret i64 %32
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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(argmem: read) uwtable
define dso_local noundef i64 @_ZN9clearpath4btouEPvm(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %xtraiter = and i64 %1, 3
  %3 = icmp ult i64 %1, 4
  br i1 %3, label %.loopexit.loopexit.unr-lcssa, label %.preheader.preheader.new

.preheader.preheader.new:                         ; preds = %.preheader.preheader
  %unroll_iter = and i64 %1, -4
  %invariant.gep = getelementptr i8, ptr %0, i64 -1
  %invariant.gep15 = getelementptr i8, ptr %0, i64 -2
  %invariant.gep17 = getelementptr i8, ptr %0, i64 -3
  br label %.preheader

.preheader:                                       ; preds = %.preheader, %.preheader.preheader.new
  %.08 = phi i64 [ 0, %.preheader.preheader.new ], [ %20, %.preheader ]
  %.0.in = phi i64 [ %1, %.preheader.preheader.new ], [ %.0.3, %.preheader ]
  %niter = phi i64 [ 0, %.preheader.preheader.new ], [ %niter.next.3, %.preheader ]
  %gep = getelementptr i8, ptr %invariant.gep, i64 %.0.in
  %4 = load i8, ptr %gep, align 1, !tbaa !5
  %5 = zext i8 %4 to i64
  %6 = shl i64 %.08, 16
  %7 = shl nuw nsw i64 %5, 8
  %8 = or disjoint i64 %6, %7
  %gep16 = getelementptr i8, ptr %invariant.gep15, i64 %.0.in
  %9 = load i8, ptr %gep16, align 1, !tbaa !5
  %10 = zext i8 %9 to i64
  %11 = or disjoint i64 %8, %10
  %gep18 = getelementptr i8, ptr %invariant.gep17, i64 %.0.in
  %12 = load i8, ptr %gep18, align 1, !tbaa !5
  %13 = zext i8 %12 to i64
  %.0.3 = add i64 %.0.in, -4
  %14 = shl i64 %11, 16
  %15 = shl nuw nsw i64 %13, 8
  %16 = or disjoint i64 %14, %15
  %17 = getelementptr inbounds i8, ptr %0, i64 %.0.3
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = zext i8 %18 to i64
  %20 = or disjoint i64 %16, %19
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit.loopexit.unr-lcssa, label %.preheader, !llvm.loop !8

.loopexit.loopexit.unr-lcssa:                     ; preds = %.preheader, %.preheader.preheader
  %.lcssa.ph = phi i64 [ poison, %.preheader.preheader ], [ %20, %.preheader ]
  %.08.unr = phi i64 [ 0, %.preheader.preheader ], [ %20, %.preheader ]
  %.0.in.unr = phi i64 [ %1, %.preheader.preheader ], [ %.0.3, %.preheader ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.preheader.epil

.preheader.epil:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.preheader.epil
  %.08.epil = phi i64 [ %25, %.preheader.epil ], [ %.08.unr, %.loopexit.loopexit.unr-lcssa ]
  %.0.in.epil = phi i64 [ %.0.epil, %.preheader.epil ], [ %.0.in.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %.0.epil = add i64 %.0.in.epil, -1
  %21 = shl i64 %.08.epil, 8
  %22 = getelementptr inbounds i8, ptr %0, i64 %.0.epil
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = zext i8 %23 to i64
  %25 = or disjoint i64 %21, %24
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.preheader.epil, !llvm.loop !10

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.unroll.disable"}


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