; LLVM IR from robotics-upo/Heuristic_path_planners :: include/voro++-0.4.6/src/container.ll (ZN4voro9wall_list20increase_wall_memoryEv)

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

%"class.voro::wall_list" = type <{ ptr, ptr, ptr, i32, [4 x i8] }>

@.str.11 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4voro16voro_fatal_errorEPKci(ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4voro9wall_list20increase_wall_memoryEv(ptr noundef nonnull align 8 dereferenceable(28) %0) #5 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 3
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = shl i32 %8, 1
  store i32 %9, ptr %7, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 3
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = icmp sgt i32 %11, 2048
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  call void @_ZN4voro16voro_fatal_errorEPKci(ptr noundef @.str.11, i32 noundef 2)
  br label %14

14:                                               ; preds = %13, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %15 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 3
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %17, i64 8)
  %19 = extractvalue { i64, i1 } %18, 1
  %20 = extractvalue { i64, i1 } %18, 0
  %21 = select i1 %19, i64 -1, i64 %20
  %22 = call noalias noundef nonnull ptr @_Znam(i64 noundef %21) #7
  store ptr %22, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %23, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %24 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  store ptr %25, ptr %5, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %31, %14
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = icmp ult ptr %27, %29
  br i1 %30, label %31, label %37

31:                                               ; preds = %26
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %32, i32 1
  store ptr %33, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %32, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds ptr, ptr %35, i32 1
  store ptr %36, ptr %4, align 8, !tbaa !5
  store ptr %34, ptr %35, align 8, !tbaa !5
  br label %26, !llvm.loop !14

37:                                               ; preds = %26
  %38 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !12
  %40 = icmp eq ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  call void @_ZdaPv(ptr noundef %39) #8
  br label %42

42:                                               ; preds = %41, %37
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 0
  store ptr %43, ptr %44, align 8, !tbaa !12
  %45 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !12
  %47 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 3
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %46, i64 %49
  %51 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 2
  store ptr %50, ptr %51, align 8, !tbaa !16
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.voro::wall_list", ptr %6, i32 0, i32 1
  store ptr %52, ptr %53, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nobuiltin nounwind "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 #4 = { inlinehint 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 #5 = { mustprogress 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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, !11, i64 24}
!10 = !{!"_ZTSN4voro9wall_listE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !6, i64 16}


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

@.str.11 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4voro16voro_fatal_errorEPKci(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4voro9wall_list20increase_wall_memoryEv(ptr nocapture noundef nonnull align 8 dereferenceable(28) %0) local_unnamed_addr #3 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = shl i32 %3, 1
  store i32 %4, ptr %2, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, 2048
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  tail call void @_ZN4voro16voro_fatal_errorEPKci(ptr noundef nonnull @.str.11, i32 noundef 2)
  %.pre = load i32, ptr %2, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %6, %1
  %8 = phi i32 [ %.pre, %6 ], [ %4, %1 ]
  %9 = sext i32 %8 to i64
  %10 = icmp slt i32 %8, 0
  %11 = shl nsw i64 %9, 3
  %12 = select i1 %10, i64 -1, i64 %11
  %13 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %12) #5
  %14 = load ptr, ptr %0, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = icmp ult ptr %14, %16
  br i1 %17, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %7
  %18 = ptrtoint ptr %14 to i64
  %19 = ptrtoint ptr %13 to i64
  %20 = ptrtoint ptr %16 to i64
  %21 = add i64 %18, 8
  %umax = tail call i64 @llvm.umax.i64(i64 %20, i64 %21)
  %22 = xor i64 %18, -1
  %23 = add i64 %umax, %22
  %24 = lshr i64 %23, 3
  %25 = add nuw nsw i64 %24, 1
  %min.iters.check = icmp ult i64 %23, 56
  %26 = sub i64 %19, %18
  %diff.check = icmp ult i64 %26, 32
  %or.cond = or i1 %min.iters.check, %diff.check
  br i1 %or.cond, label %.lr.ph.preheader20, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %25, 4611686018427387900
  %27 = shl i64 %n.vec, 3
  %ind.end = getelementptr i8, ptr %14, i64 %27
  %28 = shl i64 %n.vec, 3
  %ind.end13 = getelementptr i8, ptr %13, i64 %28
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 3
  %next.gep = getelementptr i8, ptr %14, i64 %offset.idx
  %offset.idx16 = shl i64 %index, 3
  %next.gep17 = getelementptr i8, ptr %13, i64 %offset.idx16
  %29 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <2 x ptr>, ptr %next.gep, align 8, !tbaa !13
  %wide.load19 = load <2 x ptr>, ptr %29, align 8, !tbaa !13
  %30 = getelementptr i8, ptr %next.gep17, i64 16
  store <2 x ptr> %wide.load, ptr %next.gep17, align 8, !tbaa !13
  store <2 x ptr> %wide.load19, ptr %30, align 8, !tbaa !13
  %index.next = add nuw i64 %index, 4
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %25, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader20

.lr.ph.preheader20:                               ; preds = %middle.block, %.lr.ph.preheader
  %.010.ph = phi ptr [ %14, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.079.ph = phi ptr [ %13, %.lr.ph.preheader ], [ %ind.end13, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader20, %.lr.ph
  %.010 = phi ptr [ %32, %.lr.ph ], [ %.010.ph, %.lr.ph.preheader20 ]
  %.079 = phi ptr [ %34, %.lr.ph ], [ %.079.ph, %.lr.ph.preheader20 ]
  %32 = getelementptr inbounds i8, ptr %.010, i64 8
  %33 = load ptr, ptr %.010, align 8, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %.079, i64 8
  store ptr %33, ptr %.079, align 8, !tbaa !13
  %35 = icmp ult ptr %32, %16
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %7
  %.07.lcssa = phi ptr [ %13, %7 ], [ %ind.end13, %middle.block ], [ %34, %.lr.ph ]
  %36 = icmp eq ptr %14, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %._crit_edge
  tail call void @_ZdaPv(ptr noundef nonnull %14) #6
  %.pre11 = load i32, ptr %2, align 8, !tbaa !5
  %.pre12 = sext i32 %.pre11 to i64
  br label %38

38:                                               ; preds = %37, %._crit_edge
  %.pre-phi = phi i64 [ %.pre12, %37 ], [ %9, %._crit_edge ]
  store ptr %13, ptr %0, align 8, !tbaa !11
  %39 = getelementptr inbounds ptr, ptr %13, i64 %.pre-phi
  %40 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %39, ptr %40, align 8, !tbaa !19
  store ptr %.07.lcssa, ptr %15, align 8, !tbaa !12
  ret void
}

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

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { inlinehint 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 #3 = { mustprogress 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { builtin 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, !10, i64 24}
!6 = !{!"_ZTSN4voro9wall_listE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15, !16}
!19 = !{!6, !7, i64 16}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass