; LLVM IR from Sonryle/JoePhys :: testbed/src/Renderer.ll (ZN6Camera23ScreenSpaceToWorldSpaceE4vec2)

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

%struct.vec2 = type { float, float }
%struct.Camera = type { %struct.vec2, float, i32, i32 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #2 align 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 <2 x float> @_ZN6Camera23ScreenSpaceToWorldSpaceE4vec2(ptr noundef nonnull align 4 dereferenceable(20) %0, <2 x float> %1) #3 align 2 {
  %3 = alloca %struct.vec2, align 4
  %4 = alloca %struct.vec2, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.vec2, align 4
  %7 = alloca %struct.vec2, align 4
  %8 = alloca %struct.vec2, align 4
  %9 = alloca %struct.vec2, align 4
  %10 = alloca %struct.vec2, align 4
  %11 = alloca %struct.vec2, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @_ZN4vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %13 = getelementptr inbounds %struct.vec2, ptr %4, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !9
  %15 = fdiv float %14, 1.000000e+02
  %16 = getelementptr inbounds %struct.vec2, ptr %4, i32 0, i32 1
  %17 = load float, ptr %16, align 4, !tbaa !12
  %18 = fdiv float %17, -1.000000e+02
  call void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %6, float noundef %15, float noundef %18)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %19 = getelementptr inbounds %struct.Camera, ptr %12, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !15
  %21 = sitofp i32 %20 to float
  %22 = fdiv float %21, 2.000000e+02
  %23 = getelementptr inbounds %struct.Camera, ptr %12, i32 0, i32 3
  %24 = load i32, ptr %23, align 4, !tbaa !18
  %25 = sitofp i32 %24 to float
  %26 = fdiv float %25, -2.000000e+02
  call void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %7, float noundef %22, float noundef %26)
  %27 = load <2 x float>, ptr %7, align 4
  %28 = call <2 x float> @_ZN4vec2mIES_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %27)
  store <2 x float> %28, ptr %8, align 4
  %29 = getelementptr inbounds %struct.Camera, ptr %12, i32 0, i32 1
  %30 = load float, ptr %29, align 4, !tbaa !19
  %31 = call <2 x float> @_ZN4vec2mLEf(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %30)
  store <2 x float> %31, ptr %9, align 4
  %32 = getelementptr inbounds %struct.Camera, ptr %12, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %32, i64 8, i1 false), !tbaa.struct !13
  %33 = load <2 x float>, ptr %10, align 4
  %34 = call <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %33)
  store <2 x float> %34, ptr %11, align 4
  %35 = load <2 x float>, ptr %3, align 4
  ret <2 x float> %35
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2mIES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2mLEf(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) #4 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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, !11, i64 0}
!10 = !{!"_ZTS4vec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{i64 0, i64 4, !14, i64 4, i64 4, !14}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !17, i64 12}
!16 = !{!"_ZTS6Camera", !10, i64 0, !11, i64 8, !17, i64 12, !17, i64 16}
!17 = !{!"int", !7, i64 0}
!18 = !{!16, !17, i64 16}
!19 = !{!16, !11, 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"

%struct.vec2 = type { float, float }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress 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 <2 x float> @_ZN6Camera23ScreenSpaceToWorldSpaceE4vec2(ptr nocapture noundef nonnull readonly align 4 dereferenceable(20) %0, <2 x float> %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %struct.vec2, align 8
  %4 = alloca %struct.vec2, align 8
  %5 = alloca %struct.vec2, align 8
  call void @_ZN4vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %.sroa.04.0.vec.extract = extractelement <2 x float> %1, i64 0
  %6 = fdiv float %.sroa.04.0.vec.extract, 1.000000e+02
  %.sroa.04.4.vec.extract = extractelement <2 x float> %1, i64 1
  %7 = fdiv float %.sroa.04.4.vec.extract, -1.000000e+02
  call void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef %6, float noundef %7)
  %8 = load i64, ptr %4, align 8
  store i64 %8, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = sitofp i32 %10 to float
  %12 = fdiv float %11, 2.000000e+02
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = sitofp i32 %14 to float
  %16 = fdiv float %15, -2.000000e+02
  call void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %5, float noundef %12, float noundef %16)
  %17 = load <2 x float>, ptr %5, align 8
  %18 = call <2 x float> @_ZN4vec2mIES_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load float, ptr %19, align 4, !tbaa !13
  %21 = call <2 x float> @_ZN4vec2mLEf(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %20)
  %.sroa.01.0.copyload = load <2 x float>, ptr %0, align 4
  %22 = call <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %.sroa.01.0.copyload)
  %23 = load <2 x float>, ptr %3, align 8
  ret <2 x float> %23
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2mIES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2mLEf(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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, !11, i64 12}
!6 = !{!"_ZTS6Camera", !7, i64 0, !8, i64 8, !11, i64 12, !11, i64 16}
!7 = !{!"_ZTS4vec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!6, !8, i64 8}


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