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

; 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::pre_container_base" = type { double, double, double, double, double, double, i8, i8, i8, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; 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: mustprogress uwtable
define dso_local void @_ZN4voro18pre_container_base9new_chunkEv(ptr noundef nonnull align 8 dereferenceable(128) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 12
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds ptr, ptr %5, i32 1
  store ptr %6, ptr %4, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 17
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds ptr, ptr %8, i32 1
  store ptr %9, ptr %7, align 8, !tbaa !14
  %10 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 12
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 13
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = icmp eq ptr %11, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  call void @_ZN4voro18pre_container_base18extend_chunk_indexEv(ptr noundef nonnull align 8 dereferenceable(128) %3)
  br label %16

16:                                               ; preds = %15, %1
  %17 = call noalias noundef nonnull ptr @_Znam(i64 noundef 4096) #3
  %18 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 12
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %17, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 14
  store ptr %17, ptr %20, align 8, !tbaa !16
  %21 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 14
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = getelementptr inbounds i32, ptr %22, i64 1024
  %24 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 15
  store ptr %23, ptr %24, align 8, !tbaa !17
  %25 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 9
  %26 = load i32, ptr %25, align 4, !tbaa !18
  %27 = mul nsw i32 %26, 1024
  %28 = sext i32 %27 to i64
  %29 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %28, i64 8)
  %30 = extractvalue { i64, i1 } %29, 1
  %31 = extractvalue { i64, i1 } %29, 0
  %32 = select i1 %30, i64 -1, i64 %31
  %33 = call noalias noundef nonnull ptr @_Znam(i64 noundef %32) #3
  %34 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 17
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  store ptr %33, ptr %35, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.voro::pre_container_base", ptr %3, i32 0, i32 18
  store ptr %33, ptr %36, align 8, !tbaa !19
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4voro18pre_container_base18extend_chunk_indexEv(ptr noundef nonnull align 8 dereferenceable(128)) #2 align 2

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 = { 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 #3 = { builtin allocsize(0) }

!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, !6, i64 72}
!10 = !{!"_ZTSN4voro18pre_container_baseE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !12, i64 49, !12, i64 50, !13, i64 52, !13, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!11 = !{!"double", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !6, i64 112}
!15 = !{!10, !6, i64 80}
!16 = !{!10, !6, i64 88}
!17 = !{!10, !6, i64 96}
!18 = !{!10, !13, i64 52}
!19 = !{!10, !6, i64 120}


; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4voro18pre_container_base9new_chunkEv(ptr noundef nonnull align 8 dereferenceable(128) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %4, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %7, ptr %5, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = icmp eq ptr %4, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  tail call void @_ZN4voro18pre_container_base18extend_chunk_indexEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %11, %1
  %13 = phi ptr [ %.pre, %11 ], [ %4, %1 ]
  %14 = tail call noalias noundef nonnull dereferenceable(4096) ptr @_Znam(i64 noundef 4096) #2
  store ptr %14, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %14, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %14, i64 4096
  %17 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr %16, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 52
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = shl nsw i32 %19, 10
  %21 = sext i32 %20 to i64
  %22 = icmp slt i32 %19, 0
  %23 = shl nsw i64 %21, 3
  %24 = select i1 %22, i64 -1, i64 %23
  %25 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %24) #2
  %26 = load ptr, ptr %5, align 8, !tbaa !13
  store ptr %25, ptr %26, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %25, ptr %27, align 8, !tbaa !19
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4voro18pre_container_base18extend_chunk_indexEv(ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #1 align 2

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 = { 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 #2 = { builtin allocsize(0) }

!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, !12, i64 72}
!6 = !{!"_ZTSN4voro18pre_container_baseE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !10, i64 49, !10, i64 50, !11, i64 52, !11, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !12, i64 112}
!14 = !{!6, !12, i64 80}
!15 = !{!12, !12, i64 0}
!16 = !{!6, !12, i64 88}
!17 = !{!6, !12, i64 96}
!18 = !{!6, !11, i64 52}
!19 = !{!6, !12, i64 120}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass