; LLVM IR from Eaglegor/SchedulerEngine :: Services/Routing/TaillardRoutingService (TaillardRoutingService)

; 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.Scheduler::Route" = type { %"class.Scheduler::Site", %"class.Scheduler::Site", %"class.Scheduler::Distance", %"class.Scheduler::Duration" }
%"class.Scheduler::Site" = type { %"class.Scheduler::Coordinate", %"class.Scheduler::Coordinate" }
%"class.Scheduler::Coordinate" = type { i32 }
%"class.Scheduler::Distance" = type { float }
%"class.Scheduler::Duration" = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9Scheduler22TaillardRoutingService14calculateRouteERKNS_4SiteES3_RKNS_14RoutingProfileE(ptr dead_on_unwind noalias writable sret(%"class.Scheduler::Route") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %"class.Scheduler::Coordinate", align 4
  %13 = alloca i32, align 4
  %14 = alloca %"class.Scheduler::Coordinate", align 4
  %15 = alloca i32, align 4
  %16 = alloca %"class.Scheduler::Coordinate", align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.Scheduler::Coordinate", align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca %"class.Scheduler::Distance", align 4
  %22 = alloca %"class.Scheduler::Duration", align 8
  store ptr %0, ptr %6, align 8
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZNK9Scheduler4Site11getLatitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4 %12, ptr noundef nonnull align 4 dereferenceable(8) %24)
  %25 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  store i32 %25, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZNK9Scheduler4Site12getLongitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4 %14, ptr noundef nonnull align 4 dereferenceable(8) %26)
  %27 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  store i32 %27, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZNK9Scheduler4Site11getLatitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4 %16, ptr noundef nonnull align 4 dereferenceable(8) %28)
  %29 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %16)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  store i32 %29, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZNK9Scheduler4Site12getLongitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4 %18, ptr noundef nonnull align 4 dereferenceable(8) %30)
  %31 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  store i32 %31, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %32 = load i32, ptr %15, align 4, !tbaa !9
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = sub nsw i32 %32, %33
  store i32 %34, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %35 = load i32, ptr %17, align 4, !tbaa !9
  %36 = load i32, ptr %13, align 4, !tbaa !9
  %37 = sub nsw i32 %35, %36
  store i32 %37, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %38 = load i32, ptr %19, align 4, !tbaa !9
  %39 = load i32, ptr %19, align 4, !tbaa !9
  %40 = mul nsw i32 %38, %39
  %41 = load i32, ptr %20, align 4, !tbaa !9
  %42 = load i32, ptr %20, align 4, !tbaa !9
  %43 = mul nsw i32 %41, %42
  %44 = add nsw i32 %40, %43
  %45 = sitofp i32 %44 to double
  %46 = call double @sqrt(double noundef %45) #4
  %47 = fptrunc double %46 to float
  call void @_ZN9Scheduler8DistanceC1Ef(ptr noundef nonnull align 4 dereferenceable(4) %21, float noundef %47)
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9Scheduler14RoutingProfile15getAverageSpeedEv(ptr noundef nonnull align 4 dereferenceable(4) %48)
  call void @_ZN9SchedulerdvERKNS_8DistanceERKNS_5SpeedE(ptr dead_on_unwind writable sret(%"class.Scheduler::Duration") align 8 %22, ptr noundef nonnull align 4 dereferenceable(4) %21, ptr noundef nonnull align 4 dereferenceable(4) %49)
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN9Scheduler5RouteC1ERKNS_4SiteES3_RKNS_8DistanceERKNS_8DurationE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(8) %50, ptr noundef nonnull align 4 dereferenceable(8) %51, ptr noundef nonnull align 4 dereferenceable(4) %21, ptr noundef nonnull align 8 dereferenceable(8) %22)
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

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

declare void @_ZNK9Scheduler4Site11getLatitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4, ptr noundef nonnull align 4 dereferenceable(8)) #2

declare noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4)) #2

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

declare void @_ZNK9Scheduler4Site12getLongitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4, ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

declare void @_ZN9Scheduler8DistanceC1Ef(ptr noundef nonnull align 4 dereferenceable(4), float noundef) unnamed_addr #2

declare void @_ZN9SchedulerdvERKNS_8DistanceERKNS_5SpeedE(ptr dead_on_unwind writable sret(%"class.Scheduler::Duration") align 8, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9Scheduler14RoutingProfile15getAverageSpeedEv(ptr noundef nonnull align 4 dereferenceable(4)) #2

declare void @_ZN9Scheduler5RouteC1ERKNS_4SiteES3_RKNS_8DistanceERKNS_8DurationE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 #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 = !{!"int", !7, 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"

%"class.Scheduler::Route" = type { %"class.Scheduler::Site", %"class.Scheduler::Site", %"class.Scheduler::Distance", %"class.Scheduler::Duration" }
%"class.Scheduler::Site" = type { %"class.Scheduler::Coordinate", %"class.Scheduler::Coordinate" }
%"class.Scheduler::Coordinate" = type { i32 }
%"class.Scheduler::Distance" = type { float }
%"class.Scheduler::Duration" = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK9Scheduler22TaillardRoutingService14calculateRouteERKNS_4SiteES3_RKNS_14RoutingProfileE(ptr dead_on_unwind noalias writable sret(%"class.Scheduler::Route") align 8 %0, ptr nocapture noundef nonnull readnone align 8 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) unnamed_addr #0 align 2 {
  %6 = alloca %"class.Scheduler::Coordinate", align 4
  %7 = alloca %"class.Scheduler::Coordinate", align 4
  %8 = alloca %"class.Scheduler::Coordinate", align 4
  %9 = alloca %"class.Scheduler::Coordinate", align 4
  %10 = alloca %"class.Scheduler::Distance", align 4
  %11 = alloca %"class.Scheduler::Duration", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @_ZNK9Scheduler4Site11getLatitudeEv(ptr dead_on_unwind nonnull writable sret(%"class.Scheduler::Coordinate") align 4 %6, ptr noundef nonnull align 4 dereferenceable(8) %2)
  %12 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  call void @_ZNK9Scheduler4Site12getLongitudeEv(ptr dead_on_unwind nonnull writable sret(%"class.Scheduler::Coordinate") align 4 %7, ptr noundef nonnull align 4 dereferenceable(8) %2)
  %13 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @_ZNK9Scheduler4Site11getLatitudeEv(ptr dead_on_unwind nonnull writable sret(%"class.Scheduler::Coordinate") align 4 %8, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %14 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  call void @_ZNK9Scheduler4Site12getLongitudeEv(ptr dead_on_unwind nonnull writable sret(%"class.Scheduler::Coordinate") align 4 %9, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %15 = call noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  %16 = sub nsw i32 %14, %12
  %17 = sub nsw i32 %15, %13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #4
  %18 = mul nsw i32 %16, %16
  %19 = mul nsw i32 %17, %17
  %20 = add nuw nsw i32 %19, %18
  %21 = uitofp nneg i32 %20 to double
  %sqrt = call double @llvm.sqrt.f64(double %21)
  %22 = fptrunc double %sqrt to float
  call void @_ZN9Scheduler8DistanceC1Ef(ptr noundef nonnull align 4 dereferenceable(4) %10, float noundef %22)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9Scheduler14RoutingProfile15getAverageSpeedEv(ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @_ZN9SchedulerdvERKNS_8DistanceERKNS_5SpeedE(ptr dead_on_unwind nonnull writable sret(%"class.Scheduler::Duration") align 8 %11, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %23)
  call void @_ZN9Scheduler5RouteC1ERKNS_4SiteES3_RKNS_8DistanceERKNS_8DurationE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 8 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #4
  ret void
}

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

declare void @_ZNK9Scheduler4Site11getLatitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

declare noundef i32 @_ZNK9Scheduler10Coordinate8getValueEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

declare void @_ZNK9Scheduler4Site12getLongitudeEv(ptr dead_on_unwind writable sret(%"class.Scheduler::Coordinate") align 4, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

declare void @_ZN9Scheduler8DistanceC1Ef(ptr noundef nonnull align 4 dereferenceable(4), float noundef) unnamed_addr #2

declare void @_ZN9SchedulerdvERKNS_8DistanceERKNS_5SpeedE(ptr dead_on_unwind writable sret(%"class.Scheduler::Duration") align 8, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9Scheduler14RoutingProfile15getAverageSpeedEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

declare void @_ZN9Scheduler5RouteC1ERKNS_4SiteES3_RKNS_8DistanceERKNS_8DurationE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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)"}


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