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

; 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: nounwind
declare double @sin(double noundef) #0

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK13MapProjection9reprojectEffRdS0_(ptr noundef nonnull align 8 dereferenceable(48) %0, float noundef %1, float noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #3 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %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
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %19 = load float, ptr %7, align 4, !tbaa !9
  %20 = fpext float %19 to double
  %21 = fdiv double %20, 6.371000e+06
  store double %21, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %22 = load float, ptr %8, align 4, !tbaa !9
  %23 = fpext float %22 to double
  %24 = fdiv double %23, 6.371000e+06
  store double %24, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %25 = load double, ptr %11, align 8, !tbaa !11
  %26 = load double, ptr %11, align 8, !tbaa !11
  %27 = load double, ptr %12, align 8, !tbaa !11
  %28 = load double, ptr %12, align 8, !tbaa !11
  %29 = fmul double %27, %28
  %30 = call double @llvm.fmuladd.f64(double %25, double %26, double %29)
  %31 = call double @sqrt(double noundef %30) #5
  store double %31, ptr %13, align 8, !tbaa !11
  %32 = load double, ptr %13, align 8, !tbaa !11
  %33 = call double @llvm.fabs.f64(double %32)
  %34 = fcmp ogt double %33, 0.000000e+00
  br i1 %34, label %35, label %79

35:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %36 = load double, ptr %13, align 8, !tbaa !11
  %37 = call double @sin(double noundef %36) #5
  store double %37, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %38 = load double, ptr %13, align 8, !tbaa !11
  %39 = call double @cos(double noundef %38) #5
  store double %39, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %40 = load double, ptr %15, align 8, !tbaa !11
  %41 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 3
  %42 = load double, ptr %41, align 8, !tbaa !13
  %43 = load double, ptr %11, align 8, !tbaa !11
  %44 = load double, ptr %14, align 8, !tbaa !11
  %45 = fmul double %43, %44
  %46 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 4
  %47 = load double, ptr %46, align 8, !tbaa !17
  %48 = fmul double %45, %47
  %49 = load double, ptr %13, align 8, !tbaa !11
  %50 = fdiv double %48, %49
  %51 = call double @llvm.fmuladd.f64(double %40, double %42, double %50)
  %52 = call double @asin(double noundef %51) #5
  store double %52, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %53 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 2
  %54 = load double, ptr %53, align 8, !tbaa !18
  %55 = load double, ptr %12, align 8, !tbaa !11
  %56 = load double, ptr %14, align 8, !tbaa !11
  %57 = fmul double %55, %56
  %58 = load double, ptr %13, align 8, !tbaa !11
  %59 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 4
  %60 = load double, ptr %59, align 8, !tbaa !17
  %61 = fmul double %58, %60
  %62 = load double, ptr %15, align 8, !tbaa !11
  %63 = load double, ptr %11, align 8, !tbaa !11
  %64 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 3
  %65 = load double, ptr %64, align 8, !tbaa !13
  %66 = fmul double %63, %65
  %67 = load double, ptr %14, align 8, !tbaa !11
  %68 = fmul double %66, %67
  %69 = fneg double %68
  %70 = call double @llvm.fmuladd.f64(double %61, double %62, double %69)
  %71 = call double @atan2(double noundef %57, double noundef %70) #5
  %72 = fadd double %54, %71
  store double %72, ptr %17, align 8, !tbaa !11
  %73 = load double, ptr %16, align 8, !tbaa !11
  %74 = call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %73)
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  store double %74, ptr %75, align 8, !tbaa !11
  %76 = load double, ptr %17, align 8, !tbaa !11
  %77 = call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %76)
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  store double %77, ptr %78, align 8, !tbaa !11
  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
  br label %88

79:                                               ; preds = %5
  %80 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 1
  %81 = load double, ptr %80, align 8, !tbaa !19
  %82 = call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %81)
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  store double %82, ptr %83, align 8, !tbaa !11
  %84 = getelementptr inbounds %class.MapProjection, ptr %18, i32 0, i32 2
  %85 = load double, ptr %84, align 8, !tbaa !18
  %86 = call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %85)
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  store double %86, ptr %87, align 8, !tbaa !11
  br label %88

88:                                               ; preds = %79, %35
  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: nounwind
declare double @sqrt(double noundef) #0

; Function Attrs: nounwind
declare double @asin(double noundef) #0

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN4math7degreesIdEET_S1_(double noundef) #4

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


; 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 nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(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) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK13MapProjection9reprojectEffRdS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, float noundef %1, float noundef %2, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %3, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %4) local_unnamed_addr #2 align 2 {
  %6 = fpext float %1 to double
  %7 = fdiv double %6, 6.371000e+06
  %8 = fpext float %2 to double
  %9 = fdiv double %8, 6.371000e+06
  %10 = fmul double %9, %9
  %11 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %10)
  %sqrt = tail call double @llvm.sqrt.f64(double %11)
  %12 = fcmp ueq double %sqrt, 0.000000e+00
  br i1 %12, label %38, label %13

13:                                               ; preds = %5
  %14 = tail call double @sin(double noundef %sqrt) #4
  %15 = tail call double @cos(double noundef %sqrt) #4
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fmul double %7, %14
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = fmul double %18, %20
  %22 = fdiv double %21, %sqrt
  %23 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %22)
  %24 = tail call double @asin(double noundef %23) #4
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = fmul double %9, %14
  %28 = load double, ptr %19, align 8, !tbaa !12
  %29 = fmul double %sqrt, %28
  %30 = load double, ptr %16, align 8, !tbaa !5
  %31 = fneg double %7
  %32 = fmul double %30, %31
  %33 = fmul double %14, %32
  %34 = tail call double @llvm.fmuladd.f64(double %29, double %15, double %33)
  %35 = tail call double @atan2(double noundef %27, double noundef %34) #4
  %36 = fadd double %26, %35
  %37 = tail call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %24)
  store double %37, ptr %3, align 8, !tbaa !14
  br label %44

38:                                               ; preds = %5
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = tail call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %40)
  store double %41, ptr %3, align 8, !tbaa !14
  %42 = getelementptr inbounds i8, ptr %0, i64 16
  %43 = load double, ptr %42, align 8, !tbaa !13
  br label %44

44:                                               ; preds = %38, %13
  %.sink = phi double [ %43, %38 ], [ %36, %13 ]
  %45 = tail call noundef double @_ZN4math7degreesIdEET_S1_(double noundef %.sink)
  store double %45, ptr %4, align 8, !tbaa !14
  ret void
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #0

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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, !10, i64 24}
!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 32}
!13 = !{!6, !10, i64 16}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !10, i64 8}


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