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

; 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.Camera = type { %struct.vec2, float, i32, i32 }
%struct.vec2 = type { float, float }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6Camera24GenerateProjectionMatrixEPf(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %12 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = sitofp i32 %13 to float
  %15 = fdiv float %14, 2.000000e+00
  store float %15, ptr %5, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %16 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 2
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = sitofp i32 %17 to float
  %19 = fdiv float %18, -2.000000e+00
  store float %19, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %20 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 3
  %21 = load i32, ptr %20, align 4, !tbaa !15
  %22 = sitofp i32 %21 to float
  %23 = fdiv float %22, 2.000000e+00
  store float %23, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %24 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !15
  %26 = sitofp i32 %25 to float
  %27 = fdiv float %26, -2.000000e+00
  store float %27, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store float 1.000000e+00, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store float -1.000000e+00, ptr %10, align 4, !tbaa !14
  %28 = load float, ptr %5, align 4, !tbaa !14
  %29 = fdiv float %28, 1.000000e+02
  store float %29, ptr %5, align 4, !tbaa !14
  %30 = load float, ptr %6, align 4, !tbaa !14
  %31 = fdiv float %30, 1.000000e+02
  store float %31, ptr %6, align 4, !tbaa !14
  %32 = load float, ptr %7, align 4, !tbaa !14
  %33 = fdiv float %32, 1.000000e+02
  store float %33, ptr %7, align 4, !tbaa !14
  %34 = load float, ptr %8, align 4, !tbaa !14
  %35 = fdiv float %34, 1.000000e+02
  store float %35, ptr %8, align 4, !tbaa !14
  %36 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !16
  %38 = load float, ptr %5, align 4, !tbaa !14
  %39 = fmul float %38, %37
  store float %39, ptr %5, align 4, !tbaa !14
  %40 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !16
  %42 = load float, ptr %6, align 4, !tbaa !14
  %43 = fmul float %42, %41
  store float %43, ptr %6, align 4, !tbaa !14
  %44 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !16
  %46 = load float, ptr %7, align 4, !tbaa !14
  %47 = fmul float %46, %45
  store float %47, ptr %7, align 4, !tbaa !14
  %48 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 1
  %49 = load float, ptr %48, align 4, !tbaa !16
  %50 = load float, ptr %8, align 4, !tbaa !14
  %51 = fmul float %50, %49
  store float %51, ptr %8, align 4, !tbaa !14
  %52 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 0
  %53 = getelementptr inbounds %struct.vec2, ptr %52, i32 0, i32 0
  %54 = load float, ptr %53, align 4, !tbaa !17
  %55 = load float, ptr %5, align 4, !tbaa !14
  %56 = fadd float %55, %54
  store float %56, ptr %5, align 4, !tbaa !14
  %57 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 0
  %58 = getelementptr inbounds %struct.vec2, ptr %57, i32 0, i32 0
  %59 = load float, ptr %58, align 4, !tbaa !17
  %60 = load float, ptr %6, align 4, !tbaa !14
  %61 = fadd float %60, %59
  store float %61, ptr %6, align 4, !tbaa !14
  %62 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 0
  %63 = getelementptr inbounds %struct.vec2, ptr %62, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !18
  %65 = load float, ptr %7, align 4, !tbaa !14
  %66 = fadd float %65, %64
  store float %66, ptr %7, align 4, !tbaa !14
  %67 = getelementptr inbounds %struct.Camera, ptr %11, i32 0, i32 0
  %68 = getelementptr inbounds %struct.vec2, ptr %67, i32 0, i32 1
  %69 = load float, ptr %68, align 4, !tbaa !18
  %70 = load float, ptr %8, align 4, !tbaa !14
  %71 = fadd float %70, %69
  store float %71, ptr %8, align 4, !tbaa !14
  %72 = load float, ptr %5, align 4, !tbaa !14
  %73 = load float, ptr %6, align 4, !tbaa !14
  %74 = fsub float %72, %73
  %75 = fdiv float 2.000000e+00, %74
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds float, ptr %76, i64 0
  store float %75, ptr %77, align 4, !tbaa !14
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds float, ptr %78, i64 1
  store float 0.000000e+00, ptr %79, align 4, !tbaa !14
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds float, ptr %80, i64 2
  store float 0.000000e+00, ptr %81, align 4, !tbaa !14
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds float, ptr %82, i64 3
  store float 0.000000e+00, ptr %83, align 4, !tbaa !14
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds float, ptr %84, i64 4
  store float 0.000000e+00, ptr %85, align 4, !tbaa !14
  %86 = load float, ptr %7, align 4, !tbaa !14
  %87 = load float, ptr %8, align 4, !tbaa !14
  %88 = fsub float %86, %87
  %89 = fdiv float 2.000000e+00, %88
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds float, ptr %90, i64 5
  store float %89, ptr %91, align 4, !tbaa !14
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds float, ptr %92, i64 6
  store float 0.000000e+00, ptr %93, align 4, !tbaa !14
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds float, ptr %94, i64 7
  store float 0.000000e+00, ptr %95, align 4, !tbaa !14
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds float, ptr %96, i64 8
  store float 0.000000e+00, ptr %97, align 4, !tbaa !14
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds float, ptr %98, i64 9
  store float 0.000000e+00, ptr %99, align 4, !tbaa !14
  %100 = load float, ptr %9, align 4, !tbaa !14
  %101 = load float, ptr %10, align 4, !tbaa !14
  %102 = fsub float %100, %101
  %103 = fdiv float -2.000000e+00, %102
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds float, ptr %104, i64 10
  store float %103, ptr %105, align 4, !tbaa !14
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds float, ptr %106, i64 11
  store float 0.000000e+00, ptr %107, align 4, !tbaa !14
  %108 = load float, ptr %5, align 4, !tbaa !14
  %109 = load float, ptr %6, align 4, !tbaa !14
  %110 = fadd float %108, %109
  %111 = load float, ptr %5, align 4, !tbaa !14
  %112 = load float, ptr %6, align 4, !tbaa !14
  %113 = fsub float %111, %112
  %114 = fdiv float %110, %113
  %115 = fneg float %114
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds float, ptr %116, i64 12
  store float %115, ptr %117, align 4, !tbaa !14
  %118 = load float, ptr %7, align 4, !tbaa !14
  %119 = load float, ptr %8, align 4, !tbaa !14
  %120 = fadd float %118, %119
  %121 = load float, ptr %7, align 4, !tbaa !14
  %122 = load float, ptr %8, align 4, !tbaa !14
  %123 = fsub float %121, %122
  %124 = fdiv float %120, %123
  %125 = fneg float %124
  %126 = load ptr, ptr %4, align 8, !tbaa !5
  %127 = getelementptr inbounds float, ptr %126, i64 13
  store float %125, ptr %127, align 4, !tbaa !14
  %128 = load float, ptr %9, align 4, !tbaa !14
  %129 = load float, ptr %10, align 4, !tbaa !14
  %130 = fadd float %128, %129
  %131 = load float, ptr %9, align 4, !tbaa !14
  %132 = load float, ptr %10, align 4, !tbaa !14
  %133 = fsub float %131, %132
  %134 = fdiv float %130, %133
  %135 = fneg float %134
  %136 = load ptr, ptr %4, align 8, !tbaa !5
  %137 = getelementptr inbounds float, ptr %136, i64 14
  store float %135, ptr %137, align 4, !tbaa !14
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds float, ptr %138, i64 15
  store float 1.000000e+00, ptr %139, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { 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 = { 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, !13, i64 12}
!10 = !{!"_ZTS6Camera", !11, i64 0, !12, i64 8, !13, i64 12, !13, i64 16}
!11 = !{!"_ZTS4vec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!10, !13, i64 16}
!16 = !{!10, !12, i64 8}
!17 = !{!10, !12, i64 0}
!18 = !{!10, !12, i64 4}


; 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 norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN6Camera24GenerateProjectionMatrixEPf(ptr nocapture noundef nonnull readonly align 4 dereferenceable(20) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = load <4 x float>, ptr %0, align 4
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = getelementptr inbounds i8, ptr %1, i64 20
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = getelementptr inbounds i8, ptr %1, i64 40
  %9 = getelementptr inbounds i8, ptr %1, i64 48
  %10 = load <2 x i32>, ptr %3, align 4, !tbaa !5
  %11 = sitofp <2 x i32> %10 to <2 x float>
  %12 = fmul <2 x float> %11, <float 5.000000e-01, float 5.000000e-01>
  %13 = fdiv <2 x float> %12, <float 1.000000e+02, float 1.000000e+02>
  %14 = shufflevector <4 x float> %4, <4 x float> poison, <2 x i32> <i32 2, i32 2>
  %15 = fmul <2 x float> %14, %13
  %16 = load <2 x float>, ptr %0, align 4, !tbaa !9
  %17 = fadd <2 x float> %16, %15
  %18 = fsub <2 x float> %16, %15
  %19 = fsub <2 x float> %17, %18
  %20 = extractelement <2 x float> %19, i64 0
  %21 = fdiv float 2.000000e+00, %20
  store float %21, ptr %1, align 4, !tbaa !9
  %22 = extractelement <2 x float> %19, i64 1
  %23 = fdiv float 2.000000e+00, %22
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  store float %23, ptr %6, align 4, !tbaa !9
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  store <2 x float> <float -1.000000e+00, float 0.000000e+00>, ptr %8, align 4, !tbaa !9
  %24 = fadd <2 x float> %17, %18
  %25 = fneg <2 x float> %24
  %26 = fdiv <2 x float> %25, %19
  store <2 x float> %26, ptr %9, align 4, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %1, i64 56
  store <2 x float> <float -0.000000e+00, float 1.000000e+00>, ptr %27, align 4, !tbaa !9
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 nounwind willreturn memory(argmem: write) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass