; LLVM IR from heremaps/tin-terrain :: src/Delaunator.ll (ZN14delaunator_cpp10Delaunator8hash_keyEdd)

; 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.delaunator_cpp::Delaunator" = type { %"class.std::vector", %"class.std::vector.0", double, double, i64, %"class.std::vector.0", %"class.std::vector.5" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long, std::allocator<unsigned long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long, std::allocator<long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<delaunator_cpp::DelaunatorPoint, std::allocator<delaunator_cpp::DelaunatorPoint>>::_Vector_impl" }
%"struct.std::_Vector_base<delaunator_cpp::DelaunatorPoint, std::allocator<delaunator_cpp::DelaunatorPoint>>::_Vector_impl" = type { %"struct.std::_Vector_base<delaunator_cpp::DelaunatorPoint, std::allocator<delaunator_cpp::DelaunatorPoint>>::_Vector_impl_data" }
%"struct.std::_Vector_base<delaunator_cpp::DelaunatorPoint, std::allocator<delaunator_cpp::DelaunatorPoint>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 noundef i64 @_ZN14delaunator_cpp10Delaunator8hash_keyEdd(ptr noundef nonnull align 8 dereferenceable(120) %0, double noundef %1, double noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %14 = load double, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.delaunator_cpp::Delaunator", ptr %13, i32 0, i32 2
  %16 = load double, ptr %15, align 8, !tbaa !11
  %17 = fsub double %14, %16
  store double %17, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = load double, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.delaunator_cpp::Delaunator", ptr %13, i32 0, i32 3
  %20 = load double, ptr %19, align 8, !tbaa !26
  %21 = fsub double %18, %20
  store double %21, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %22 = load double, ptr %7, align 8, !tbaa !9
  %23 = call noundef double @_ZSt3absd(double noundef %22)
  %24 = load double, ptr %8, align 8, !tbaa !9
  %25 = call noundef double @_ZSt3absd(double noundef %24)
  %26 = fadd double %23, %25
  store double %26, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  %27 = load double, ptr %9, align 8, !tbaa !9
  %28 = fcmp une double %27, 0.000000e+00
  br i1 %28, label %29, label %34

29:                                               ; preds = %3
  %30 = load double, ptr %7, align 8, !tbaa !9
  %31 = load double, ptr %9, align 8, !tbaa !9
  %32 = fdiv double %30, %31
  %33 = fsub double 1.000000e+00, %32
  store double %33, ptr %10, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %29, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %35 = load double, ptr %8, align 8, !tbaa !9
  %36 = fcmp olt double %35, 0.000000e+00
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = fneg double %38
  br label %42

40:                                               ; preds = %34
  %41 = load double, ptr %10, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %40, %37
  %43 = phi double [ %39, %37 ], [ %41, %40 ]
  %44 = fadd double 2.000000e+00, %43
  store double %44, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %45 = getelementptr inbounds %"class.delaunator_cpp::Delaunator", ptr %13, i32 0, i32 4
  %46 = load i64, ptr %45, align 8, !tbaa !27
  %47 = sub nsw i64 %46, 1
  %48 = sitofp i64 %47 to double
  %49 = load double, ptr %11, align 8, !tbaa !9
  %50 = fdiv double %49, 4.000000e+00
  %51 = fmul double %48, %50
  %52 = call double @llvm.floor.f64(double %51)
  %53 = fptosi double %52 to i64
  store i64 %53, ptr %12, align 8, !tbaa !28
  %54 = load i64, ptr %12, align 8, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i64 %54
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !10, i64 48}
!12 = !{!"_ZTSN14delaunator_cpp10DelaunatorE", !13, i64 0, !17, i64 24, !10, i64 48, !10, i64 56, !21, i64 64, !17, i64 72, !22, i64 96}
!13 = !{!"_ZTSSt6vectorImSaImEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseImSaImEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTSSt6vectorIlSaIlEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIlSaIlEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSSt6vectorIN14delaunator_cpp15DelaunatorPointESaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIN14delaunator_cpp15DelaunatorPointESaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIN14delaunator_cpp15DelaunatorPointESaIS1_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIN14delaunator_cpp15DelaunatorPointESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!12, !10, i64 56}
!27 = !{!12, !21, i64 64}
!28 = !{!21, !21, i64 0}


; 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 i64 @_ZN14delaunator_cpp10Delaunator8hash_keyEdd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(120) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fsub double %1, %5
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load double, ptr %7, align 8, !tbaa !24
  %9 = fsub double %2, %8
  %10 = tail call noundef double @_ZSt3absd(double noundef %6)
  %11 = tail call noundef double @_ZSt3absd(double noundef %9)
  %12 = fadd double %10, %11
  %13 = fcmp une double %12, 0.000000e+00
  %14 = fdiv double %6, %12
  %15 = fsub double 1.000000e+00, %14
  %.0 = select i1 %13, double %15, double 0.000000e+00
  %16 = fcmp olt double %9, 0.000000e+00
  %17 = fneg double %.0
  %18 = select i1 %16, double %17, double %.0
  %19 = fadd double %18, 2.000000e+00
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  %21 = load i64, ptr %20, align 8, !tbaa !25
  %22 = add nsw i64 %21, -1
  %23 = sitofp i64 %22 to double
  %24 = fmul double %19, 2.500000e-01
  %25 = fmul double %24, %23
  %26 = tail call double @llvm.floor.f64(double %25)
  %27 = fptosi double %26 to i64
  ret i64 %27
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #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" }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !18, i64 48}
!6 = !{!"_ZTSN14delaunator_cpp10DelaunatorE", !7, i64 0, !14, i64 24, !18, i64 48, !18, i64 56, !19, i64 64, !14, i64 72, !20, i64 96}
!7 = !{!"_ZTSSt6vectorImSaImEE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseImSaImEE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseImSaImEE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseImSaImEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSSt6vectorIlSaIlEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIlSaIlEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIlSaIlEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!18 = !{!"double", !12, i64 0}
!19 = !{!"long", !12, i64 0}
!20 = !{!"_ZTSSt6vectorIN14delaunator_cpp15DelaunatorPointESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN14delaunator_cpp15DelaunatorPointESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN14delaunator_cpp15DelaunatorPointESaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN14delaunator_cpp15DelaunatorPointESaIS1_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!24 = !{!6, !18, i64 56}
!25 = !{!6, !19, i64 64}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass