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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4voro13c_loop_subset5startEv(ptr noundef nonnull align 8 dereferenceable(304) %0) #0 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  br label %5

5:                                                ; preds = %17, %1
  %6 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 8
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 12
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i32, ptr %7, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %18

14:                                               ; preds = %5
  %15 = call noundef zeroext i1 @_ZN4voro13c_loop_subset10next_blockEv(ptr noundef nonnull align 8 dereferenceable(304) %4)
  br i1 %15, label %17, label %16

16:                                               ; preds = %14
  store i1 false, ptr %2, align 1
  br label %49

17:                                               ; preds = %14
  br label %5, !llvm.loop !14

18:                                               ; preds = %5
  br label %19

19:                                               ; preds = %47, %18
  %20 = getelementptr inbounds %"class.voro::c_loop_subset", ptr %4, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !16
  %22 = icmp ne i32 %21, 2
  br i1 %22, label %23, label %25

23:                                               ; preds = %19
  %24 = call noundef zeroext i1 @_ZN4voro13c_loop_subset13out_of_boundsEv(ptr noundef nonnull align 8 dereferenceable(304) %4)
  br label %25

25:                                               ; preds = %23, %19
  %26 = phi i1 [ false, %19 ], [ %24, %23 ]
  br i1 %26, label %27, label %48

27:                                               ; preds = %25
  %28 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 13
  %29 = load i32, ptr %28, align 8, !tbaa !21
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 8, !tbaa !21
  br label %31

31:                                               ; preds = %46, %27
  %32 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 13
  %33 = load i32, ptr %32, align 8, !tbaa !21
  %34 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 8
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 12
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %35, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !13
  %41 = icmp sge i32 %33, %40
  br i1 %41, label %42, label %47

42:                                               ; preds = %31
  %43 = getelementptr inbounds %"class.voro::c_loop_base", ptr %4, i32 0, i32 13
  store i32 0, ptr %43, align 8, !tbaa !21
  %44 = call noundef zeroext i1 @_ZN4voro13c_loop_subset10next_blockEv(ptr noundef nonnull align 8 dereferenceable(304) %4)
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  store i1 false, ptr %2, align 1
  br label %49

46:                                               ; preds = %42
  br label %31, !llvm.loop !22

47:                                               ; preds = %31
  br label %19, !llvm.loop !23

48:                                               ; preds = %25
  store i1 true, ptr %2, align 1
  br label %49

49:                                               ; preds = %48, %45, %16
  %50 = load i1, ptr %2, align 1
  ret i1 %50
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4voro13c_loop_subset10next_blockEv(ptr noundef nonnull align 8 dereferenceable(304)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4voro13c_loop_subset13out_of_boundsEv(ptr noundef nonnull align 8 dereferenceable(304)) #1 align 2

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

!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 40}
!10 = !{!"_ZTSN4voro11c_loop_baseE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 60}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !18, i64 68}
!17 = !{!"_ZTSN4voro13c_loop_subsetE", !10, i64 0, !18, i64 68, !19, i64 72, !19, i64 80, !19, i64 88, !19, i64 96, !19, i64 104, !19, i64 112, !19, i64 120, !19, i64 128, !19, i64 136, !20, i64 144, !20, i64 145, !20, i64 146, !19, i64 152, !19, i64 160, !19, i64 168, !19, i64 176, !19, i64 184, !19, i64 192, !19, i64 200, !19, i64 208, !19, i64 216, !19, i64 224, !19, i64 232, !19, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !11, i64 288, !11, i64 292, !11, i64 296, !11, i64 300}
!18 = !{!"_ZTSN4voro18c_loop_subset_modeE", !7, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!10, !11, i64 64}
!22 = distinct !{!22, !15}
!23 = distinct !{!23, !15}


; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4voro13c_loop_subset5startEv(ptr noundef nonnull align 8 dereferenceable(304) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = getelementptr inbounds i8, ptr %0, i64 60
  br label %4

4:                                                ; preds = %14, %1
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = load i32, ptr %3, align 4, !tbaa !11
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds i32, ptr %5, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %14, label %.preheader

.preheader:                                       ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 68
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %.not8 = icmp eq i32 %12, 2
  br i1 %.not8, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  br label %17

14:                                               ; preds = %4
  %15 = tail call noundef zeroext i1 @_ZN4voro13c_loop_subset10next_blockEv(ptr noundef nonnull align 8 dereferenceable(304) %0)
  br i1 %15, label %4, label %.critedge, !llvm.loop !18

.loopexit:                                        ; preds = %22
  %16 = load i32, ptr %11, align 4, !tbaa !13
  %.not = icmp eq i32 %16, 2
  br i1 %.not, label %.critedge, label %17, !llvm.loop !20

17:                                               ; preds = %.lr.ph, %.loopexit
  %18 = tail call noundef zeroext i1 @_ZN4voro13c_loop_subset13out_of_boundsEv(ptr noundef nonnull align 8 dereferenceable(304) %0)
  br i1 %18, label %19, label %.critedge

19:                                               ; preds = %17
  %20 = load i32, ptr %13, align 8, !tbaa !21
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %13, align 8, !tbaa !21
  br label %22

22:                                               ; preds = %29, %19
  %23 = load i32, ptr %13, align 8, !tbaa !21
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr %24, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !12
  %.not2 = icmp slt i32 %23, %28
  br i1 %.not2, label %.loopexit, label %29

29:                                               ; preds = %22
  store i32 0, ptr %13, align 8, !tbaa !21
  %30 = tail call noundef zeroext i1 @_ZN4voro13c_loop_subset10next_blockEv(ptr noundef nonnull align 8 dereferenceable(304) %0)
  br i1 %30, label %22, label %.critedge, !llvm.loop !22

.critedge:                                        ; preds = %14, %.loopexit, %17, %29, %.preheader
  %.0 = phi i1 [ true, %.preheader ], [ false, %29 ], [ true, %17 ], [ true, %.loopexit ], [ false, %14 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4voro13c_loop_subset10next_blockEv(ptr noundef nonnull align 8 dereferenceable(304)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4voro13c_loop_subset13out_of_boundsEv(ptr noundef nonnull align 8 dereferenceable(304)) local_unnamed_addr #0 align 2

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

!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 40}
!6 = !{!"_ZTSN4voro11c_loop_baseE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 60}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !15, i64 68}
!14 = !{!"_ZTSN4voro13c_loop_subsetE", !6, i64 0, !15, i64 68, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !16, i64 104, !16, i64 112, !16, i64 120, !16, i64 128, !16, i64 136, !17, i64 144, !17, i64 145, !17, i64 146, !16, i64 152, !16, i64 160, !16, i64 168, !16, i64 176, !16, i64 184, !16, i64 192, !16, i64 200, !16, i64 208, !16, i64 216, !16, i64 224, !16, i64 232, !16, i64 240, !7, i64 248, !7, i64 252, !7, i64 256, !7, i64 260, !7, i64 264, !7, i64 268, !7, i64 272, !7, i64 276, !7, i64 280, !7, i64 284, !7, i64 288, !7, i64 292, !7, i64 296, !7, i64 300}
!15 = !{!"_ZTSN4voro18c_loop_subset_modeE", !8, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = !{!"bool", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!6, !7, i64 64}
!22 = distinct !{!22, !19}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass