; LLVM IR from laurimi/ase_exploration :: src/ExplorationPlanner/grid (PlanarGridOccupancyMap)

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

%"struct.boost::unordered::iterator_detail::c_iterator.3" = type { ptr }
%"struct.std::pair.4" = type <{ %class.PlanarGridIndex, i8, [3 x i8] }>
%class.PlanarGridIndex = type { i32, i32 }

; 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 nounwind uwtable
declare dso_local ptr @_ZNK19PlanarGridContainerIaE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK22PlanarGridOccupancyMap10getEntropyEv(ptr noundef nonnull align 8 dereferenceable(10) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca %"struct.boost::unordered::iterator_detail::c_iterator.3", align 8
  %5 = alloca %"struct.boost::unordered::iterator_detail::c_iterator.3", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = getelementptr i8, ptr %7, i64 -32
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr %6, i64 %9
  %11 = call ptr @_ZNK19PlanarGridContainerIaE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %10)
  %12 = getelementptr inbounds %"struct.boost::unordered::iterator_detail::c_iterator.3", ptr %4, i32 0, i32 0
  store ptr %11, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !11
  %14 = getelementptr i8, ptr %13, i64 -32
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %6, i64 %15
  %17 = call ptr @_ZNK19PlanarGridContainerIaE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %16)
  %18 = getelementptr inbounds %"struct.boost::unordered::iterator_detail::c_iterator.3", ptr %5, i32 0, i32 0
  store ptr %17, ptr %18, align 8
  br label %19

19:                                               ; preds = %30, %1
  %20 = call noundef zeroext i1 @_ZN5boost9unordered15iterator_detailneERKNS1_10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  br i1 %20, label %22, label %21

21:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %32

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %6, i64 8
  %24 = call noundef ptr @_ZNK5boost9unordered15iterator_detail10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %25 = getelementptr inbounds %"struct.std::pair.4", ptr %24, i32 0, i32 1
  %26 = load i8, ptr %25, align 4, !tbaa !13
  %27 = call noundef double @_ZNK10EntropyLUT3getEa(ptr noundef nonnull align 1 dereferenceable(1) %23, i8 noundef signext %26)
  %28 = load double, ptr %3, align 8, !tbaa !9
  %29 = fadd double %28, %27
  store double %29, ptr %3, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %22
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9unordered15iterator_detail10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  br label %19, !llvm.loop !17

32:                                               ; preds = %21
  %33 = load double, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %33
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK19PlanarGridContainerIaE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK10EntropyLUT3getEa(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef signext) #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !7, i64 8}
!14 = !{!"_ZTSSt4pairIK15PlanarGridIndexaE", !15, i64 0, !7, i64 8}
!15 = !{!"_ZTS15PlanarGridIndex", !16, i64 0, !16, i64 4}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

%"struct.boost::unordered::iterator_detail::c_iterator.3" = type { ptr }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK19PlanarGridContainerIaE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5boost9unordered15iterator_detailneERKNS1_10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK22PlanarGridOccupancyMap10getEntropyEv(ptr noundef nonnull align 8 dereferenceable(10) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %"struct.boost::unordered::iterator_detail::c_iterator.3", align 8
  %3 = alloca %"struct.boost::unordered::iterator_detail::c_iterator.3", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -32
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 %6
  %8 = tail call ptr @_ZNK19PlanarGridContainerIaE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %7)
  store ptr %8, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -32
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr %0, i64 %11
  %13 = tail call ptr @_ZNK19PlanarGridContainerIaE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %12)
  store ptr %13, ptr %3, align 8
  %14 = call noundef zeroext i1 @_ZN5boost9unordered15iterator_detailneERKNS1_10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  br label %16

._crit_edge:                                      ; preds = %16, %1
  %.0.lcssa = phi double [ 0.000000e+00, %1 ], [ %21, %16 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret double %.0.lcssa

16:                                               ; preds = %.lr.ph, %16
  %.03 = phi double [ 0.000000e+00, %.lr.ph ], [ %21, %16 ]
  %17 = call noundef ptr @_ZNK5boost9unordered15iterator_detail10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load i8, ptr %18, align 4, !tbaa !8
  %20 = call noundef double @_ZNK10EntropyLUT3getEa(ptr noundef nonnull align 1 dereferenceable(1) %15, i8 noundef signext %19)
  %21 = fadd double %.03, %20
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9unordered15iterator_detail10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2)
  %23 = call noundef zeroext i1 @_ZN5boost9unordered15iterator_detailneERKNS1_10c_iteratorINS0_6detail8ptr_nodeISt4pairIK15PlanarGridIndexaEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  br i1 %23, label %16, label %._crit_edge, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK19PlanarGridContainerIaE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK10EntropyLUT3getEa(ptr noundef nonnull align 1 dereferenceable(1), i8 noundef signext) local_unnamed_addr #2 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 8}
!9 = !{!"_ZTSSt4pairIK15PlanarGridIndexaE", !10, i64 0, !12, i64 8}
!10 = !{!"_ZTS15PlanarGridIndex", !11, i64 0, !11, i64 4}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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