void matrix3_orthographic_projection(double m[4][4], double left, double right,
                                     double bottom, double top, double near,
                                     double far) {
  assert(m);
  assert(left < right);
  assert(bottom < top);
  assert(near < far);
  matrix3_initialize(m);
  m[0][0] = 2.0 / (right - left);
  m[3][0] = -(right + left) / (right - left);
  m[1][1] = 2.0 / (top - bottom);
  m[3][1] = -(top + bottom) / (top - bottom);
  m[2][2] = -2.0 / (far - near);
  m[3][2] = -(far + near) / (far - near);
}


x86 assembly (clang, -O0):
<matrix3_orthographic_projection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <matrix3_initialize@plt>
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe3f(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x60(%rax)
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xde9(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x68(%rax)
movsd  -0x38(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  0xd8a(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x50(%rax)
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x70(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix3_orthographic_projection>:
push   %rbx
sub    $0x60,%rsp
movsd  %xmm5,0x8(%rsp)
movaps %xmm4,0x50(%rsp)
movaps %xmm3,0x30(%rsp)
movaps %xmm2,0x40(%rsp)
movaps %xmm1,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <assert@plt>
xor    %edi,%edi
movapd 0x10(%rsp),%xmm0
ucomisd 0x20(%rsp),%xmm0
seta   %dil
xor    %eax,%eax
call   1030 <assert@plt>
xor    %edi,%edi
movapd 0x30(%rsp),%xmm0
ucomisd 0x40(%rsp),%xmm0
seta   %dil
xor    %eax,%eax
call   1030 <assert@plt>
xor    %edi,%edi
movsd  0x8(%rsp),%xmm0
ucomisd 0x50(%rsp),%xmm0
seta   %dil
xor    %eax,%eax
call   1030 <assert@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <matrix3_initialize@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd 0x30(%rsp),%xmm1
movapd 0x20(%rsp),%xmm3
unpcklpd 0x40(%rsp),%xmm3
movapd %xmm1,%xmm0
movapd %xmm1,%xmm4
subpd  %xmm3,%xmm0
movsd  0xe31(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rbx)
addpd  %xmm4,%xmm3
movapd 0xe29(%rip),%xmm2
xorpd  %xmm2,%xmm3
divpd  %xmm0,%xmm3
unpckhpd %xmm0,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rbx)
movupd %xmm3,0x60(%rbx)
movsd  0x8(%rsp),%xmm4
movapd %xmm4,%xmm0
movapd 0x50(%rsp),%xmm3
subsd  %xmm3,%xmm0
movsd  0xdeb(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rbx)
addsd  %xmm4,%xmm3
xorpd  %xmm2,%xmm3
divsd  %xmm0,%xmm3
movsd  %xmm3,0x70(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @matrix3_orthographic_projection([4 x double]* %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca [4 x double]*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store [4 x double]* %0, [4 x 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 double %6, double* %14
%15 = load [4 x double]*, [4 x double]** %8
%16 = call i32 ([4 x double]*, ...) bitcast (i32 (...)* @assert to i32 ([4 x double]*, ...)*)([4 x double]* %15)
%17 = load double, double* %9
%18 = load double, double* %10
%19 = fcmp olt double %17, %18
%20 = zext i1 %19 to i32
%21 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %20)
%22 = load double, double* %11
%23 = load double, double* %12
%24 = fcmp olt double %22, %23
%25 = zext i1 %24 to i32
%26 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %25)
%27 = load double, double* %13
%28 = load double, double* %14
%29 = fcmp olt double %27, %28
%30 = zext i1 %29 to i32
%31 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %30)
%32 = load [4 x double]*, [4 x double]** %8
%33 = call i32 ([4 x double]*, ...) bitcast (i32 (...)* @matrix3_initialize to i32 ([4 x double]*, ...)*)([4 x double]* %32)
%34 = load double, double* %10
%35 = load double, double* %9
%36 = fsub double %34, %35
%37 = fdiv double 2.000000e+00, %36
%38 = load [4 x double]*, [4 x double]** %8
%39 = getelementptr inbounds [4 x double], [4 x double]* %38, i64 0
%40 = getelementptr inbounds [4 x double], [4 x double]* %39, i64 0, i64 0
store double %37, double* %40
%41 = load double, double* %10
%42 = load double, double* %9
%43 = fadd double %41, %42
%44 = fneg double %43
%45 = load double, double* %10
%46 = load double, double* %9
%47 = fsub double %45, %46
%48 = fdiv double %44, %47
%49 = load [4 x double]*, [4 x double]** %8
%50 = getelementptr inbounds [4 x double], [4 x double]* %49, i64 3
%51 = getelementptr inbounds [4 x double], [4 x double]* %50, i64 0, i64 0
store double %48, double* %51
%52 = load double, double* %12
%53 = load double, double* %11
%54 = fsub double %52, %53
%55 = fdiv double 2.000000e+00, %54
%56 = load [4 x double]*, [4 x double]** %8
%57 = getelementptr inbounds [4 x double], [4 x double]* %56, i64 1
%58 = getelementptr inbounds [4 x double], [4 x double]* %57, i64 0, i64 1
store double %55, double* %58
%59 = load double, double* %12
%60 = load double, double* %11
%61 = fadd double %59, %60
%62 = fneg double %61
%63 = load double, double* %12
%64 = load double, double* %11
%65 = fsub double %63, %64
%66 = fdiv double %62, %65
%67 = load [4 x double]*, [4 x double]** %8
%68 = getelementptr inbounds [4 x double], [4 x double]* %67, i64 3
%69 = getelementptr inbounds [4 x double], [4 x double]* %68, i64 0, i64 1
store double %66, double* %69
%70 = load double, double* %14
%71 = load double, double* %13
%72 = fsub double %70, %71
%73 = fdiv double -2.000000e+00, %72
%74 = load [4 x double]*, [4 x double]** %8
%75 = getelementptr inbounds [4 x double], [4 x double]* %74, i64 2
%76 = getelementptr inbounds [4 x double], [4 x double]* %75, i64 0, i64 2
store double %73, double* %76
%77 = load double, double* %14
%78 = load double, double* %13
%79 = fadd double %77, %78
%80 = fneg double %79
%81 = load double, double* %14
%82 = load double, double* %13
%83 = fsub double %81, %82
%84 = fdiv double %80, %83
%85 = load [4 x double]*, [4 x double]** %8
%86 = getelementptr inbounds [4 x double], [4 x double]* %85, i64 3
%87 = getelementptr inbounds [4 x double], [4 x double]* %86, i64 0, i64 2
store double %84, double* %87
ret void
}

LLVM IR (-O2):
define void @matrix3_orthographic_projection([4 x double]* %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = tail call i32 ([4 x double]*, ...) bitcast (i32 (...)* @assert to i32 ([4 x double]*, ...)*)([4 x double]* %0)
%9 = fcmp olt double %1, %2
%10 = zext i1 %9 to i32
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %10)
%12 = fcmp olt double %3, %4
%13 = zext i1 %12 to i32
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %13)
%15 = fcmp olt double %5, %6
%16 = zext i1 %15 to i32
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %16)
%18 = tail call i32 ([4 x double]*, ...) bitcast (i32 (...)* @matrix3_initialize to i32 ([4 x double]*, ...)*)([4 x double]* %0)
%19 = insertelement <2 x double> poison, double %2, i64 0
%20 = insertelement <2 x double> %19, double %4, i64 1
%21 = insertelement <2 x double> poison, double %1, i64 0
%22 = insertelement <2 x double> %21, double %3, i64 1
%23 = fsub <2 x double> %20, %22
%24 = extractelement <2 x double> %23, i64 0
%25 = fdiv double 2.000000e+00, %24
%26 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
store double %25, double* %26
%27 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
%28 = extractelement <2 x double> %23, i64 1
%29 = fdiv double 2.000000e+00, %28
%30 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 1
store double %29, double* %30
%31 = fadd <2 x double> %22, %20
%32 = fneg <2 x double> %31
%33 = fdiv <2 x double> %32, %23
%34 = bitcast double* %27 to <2 x double>*
store <2 x double> %33, <2 x double>* %34
%35 = fsub double %6, %5
%36 = fdiv double -2.000000e+00, %35
%37 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 2
store double %36, double* %37
%38 = fadd double %5, %6
%39 = fneg double %38
%40 = fdiv double %39, %35
%41 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 2
store double %40, double* %41
ret void
}