void mat_ortho(float *matrix, float w, float h, float near, float far) {
  *(matrix + 0) = 2 / w;
  *(matrix + 5) = 2 / -h;
  *(matrix + 10) = -2 / (far - near);
  *(matrix + 12) = -1;
  *(matrix + 13) = 1;
  *(matrix + 14) = (far + near) / (far - near);
}


x86 assembly (clang, -O0):
<mat_ortho>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  0xee8(%rip),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xec1(%rip),%xmm0
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  -0x18(%rbp),%xmm1
subss  -0x14(%rbp),%xmm1
movss  0xe9e(%rip),%xmm0
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movss  0xe81(%rip),%xmm0
movss  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
movss  0xe6c(%rip),%xmm0
movss  %xmm0,0x34(%rax)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
subss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat_ortho>:
movss  0xef8(%rip),%xmm4
divss  %xmm0,%xmm4
movss  %xmm4,(%rdi)
movss  0xeec(%rip),%xmm0
movaps %xmm0,%xmm4
divss  %xmm1,%xmm4
movss  %xmm4,0x14(%rdi)
movaps %xmm3,%xmm1
subss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x28(%rdi)
movabs $0x3f800000bf800000,%rax
mov    %rax,0x30(%rdi)
addss  %xmm3,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x38(%rdi)
ret

LLVM IR (-O0):
define void @mat_ortho(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%11 = load float, float* %7
%12 = fdiv float 2.000000e+00, %11
%13 = load float*, float** %6
%14 = getelementptr inbounds float, float* %13, i64 0
store float %12, float* %14
%15 = load float, float* %8
%16 = fneg float %15
%17 = fdiv float 2.000000e+00, %16
%18 = load float*, float** %6
%19 = getelementptr inbounds float, float* %18, i64 5
store float %17, float* %19
%20 = load float, float* %10
%21 = load float, float* %9
%22 = fsub float %20, %21
%23 = fdiv float -2.000000e+00, %22
%24 = load float*, float** %6
%25 = getelementptr inbounds float, float* %24, i64 10
store float %23, float* %25
%26 = load float*, float** %6
%27 = getelementptr inbounds float, float* %26, i64 12
store float -1.000000e+00, float* %27
%28 = load float*, float** %6
%29 = getelementptr inbounds float, float* %28, i64 13
store float 1.000000e+00, float* %29
%30 = load float, float* %10
%31 = load float, float* %9
%32 = fadd float %30, %31
%33 = load float, float* %10
%34 = load float, float* %9
%35 = fsub float %33, %34
%36 = fdiv float %32, %35
%37 = load float*, float** %6
%38 = getelementptr inbounds float, float* %37, i64 14
store float %36, float* %38
ret void
}

LLVM IR (-O2):
define void @mat_ortho(float* nocapture writeonly %0, float %1, float %2, float %3, float %4) {
%6 = fdiv float 2.000000e+00, %1
store float %6, float* %0
%7 = fdiv float -2.000000e+00, %2
%8 = getelementptr inbounds float, float* %0, i64 5
store float %7, float* %8
%9 = fsub float %4, %3
%10 = fdiv float -2.000000e+00, %9
%11 = getelementptr inbounds float, float* %0, i64 10
store float %10, float* %11
%12 = getelementptr inbounds float, float* %0, i64 12
store float -1.000000e+00, float* %12
%13 = getelementptr inbounds float, float* %0, i64 13
store float 1.000000e+00, float* %13
%14 = fadd float %3, %4
%15 = fdiv float %14, %9
%16 = getelementptr inbounds float, float* %0, i64 14
store float %15, float* %16
ret void
}