void mat44Orthographic(double left, double right, double bottom, double top,
                       double far, double near, double proj[4][4]) {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      proj[i][j] = 0;
    }
  }
  proj[0][0] = 2 / (right - left);
  proj[1][1] = 2 / (top - bottom);
  proj[2][2] = 2 / (near - far);
  proj[2][3] = (near + far) / (far - near);
  proj[0][3] = (right + left) / (left - right);
  proj[1][3] = (top + bottom) / (bottom - top);
  proj[3][3] = 1;
}


x86 assembly (clang, -O0):
<mat44Orthographic>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1184 <mat44Orthographic+0x84>
movl   $0x0,-0x40(%rbp)
cmpl   $0x4,-0x40(%rbp)
jge    1171 <mat44Orthographic+0x71>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    113e <mat44Orthographic+0x3e>
jmp    1176 <mat44Orthographic+0x76>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    112d <mat44Orthographic+0x2d>
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xe72(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  0xe54(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  0xe35(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x50(%rax)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x58(%rax)
movsd  -0x10(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x38(%rbp),%rax
movsd  0xdb1(%rip),%xmm0
movsd  %xmm0,0x78(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat44Orthographic>:
xorps  %xmm6,%xmm6
movups %xmm6,0x28(%rdi)
movups %xmm6,0x58(%rdi)
movups %xmm6,0x48(%rdi)
movups %xmm6,0x18(%rdi)
movups %xmm6,0x38(%rdi)
movups %xmm6,0x68(%rdi)
movups %xmm6,0x8(%rdi)
movapd %xmm1,%xmm8
subsd  %xmm0,%xmm8
movsd  0xecf(%rip),%xmm6
movapd %xmm6,%xmm7
divsd  %xmm8,%xmm7
movsd  %xmm7,(%rdi)
movapd %xmm3,%xmm7
subsd  %xmm2,%xmm7
divsd  %xmm7,%xmm6
movsd  %xmm6,0x28(%rdi)
movapd %xmm4,%xmm6
addsd  %xmm5,%xmm6
movapd %xmm5,%xmm7
unpcklpd %xmm4,%xmm7
unpcklpd %xmm5,%xmm4
subpd  %xmm4,%xmm7
movapd 0xea1(%rip),%xmm4
unpcklpd %xmm6,%xmm4
divpd  %xmm7,%xmm4
movupd %xmm4,0x50(%rdi)
movapd %xmm0,%xmm4
addsd  %xmm1,%xmm4
subsd  %xmm1,%xmm0
divsd  %xmm0,%xmm4
movsd  %xmm4,0x18(%rdi)
movapd %xmm2,%xmm0
addsd  %xmm3,%xmm0
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
movsd  %xmm0,0x38(%rdi)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x78(%rdi)
ret

LLVM IR (-O0):
define void @mat44Orthographic(double %0, double %1, double %2, double %3, double %4, double %5, [4 x double]* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca [4 x double]*
%15 = alloca i32
%16 = alloca i32
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store [4 x double]* %6, [4 x double]** %14
store i32 0, i32* %15
br label %17
17: ; preds = %36, %7
%18 = load i32, i32* %15
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %39
20: ; preds = %17
store i32 0, i32* %16
br label %21
21: ; preds = %32, %20
%22 = load i32, i32* %16
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = load [4 x double]*, [4 x double]** %14
%26 = load i32, i32* %15
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x double], [4 x double]* %25, i64 %27
%29 = load i32, i32* %16
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x double], [4 x double]* %28, i64 0, i64 %30
store double 0.000000e+00, double* %31
br label %32
32: ; preds = %24
%33 = load i32, i32* %16
%34 = add nsw i32 %33, 1
store i32 %34, i32* %16
br label %21
35: ; preds = %21
br label %36
36: ; preds = %35
%37 = load i32, i32* %15
%38 = add nsw i32 %37, 1
store i32 %38, i32* %15
br label %17
39: ; preds = %17
%40 = load double, double* %9
%41 = load double, double* %8
%42 = fsub double %40, %41
%43 = fdiv double 2.000000e+00, %42
%44 = load [4 x double]*, [4 x double]** %14
%45 = getelementptr inbounds [4 x double], [4 x double]* %44, i64 0
%46 = getelementptr inbounds [4 x double], [4 x double]* %45, i64 0, i64 0
store double %43, double* %46
%47 = load double, double* %11
%48 = load double, double* %10
%49 = fsub double %47, %48
%50 = fdiv double 2.000000e+00, %49
%51 = load [4 x double]*, [4 x double]** %14
%52 = getelementptr inbounds [4 x double], [4 x double]* %51, i64 1
%53 = getelementptr inbounds [4 x double], [4 x double]* %52, i64 0, i64 1
store double %50, double* %53
%54 = load double, double* %13
%55 = load double, double* %12
%56 = fsub double %54, %55
%57 = fdiv double 2.000000e+00, %56
%58 = load [4 x double]*, [4 x double]** %14
%59 = getelementptr inbounds [4 x double], [4 x double]* %58, i64 2
%60 = getelementptr inbounds [4 x double], [4 x double]* %59, i64 0, i64 2
store double %57, double* %60
%61 = load double, double* %13
%62 = load double, double* %12
%63 = fadd double %61, %62
%64 = load double, double* %12
%65 = load double, double* %13
%66 = fsub double %64, %65
%67 = fdiv double %63, %66
%68 = load [4 x double]*, [4 x double]** %14
%69 = getelementptr inbounds [4 x double], [4 x double]* %68, i64 2
%70 = getelementptr inbounds [4 x double], [4 x double]* %69, i64 0, i64 3
store double %67, double* %70
%71 = load double, double* %9
%72 = load double, double* %8
%73 = fadd double %71, %72
%74 = load double, double* %8
%75 = load double, double* %9
%76 = fsub double %74, %75
%77 = fdiv double %73, %76
%78 = load [4 x double]*, [4 x double]** %14
%79 = getelementptr inbounds [4 x double], [4 x double]* %78, i64 0
%80 = getelementptr inbounds [4 x double], [4 x double]* %79, i64 0, i64 3
store double %77, double* %80
%81 = load double, double* %11
%82 = load double, double* %10
%83 = fadd double %81, %82
%84 = load double, double* %10
%85 = load double, double* %11
%86 = fsub double %84, %85
%87 = fdiv double %83, %86
%88 = load [4 x double]*, [4 x double]** %14
%89 = getelementptr inbounds [4 x double], [4 x double]* %88, i64 1
%90 = getelementptr inbounds [4 x double], [4 x double]* %89, i64 0, i64 3
store double %87, double* %90
%91 = load [4 x double]*, [4 x double]** %14
%92 = getelementptr inbounds [4 x double], [4 x double]* %91, i64 3
%93 = getelementptr inbounds [4 x double], [4 x double]* %92, i64 0, i64 3
store double 1.000000e+00, double* %93
ret void
}

LLVM IR (-O2):
define void @mat44Orthographic(double %0, double %1, double %2, double %3, double %4, double %5, [4 x double]* nocapture writeonly %6) {
%8 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 1
%9 = bitcast double* %8 to i8*
%10 = fsub double %1, %0
%11 = fdiv double 2.000000e+00, %10
%12 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
store double %11, double* %12
%13 = fsub double %3, %2
%14 = fdiv double 2.000000e+00, %13
%15 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 1, i64 1
store double %14, double* %15
%16 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 2, i64 2
%17 = fadd double %4, %5
%18 = insertelement <2 x double> poison, double %5, i64 0
%19 = insertelement <2 x double> %18, double %4, i64 1
%20 = insertelement <2 x double> poison, double %4, i64 0
%21 = insertelement <2 x double> %20, double %5, i64 1
%22 = fsub <2 x double> %19, %21
%23 = insertelement <2 x double> <double 2.000000e+00, double poison>, double %17, i64 1
%24 = fdiv <2 x double> %23, %22
%25 = bitcast double* %16 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = fadd double %0, %1
%27 = fsub double %0, %1
%28 = fdiv double %26, %27
%29 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 3
store double %28, double* %29
%30 = fadd double %2, %3
%31 = fsub double %2, %3
%32 = fdiv double %30, %31
%33 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 1, i64 3
store double %32, double* %33
%34 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 3, i64 3
store double 1.000000e+00, double* %34
ret void
}