; LLVM IR from shupx/swarm_sync_sim :: src/fw_plane_sim/src/px4_lib/geo/geo.ll (ZNK13MapProjection7projectEddRfS0_)

; 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.MapProjection = type <{ i64, double, double, double, double, i8, [7 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math7radiansIdEET_S1_(double noundef) #0

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK13MapProjection7projectEddRfS0_(ptr noundef nonnull align 8 dereferenceable(48) %0, double noundef %1, double noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %20 = load double, ptr %7, align 8, !tbaa !9
  %21 = call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %20)
  store double %21, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %22 = load double, ptr %8, align 8, !tbaa !9
  %23 = call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %22)
  store double %23, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %24 = load double, ptr %11, align 8, !tbaa !9
  %25 = call double @sin(double noundef %24) #5
  store double %25, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %26 = load double, ptr %11, align 8, !tbaa !9
  %27 = call double @cos(double noundef %26) #5
  store double %27, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %28 = load double, ptr %12, align 8, !tbaa !9
  %29 = getelementptr inbounds %class.MapProjection, ptr %19, i32 0, i32 2
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fsub double %28, %30
  %32 = call double @cos(double noundef %31) #5
  store double %32, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %33 = getelementptr inbounds %class.MapProjection, ptr %19, i32 0, i32 3
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = load double, ptr %13, align 8, !tbaa !9
  %36 = getelementptr inbounds %class.MapProjection, ptr %19, i32 0, i32 4
  %37 = load double, ptr %36, align 8, !tbaa !16
  %38 = load double, ptr %14, align 8, !tbaa !9
  %39 = fmul double %37, %38
  %40 = load double, ptr %15, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = call double @llvm.fmuladd.f64(double %34, double %35, double %41)
  %43 = call noundef double @_ZN4math9constrainIdEET_S1_S1_S1_(double noundef %42, double noundef -1.000000e+00, double noundef 1.000000e+00)
  store double %43, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %44 = load double, ptr %16, align 8, !tbaa !9
  %45 = call double @acos(double noundef %44) #5
  store double %45, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store double 1.000000e+00, ptr %18, align 8, !tbaa !9
  %46 = load double, ptr %17, align 8, !tbaa !9
  %47 = call double @llvm.fabs.f64(double %46)
  %48 = fcmp ogt double %47, 0.000000e+00
  br i1 %48, label %49, label %54

49:                                               ; preds = %5
  %50 = load double, ptr %17, align 8, !tbaa !9
  %51 = load double, ptr %17, align 8, !tbaa !9
  %52 = call double @sin(double noundef %51) #5
  %53 = fdiv double %50, %52
  store double %53, ptr %18, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %49, %5
  %55 = load double, ptr %18, align 8, !tbaa !9
  %56 = getelementptr inbounds %class.MapProjection, ptr %19, i32 0, i32 4
  %57 = load double, ptr %56, align 8, !tbaa !16
  %58 = load double, ptr %13, align 8, !tbaa !9
  %59 = getelementptr inbounds %class.MapProjection, ptr %19, i32 0, i32 3
  %60 = load double, ptr %59, align 8, !tbaa !15
  %61 = load double, ptr %14, align 8, !tbaa !9
  %62 = fmul double %60, %61
  %63 = load double, ptr %15, align 8, !tbaa !9
  %64 = fmul double %62, %63
  %65 = fneg double %64
  %66 = call double @llvm.fmuladd.f64(double %57, double %58, double %65)
  %67 = fmul double %55, %66
  %68 = fmul double %67, 6.371000e+06
  %69 = fptrunc double %68 to float
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  store float %69, ptr %70, align 4, !tbaa !17
  %71 = load double, ptr %18, align 8, !tbaa !9
  %72 = load double, ptr %14, align 8, !tbaa !9
  %73 = fmul double %71, %72
  %74 = load double, ptr %12, align 8, !tbaa !9
  %75 = getelementptr inbounds %class.MapProjection, ptr %19, i32 0, i32 2
  %76 = load double, ptr %75, align 8, !tbaa !11
  %77 = fsub double %74, %76
  %78 = call double @sin(double noundef %77) #5
  %79 = fmul double %73, %78
  %80 = fmul double %79, 6.371000e+06
  %81 = fptrunc double %80 to float
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  store float %81, ptr %82, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math9constrainIdEET_S1_S1_S1_(double noundef, double noundef, double noundef) #0

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

; Function Attrs: nounwind
declare double @acos(double noundef) #1

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

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

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 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 16}
!12 = !{!"_ZTS13MapProjection", !13, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !14, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 32}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math7radiansIdEET_S1_(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK13MapProjection7projectEddRfS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, double noundef %1, double noundef %2, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %3, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %4) local_unnamed_addr #0 align 2 {
  %6 = tail call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %1)
  %7 = tail call noundef double @_ZN4math7radiansIdEET_S1_(double noundef %2)
  %8 = tail call double @sin(double noundef %6) #3
  %9 = tail call double @cos(double noundef %6) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fsub double %7, %11
  %13 = tail call double @cos(double noundef %12) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load double, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load double, ptr %16, align 8, !tbaa !13
  %18 = fmul double %9, %17
  %19 = fmul double %13, %18
  %20 = tail call double @llvm.fmuladd.f64(double %15, double %8, double %19)
  %21 = tail call noundef double @_ZN4math9constrainIdEET_S1_S1_S1_(double noundef %20, double noundef -1.000000e+00, double noundef 1.000000e+00)
  %22 = tail call double @acos(double noundef %21) #3
  %23 = fcmp ueq double %22, 0.000000e+00
  br i1 %23, label %27, label %24

24:                                               ; preds = %5
  %25 = tail call double @sin(double noundef %22) #3
  %26 = fdiv double %22, %25
  br label %27

27:                                               ; preds = %24, %5
  %.0 = phi double [ %26, %24 ], [ 1.000000e+00, %5 ]
  %28 = load double, ptr %16, align 8, !tbaa !13
  %29 = load double, ptr %14, align 8, !tbaa !12
  %30 = fneg double %29
  %31 = fmul double %9, %30
  %32 = fmul double %13, %31
  %33 = tail call double @llvm.fmuladd.f64(double %28, double %8, double %32)
  %34 = fmul double %.0, %33
  %35 = fmul double %34, 6.371000e+06
  %36 = fptrunc double %35 to float
  store float %36, ptr %3, align 4, !tbaa !14
  %37 = fmul double %9, %.0
  %38 = load double, ptr %10, align 8, !tbaa !5
  %39 = fsub double %7, %38
  %40 = tail call double @sin(double noundef %39) #3
  %41 = fmul double %37, %40
  %42 = fmul double %41, 6.371000e+06
  %43 = fptrunc double %42 to float
  store float %43, ptr %4, align 4, !tbaa !14
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math9constrainIdEET_S1_S1_S1_(double noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @acos(double noundef) local_unnamed_addr #1

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 = { mustprogress nofree nounwind willreturn memory(write) "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) }
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, !10, i64 16}
!6 = !{!"_ZTS13MapProjection", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !10, i64 32}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}


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