; LLVM IR from Lut1n/ImpGears :: src/ImpGears/Core/Matrix4.ll (ZN3imp7Matrix416orthographicProjEffffff)

; 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.imp::Matrix4" = type { %"class.imp::Matrix" }
%"class.imp::Matrix" = type { %"class.imp::Object", [16 x float] }
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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 uwtable
define dso_local void @_ZN3imp7Matrix416orthographicProjEffffff(ptr dead_on_unwind noalias writable sret(%"class.imp::Matrix4") align 8 %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) #1 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca [16 x float], align 16
  store ptr %0, ptr %8, align 8
  store float %1, ptr %9, align 4, !tbaa !5
  store float %2, ptr %10, align 4, !tbaa !5
  store float %3, ptr %11, align 4, !tbaa !5
  store float %4, ptr %12, align 4, !tbaa !5
  store float %5, ptr %13, align 4, !tbaa !5
  store float %6, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %22 = load float, ptr %10, align 4, !tbaa !5
  %23 = load float, ptr %9, align 4, !tbaa !5
  %24 = fsub float %22, %23
  %25 = fdiv float 2.000000e+00, %24
  store float %25, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %26 = load float, ptr %12, align 4, !tbaa !5
  %27 = load float, ptr %11, align 4, !tbaa !5
  %28 = fsub float %26, %27
  %29 = fdiv float 2.000000e+00, %28
  store float %29, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  %30 = load float, ptr %14, align 4, !tbaa !5
  %31 = load float, ptr %13, align 4, !tbaa !5
  %32 = fsub float %30, %31
  %33 = fdiv float -2.000000e+00, %32
  store float %33, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %34 = load float, ptr %10, align 4, !tbaa !5
  %35 = load float, ptr %9, align 4, !tbaa !5
  %36 = fadd float %34, %35
  %37 = fneg float %36
  %38 = load float, ptr %10, align 4, !tbaa !5
  %39 = load float, ptr %9, align 4, !tbaa !5
  %40 = fsub float %38, %39
  %41 = fdiv float %37, %40
  store float %41, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  %42 = load float, ptr %12, align 4, !tbaa !5
  %43 = load float, ptr %11, align 4, !tbaa !5
  %44 = fadd float %42, %43
  %45 = fneg float %44
  %46 = load float, ptr %12, align 4, !tbaa !5
  %47 = load float, ptr %11, align 4, !tbaa !5
  %48 = fsub float %46, %47
  %49 = fdiv float %45, %48
  store float %49, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  %50 = load float, ptr %14, align 4, !tbaa !5
  %51 = load float, ptr %13, align 4, !tbaa !5
  %52 = fadd float %50, %51
  %53 = fneg float %52
  %54 = load float, ptr %14, align 4, !tbaa !5
  %55 = load float, ptr %13, align 4, !tbaa !5
  %56 = fsub float %54, %55
  %57 = fdiv float %53, %56
  store float %57, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %21) #2
  %58 = load float, ptr %15, align 4, !tbaa !5
  store float %58, ptr %21, align 4, !tbaa !5
  %59 = getelementptr inbounds float, ptr %21, i64 1
  store float 0.000000e+00, ptr %59, align 4, !tbaa !5
  %60 = getelementptr inbounds float, ptr %21, i64 2
  store float 0.000000e+00, ptr %60, align 4, !tbaa !5
  %61 = getelementptr inbounds float, ptr %21, i64 3
  %62 = load float, ptr %18, align 4, !tbaa !5
  store float %62, ptr %61, align 4, !tbaa !5
  %63 = getelementptr inbounds float, ptr %21, i64 4
  store float 0.000000e+00, ptr %63, align 4, !tbaa !5
  %64 = getelementptr inbounds float, ptr %21, i64 5
  %65 = load float, ptr %16, align 4, !tbaa !5
  store float %65, ptr %64, align 4, !tbaa !5
  %66 = getelementptr inbounds float, ptr %21, i64 6
  store float 0.000000e+00, ptr %66, align 4, !tbaa !5
  %67 = getelementptr inbounds float, ptr %21, i64 7
  %68 = load float, ptr %19, align 4, !tbaa !5
  store float %68, ptr %67, align 4, !tbaa !5
  %69 = getelementptr inbounds float, ptr %21, i64 8
  store float 0.000000e+00, ptr %69, align 4, !tbaa !5
  %70 = getelementptr inbounds float, ptr %21, i64 9
  store float 0.000000e+00, ptr %70, align 4, !tbaa !5
  %71 = getelementptr inbounds float, ptr %21, i64 10
  %72 = load float, ptr %17, align 4, !tbaa !5
  store float %72, ptr %71, align 4, !tbaa !5
  %73 = getelementptr inbounds float, ptr %21, i64 11
  %74 = load float, ptr %20, align 4, !tbaa !5
  store float %74, ptr %73, align 4, !tbaa !5
  %75 = getelementptr inbounds float, ptr %21, i64 12
  store float 0.000000e+00, ptr %75, align 4, !tbaa !5
  %76 = getelementptr inbounds float, ptr %21, i64 13
  store float 0.000000e+00, ptr %76, align 4, !tbaa !5
  %77 = getelementptr inbounds float, ptr %21, i64 14
  store float 0.000000e+00, ptr %77, align 4, !tbaa !5
  %78 = getelementptr inbounds float, ptr %21, i64 15
  store float 1.000000e+00, ptr %78, align 4, !tbaa !5
  %79 = getelementptr inbounds [16 x float], ptr %21, i64 0, i64 0
  call void @_ZN3imp7Matrix4C1EPKfb(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %79, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 64, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  ret void
}

declare void @_ZN3imp7Matrix4C1EPKfb(ptr, ptr, i1)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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

%"class.imp::Matrix4" = type { %"class.imp::Matrix" }
%"class.imp::Matrix" = type { %"class.imp::Object", [16 x float] }
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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 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 void @_ZN3imp7Matrix416orthographicProjEffffff(ptr dead_on_unwind noalias writable sret(%"class.imp::Matrix4") align 8 %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) local_unnamed_addr #1 align 2 {
  %8 = alloca [16 x float], align 16
  %9 = fsub float %2, %1
  %10 = fdiv float 2.000000e+00, %9
  %11 = fsub float %4, %3
  %12 = fdiv float 2.000000e+00, %11
  %13 = fsub float %6, %5
  %14 = fadd float %1, %2
  %15 = fneg float %14
  %16 = fdiv float %15, %9
  %17 = fadd float %3, %4
  %18 = fneg float %17
  %19 = fdiv float %18, %11
  %20 = fadd float %5, %6
  %21 = fneg float %20
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #2
  store float %10, ptr %8, align 16, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %8, i64 4
  store <2 x float> zeroinitializer, ptr %22, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %8, i64 12
  store float %16, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %8, i64 16
  store float 0.000000e+00, ptr %24, align 16, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %8, i64 20
  store float %12, ptr %25, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %8, i64 24
  store float 0.000000e+00, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %8, i64 28
  store float %19, ptr %27, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %8, i64 32
  store <2 x float> zeroinitializer, ptr %28, align 16, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %8, i64 40
  %30 = insertelement <2 x float> <float -2.000000e+00, float poison>, float %21, i64 1
  %31 = insertelement <2 x float> poison, float %13, i64 0
  %32 = shufflevector <2 x float> %31, <2 x float> poison, <2 x i32> zeroinitializer
  %33 = fdiv <2 x float> %30, %32
  store <2 x float> %33, ptr %29, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %8, i64 48
  store <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00>, ptr %34, align 16, !tbaa !5
  call void @_ZN3imp7Matrix4C1EPKfb(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull %8, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #2
  ret void
}

declare void @_ZN3imp7Matrix4C1EPKfb(ptr, ptr, i1) local_unnamed_addr

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


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