; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RNBasics/RNGrfx.ll (Z13R2ScaleWindowff)

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

@RNgrfx_window_xscale = external dso_local global float, align 4
@RNgrfx_window_yscale = external dso_local global float, align 4
@RNgrfx_window_width = external dso_local global float, align 4
@RNgrfx_window_height = external dso_local global float, align 4
@RNgrfx_window_xcenter = external dso_local global float, align 4
@RNgrfx_window_ycenter = external dso_local global float, align 4
@RNgrfx_window_xmin = external dso_local global float, align 4
@RNgrfx_window_ymin = external dso_local global float, align 4
@RNgrfx_window_xmax = external dso_local global float, align 4
@RNgrfx_window_ymax = external dso_local global float, align 4
@RNgrfx_viewport_width = external dso_local global i32, align 4
@RNgrfx_viewport_height = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z13R2ScaleWindowff(float noundef %0, float noundef %1) #0 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  store float %0, ptr %3, align 4, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !5
  %5 = load float, ptr @RNgrfx_window_xcenter, align 4, !tbaa !5
  %6 = fpext float %5 to double
  %7 = load float, ptr %3, align 4, !tbaa !5
  %8 = fpext float %7 to double
  %9 = fmul double 5.000000e-01, %8
  %10 = load float, ptr @RNgrfx_window_width, align 4, !tbaa !5
  %11 = fpext float %10 to double
  %12 = fneg double %9
  %13 = call double @llvm.fmuladd.f64(double %12, double %11, double %6)
  %14 = fptrunc double %13 to float
  store float %14, ptr @RNgrfx_window_xmin, align 4, !tbaa !5
  %15 = load float, ptr @RNgrfx_window_ycenter, align 4, !tbaa !5
  %16 = fpext float %15 to double
  %17 = load float, ptr %4, align 4, !tbaa !5
  %18 = fpext float %17 to double
  %19 = fmul double 5.000000e-01, %18
  %20 = load float, ptr @RNgrfx_window_height, align 4, !tbaa !5
  %21 = fpext float %20 to double
  %22 = fneg double %19
  %23 = call double @llvm.fmuladd.f64(double %22, double %21, double %16)
  %24 = fptrunc double %23 to float
  store float %24, ptr @RNgrfx_window_ymin, align 4, !tbaa !5
  %25 = load float, ptr @RNgrfx_window_xcenter, align 4, !tbaa !5
  %26 = fpext float %25 to double
  %27 = load float, ptr %3, align 4, !tbaa !5
  %28 = fpext float %27 to double
  %29 = fmul double 5.000000e-01, %28
  %30 = load float, ptr @RNgrfx_window_width, align 4, !tbaa !5
  %31 = fpext float %30 to double
  %32 = call double @llvm.fmuladd.f64(double %29, double %31, double %26)
  %33 = fptrunc double %32 to float
  store float %33, ptr @RNgrfx_window_xmax, align 4, !tbaa !5
  %34 = load float, ptr @RNgrfx_window_ycenter, align 4, !tbaa !5
  %35 = fpext float %34 to double
  %36 = load float, ptr %4, align 4, !tbaa !5
  %37 = fpext float %36 to double
  %38 = fmul double 5.000000e-01, %37
  %39 = load float, ptr @RNgrfx_window_height, align 4, !tbaa !5
  %40 = fpext float %39 to double
  %41 = call double @llvm.fmuladd.f64(double %38, double %40, double %35)
  %42 = fptrunc double %41 to float
  store float %42, ptr @RNgrfx_window_ymax, align 4, !tbaa !5
  %43 = load float, ptr @RNgrfx_window_xmax, align 4, !tbaa !5
  %44 = load float, ptr @RNgrfx_window_xmin, align 4, !tbaa !5
  %45 = fsub float %43, %44
  store float %45, ptr @RNgrfx_window_width, align 4, !tbaa !5
  %46 = load float, ptr @RNgrfx_window_ymax, align 4, !tbaa !5
  %47 = load float, ptr @RNgrfx_window_ymin, align 4, !tbaa !5
  %48 = fsub float %46, %47
  store float %48, ptr @RNgrfx_window_height, align 4, !tbaa !5
  %49 = load i32, ptr @RNgrfx_viewport_width, align 4, !tbaa !9
  %50 = sitofp i32 %49 to float
  %51 = load float, ptr @RNgrfx_window_width, align 4, !tbaa !5
  %52 = fdiv float %50, %51
  store float %52, ptr @RNgrfx_window_xscale, align 4, !tbaa !5
  %53 = load i32, ptr @RNgrfx_viewport_height, align 4, !tbaa !9
  %54 = sitofp i32 %53 to float
  %55 = load float, ptr @RNgrfx_window_height, align 4, !tbaa !5
  %56 = fdiv float %54, %55
  store float %56, ptr @RNgrfx_window_yscale, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { 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, !6, i64 0}
!6 = !{!"float", !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"

@RNgrfx_window_xscale = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_yscale = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_width = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_height = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_xcenter = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_ycenter = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_xmin = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_ymin = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_xmax = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_window_ymax = external dso_local local_unnamed_addr global float, align 4
@RNgrfx_viewport_width = external dso_local local_unnamed_addr global i32, align 4
@RNgrfx_viewport_height = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z13R2ScaleWindowff(float noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = load float, ptr @RNgrfx_window_xcenter, align 4, !tbaa !5
  %4 = fpext float %3 to double
  %5 = fpext float %0 to double
  %6 = fmul double %5, 5.000000e-01
  %7 = load float, ptr @RNgrfx_window_width, align 4, !tbaa !5
  %8 = fpext float %7 to double
  %9 = fneg double %6
  %10 = load float, ptr @RNgrfx_window_ycenter, align 4, !tbaa !5
  %11 = fpext float %10 to double
  %12 = fpext float %1 to double
  %13 = fmul double %12, 5.000000e-01
  %14 = load float, ptr @RNgrfx_window_height, align 4, !tbaa !5
  %15 = fpext float %14 to double
  %16 = fneg double %13
  %17 = insertelement <2 x double> poison, double %6, i64 0
  %18 = insertelement <2 x double> %17, double %9, i64 1
  %19 = insertelement <2 x double> poison, double %8, i64 0
  %20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
  %21 = insertelement <2 x double> poison, double %4, i64 0
  %22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
  %23 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %20, <2 x double> %22)
  %24 = fptrunc <2 x double> %23 to <2 x float>
  %25 = extractelement <2 x float> %24, i64 1
  store float %25, ptr @RNgrfx_window_xmin, align 4, !tbaa !5
  %26 = extractelement <2 x float> %24, i64 0
  store float %26, ptr @RNgrfx_window_xmax, align 4, !tbaa !5
  %27 = insertelement <2 x double> poison, double %13, i64 0
  %28 = insertelement <2 x double> %27, double %16, i64 1
  %29 = insertelement <2 x double> poison, double %15, i64 0
  %30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
  %31 = insertelement <2 x double> poison, double %11, i64 0
  %32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
  %33 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %30, <2 x double> %32)
  %34 = fptrunc <2 x double> %33 to <2 x float>
  %35 = extractelement <2 x float> %34, i64 1
  store float %35, ptr @RNgrfx_window_ymin, align 4, !tbaa !5
  %36 = extractelement <2 x float> %34, i64 0
  store float %36, ptr @RNgrfx_window_ymax, align 4, !tbaa !5
  %37 = fsub float %26, %25
  store float %37, ptr @RNgrfx_window_width, align 4, !tbaa !5
  %38 = fsub float %36, %35
  store float %38, ptr @RNgrfx_window_height, align 4, !tbaa !5
  %39 = load i32, ptr @RNgrfx_viewport_width, align 4, !tbaa !9
  %40 = sitofp i32 %39 to float
  %41 = fdiv float %40, %37
  store float %41, ptr @RNgrfx_window_xscale, align 4, !tbaa !5
  %42 = load i32, ptr @RNgrfx_viewport_height, align 4, !tbaa !9
  %43 = sitofp i32 %42 to float
  %44 = fdiv float %43, %38
  store float %44, ptr @RNgrfx_window_yscale, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) 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 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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