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

; 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 void @_ZN9clearpath4utobEPvmm(ptr noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %27, %3
  %9 = load i64, ptr %7, align 8, !tbaa !9
  %10 = load i64, ptr %5, align 8, !tbaa !9
  %11 = icmp ult i64 %9, %10
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 8
  br label %15

15:                                               ; preds = %12, %8
  %16 = phi i1 [ false, %8 ], [ %14, %12 ]
  br i1 %16, label %17, label %30

17:                                               ; preds = %15
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = mul i64 %19, 8
  %21 = lshr i64 %18, %20
  %22 = and i64 %21, 255
  %23 = trunc i64 %22 to i8
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  store i8 %23, ptr %26, align 1, !tbaa !11
  br label %27

27:                                               ; preds = %17
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = add i64 %28, 1
  store i64 %29, ptr %7, align 8, !tbaa !9
  br label %8, !llvm.loop !12

30:                                               ; preds = %15
  br label %31

31:                                               ; preds = %39, %30
  %32 = load i64, ptr %7, align 8, !tbaa !9
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %35, label %42

35:                                               ; preds = %31
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  store i8 0, ptr %38, align 1, !tbaa !11
  br label %39

39:                                               ; preds = %35
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = add i64 %40, 1
  store i64 %41, ptr %7, align 8, !tbaa !9
  br label %31, !llvm.loop !14

42:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #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 = { 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 = !{!"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"}
!14 = distinct !{!14, !13}


; 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 memory(argmem: write) uwtable
define dso_local void @_ZN9clearpath4utobEPvmm(ptr nocapture noundef writeonly %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %invariant.umin = tail call i64 @llvm.umin.i64(i64 %1, i64 8)
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %.preheader, label %vector.ph

vector.ph:                                        ; preds = %3
  %trip.count.minus.1 = add nsw i64 %invariant.umin, -1
  %broadcast.splatinsert = insertelement <8 x i64> poison, i64 %trip.count.minus.1, i64 0
  %broadcast.splat = shufflevector <8 x i64> %broadcast.splatinsert, <8 x i64> poison, <8 x i32> zeroinitializer
  %4 = icmp uge <8 x i64> %broadcast.splat, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>
  %5 = extractelement <8 x i1> %4, i64 0
  br i1 %5, label %pred.store.if, label %pred.store.continue

pred.store.if:                                    ; preds = %vector.ph
  %6 = trunc i64 %2 to i8
  store i8 %6, ptr %0, align 1, !tbaa !5
  br label %pred.store.continue

pred.store.continue:                              ; preds = %pred.store.if, %vector.ph
  %7 = extractelement <8 x i1> %4, i64 1
  br i1 %7, label %pred.store.if15, label %pred.store.continue16

pred.store.if15:                                  ; preds = %pred.store.continue
  %8 = lshr i64 %2, 8
  %9 = getelementptr inbounds i8, ptr %0, i64 1
  %10 = trunc i64 %8 to i8
  store i8 %10, ptr %9, align 1, !tbaa !5
  br label %pred.store.continue16

pred.store.continue16:                            ; preds = %pred.store.if15, %pred.store.continue
  %11 = extractelement <8 x i1> %4, i64 2
  br i1 %11, label %pred.store.if17, label %pred.store.continue18

pred.store.if17:                                  ; preds = %pred.store.continue16
  %12 = lshr i64 %2, 16
  %13 = getelementptr inbounds i8, ptr %0, i64 2
  %14 = trunc i64 %12 to i8
  store i8 %14, ptr %13, align 1, !tbaa !5
  br label %pred.store.continue18

pred.store.continue18:                            ; preds = %pred.store.if17, %pred.store.continue16
  %15 = extractelement <8 x i1> %4, i64 3
  br i1 %15, label %pred.store.if19, label %pred.store.continue20

pred.store.if19:                                  ; preds = %pred.store.continue18
  %16 = lshr i64 %2, 24
  %17 = getelementptr inbounds i8, ptr %0, i64 3
  %18 = trunc i64 %16 to i8
  store i8 %18, ptr %17, align 1, !tbaa !5
  br label %pred.store.continue20

pred.store.continue20:                            ; preds = %pred.store.if19, %pred.store.continue18
  %19 = extractelement <8 x i1> %4, i64 4
  br i1 %19, label %pred.store.if21, label %pred.store.continue22

pred.store.if21:                                  ; preds = %pred.store.continue20
  %20 = lshr i64 %2, 32
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  %22 = trunc i64 %20 to i8
  store i8 %22, ptr %21, align 1, !tbaa !5
  br label %pred.store.continue22

pred.store.continue22:                            ; preds = %pred.store.if21, %pred.store.continue20
  %23 = extractelement <8 x i1> %4, i64 5
  br i1 %23, label %pred.store.if23, label %pred.store.continue24

pred.store.if23:                                  ; preds = %pred.store.continue22
  %24 = lshr i64 %2, 40
  %25 = getelementptr inbounds i8, ptr %0, i64 5
  %26 = trunc i64 %24 to i8
  store i8 %26, ptr %25, align 1, !tbaa !5
  br label %pred.store.continue24

pred.store.continue24:                            ; preds = %pred.store.if23, %pred.store.continue22
  %27 = extractelement <8 x i1> %4, i64 6
  br i1 %27, label %pred.store.if25, label %pred.store.continue26

pred.store.if25:                                  ; preds = %pred.store.continue24
  %28 = lshr i64 %2, 48
  %29 = getelementptr inbounds i8, ptr %0, i64 6
  %30 = trunc i64 %28 to i8
  store i8 %30, ptr %29, align 1, !tbaa !5
  br label %pred.store.continue26

pred.store.continue26:                            ; preds = %pred.store.if25, %pred.store.continue24
  %31 = extractelement <8 x i1> %4, i64 7
  br i1 %31, label %pred.store.if27, label %.preheader

pred.store.if27:                                  ; preds = %pred.store.continue26
  %32 = lshr i64 %2, 56
  %33 = getelementptr inbounds i8, ptr %0, i64 7
  %34 = trunc nuw i64 %32 to i8
  store i8 %34, ptr %33, align 1, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %pred.store.continue26, %pred.store.if27, %3
  %.0.lcssa = phi i64 [ 0, %3 ], [ %invariant.umin, %pred.store.if27 ], [ %invariant.umin, %pred.store.continue26 ]
  %35 = icmp ult i64 %.0.lcssa, %1
  br i1 %35, label %.lr.ph14.preheader, label %._crit_edge

.lr.ph14.preheader:                               ; preds = %.preheader
  %scevgep = getelementptr i8, ptr %0, i64 %.0.lcssa
  %36 = sub i64 %1, %.0.lcssa
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep, i8 0, i64 %36, i1 false), !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph14.preheader, %.preheader
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: write) 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 speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass