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

; 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::container_base" = type <{ %"class.voro::voro_base", %"class.voro::wall_list.base", [4 x i8], double, double, double, double, double, double, i8, i8, i8, [5 x i8], ptr, ptr, ptr, ptr, i32, [4 x i8] }>
%"class.voro::voro_base" = type { i32, i32, i32, i32, i32, double, double, double, double, double, double, ptr }
%"class.voro::wall_list.base" = type <{ ptr, ptr, ptr, i32 }>

@.str.4 = external hidden unnamed_addr constant [33 x i8], align 1

; 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 uwtable
define dso_local void @_ZN4voro14container_base12region_countEv(ptr noundef nonnull align 8 dereferenceable(204) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = getelementptr inbounds %"class.voro::container_base", ptr %7, i32 0, i32 15
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %10

10:                                               ; preds = %43, %1
  %11 = load i32, ptr %5, align 4, !tbaa !16
  %12 = getelementptr inbounds %"class.voro::voro_base", ptr %7, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !17
  %14 = icmp slt i32 %11, %13
  br i1 %14, label %15, label %46

15:                                               ; preds = %10
  store i32 0, ptr %4, align 4, !tbaa !16
  br label %16

16:                                               ; preds = %39, %15
  %17 = load i32, ptr %4, align 4, !tbaa !16
  %18 = getelementptr inbounds %"class.voro::voro_base", ptr %7, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %21, label %42

21:                                               ; preds = %16
  store i32 0, ptr %3, align 4, !tbaa !16
  br label %22

22:                                               ; preds = %35, %21
  %23 = load i32, ptr %3, align 4, !tbaa !16
  %24 = getelementptr inbounds %"class.voro::voro_base", ptr %7, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !19
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %27, label %38

27:                                               ; preds = %22
  %28 = load i32, ptr %3, align 4, !tbaa !16
  %29 = load i32, ptr %4, align 4, !tbaa !16
  %30 = load i32, ptr %5, align 4, !tbaa !16
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds i32, ptr %31, i32 1
  store ptr %32, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %31, align 4, !tbaa !16
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %28, i32 noundef %29, i32 noundef %30, i32 noundef %33)
  br label %35

35:                                               ; preds = %27
  %36 = load i32, ptr %3, align 4, !tbaa !16
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %3, align 4, !tbaa !16
  br label %22, !llvm.loop !20

38:                                               ; preds = %22
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %4, align 4, !tbaa !16
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !16
  br label %16, !llvm.loop !22

42:                                               ; preds = %16
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %5, align 4, !tbaa !16
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !16
  br label %10, !llvm.loop !23

46:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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, !6, i64 184}
!10 = !{!"_ZTSN4voro14container_baseE", !11, i64 0, !14, i64 80, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !13, i64 152, !15, i64 160, !15, i64 161, !15, i64 162, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !12, i64 200}
!11 = !{!"_ZTSN4voro9voro_baseE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !6, i64 72}
!12 = !{!"int", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTSN4voro9wall_listE", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24}
!15 = !{!"bool", !7, i64 0}
!16 = !{!12, !12, i64 0}
!17 = !{!11, !12, i64 8}
!18 = !{!11, !12, i64 4}
!19 = !{!11, !12, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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.4 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_ZN4voro14container_base12region_countEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(204) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.preheader13.lr.ph, label %._crit_edge23

.preheader13.lr.ph:                               ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader13.preheader, label %._crit_edge23

.preheader13.preheader:                           ; preds = %.preheader13.lr.ph
  %8 = getelementptr inbounds i8, ptr %0, i64 184
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  br label %.preheader13

.preheader13:                                     ; preds = %.preheader13.preheader, %._crit_edge18
  %10 = phi i32 [ %29, %._crit_edge18 ], [ %3, %.preheader13.preheader ]
  %11 = phi i32 [ %30, %._crit_edge18 ], [ %6, %.preheader13.preheader ]
  %12 = phi i32 [ %31, %._crit_edge18 ], [ %6, %.preheader13.preheader ]
  %.022 = phi ptr [ %.1.lcssa, %._crit_edge18 ], [ %9, %.preheader13.preheader ]
  %.01020 = phi i32 [ %32, %._crit_edge18 ], [ 0, %.preheader13.preheader ]
  %13 = icmp sgt i32 %12, 0
  %14 = load i32, ptr %0, align 8
  %15 = icmp sgt i32 %14, 0
  %or.cond = select i1 %13, i1 %15, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge18

.preheader:                                       ; preds = %.preheader13, %._crit_edge
  %16 = phi i32 [ %25, %._crit_edge ], [ %11, %.preheader13 ]
  %17 = phi i32 [ %26, %._crit_edge ], [ %14, %.preheader13 ]
  %.117 = phi ptr [ %.2.lcssa, %._crit_edge ], [ %.022, %.preheader13 ]
  %.01116 = phi i32 [ %27, %._crit_edge ], [ 0, %.preheader13 ]
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.215 = phi ptr [ %19, %.lr.ph ], [ %.117, %.preheader ]
  %.01214 = phi i32 [ %22, %.lr.ph ], [ 0, %.preheader ]
  %19 = getelementptr inbounds i8, ptr %.215, i64 4
  %20 = load i32, ptr %.215, align 4, !tbaa !17
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.01214, i32 noundef %.01116, i32 noundef %.01020, i32 noundef %20)
  %22 = add nuw nsw i32 %.01214, 1
  %23 = load i32, ptr %0, align 8, !tbaa !18
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %5, align 4, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %25 = phi i32 [ %16, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %26 = phi i32 [ %17, %.preheader ], [ %23, %._crit_edge.loopexit ]
  %.2.lcssa = phi ptr [ %.117, %.preheader ], [ %19, %._crit_edge.loopexit ]
  %27 = add nuw nsw i32 %.01116, 1
  %28 = icmp slt i32 %27, %25
  br i1 %28, label %.preheader, label %._crit_edge18.loopexit, !llvm.loop !21

._crit_edge18.loopexit:                           ; preds = %._crit_edge
  %.pre26 = load i32, ptr %2, align 8, !tbaa !5
  br label %._crit_edge18

._crit_edge18:                                    ; preds = %._crit_edge18.loopexit, %.preheader13
  %29 = phi i32 [ %10, %.preheader13 ], [ %.pre26, %._crit_edge18.loopexit ]
  %30 = phi i32 [ %11, %.preheader13 ], [ %25, %._crit_edge18.loopexit ]
  %31 = phi i32 [ %12, %.preheader13 ], [ %25, %._crit_edge18.loopexit ]
  %.1.lcssa = phi ptr [ %.022, %.preheader13 ], [ %.2.lcssa, %._crit_edge18.loopexit ]
  %32 = add nuw nsw i32 %.01020, 1
  %33 = icmp slt i32 %32, %29
  br i1 %33, label %.preheader13, label %._crit_edge23, !llvm.loop !23

._crit_edge23:                                    ; preds = %._crit_edge18, %.preheader13.lr.ph, %1
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree 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 = { nofree 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" }

!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, !7, i64 8}
!6 = !{!"_ZTSN4voro9voro_baseE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !11, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!14, !11, i64 184}
!14 = !{!"_ZTSN4voro14container_baseE", !6, i64 0, !15, i64 80, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !16, i64 160, !16, i64 161, !16, i64 162, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !7, i64 200}
!15 = !{!"_ZTSN4voro9wall_listE", !11, i64 0, !11, i64 8, !11, i64 16, !7, i64 24}
!16 = !{!"bool", !8, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20, !22}
!22 = !{!"llvm.loop.unswitch.partial.disable"}
!23 = distinct !{!23, !20, !22}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass