void glmGeneratePerspectiveProjectionMatrixd(double m[16], double left,
                                             double right, double bottom,
                                             double top, double near,
                                             double far) {
  m[0] = (2 * near) / (right - left);
  m[1] = 0;
  m[2] = 0;
  m[3] = 0;
  m[4] = 0;
  m[5] = (2 * near) / (top - bottom);
  m[6] = 0;
  m[7] = 0;
  m[8] = (right + left) / (right - left);
  m[9] = (top + bottom) / (top - bottom);
  m[10] = -(far + near) / (far - near);
  m[11] = -1;
  m[12] = 0;
  m[13] = 0;
  m[14] = (-2 * far * near) / (far - near);
  m[15] = 0;
}


x86 assembly (clang, -O0):
<glmGeneratePerspectiveProjectionMatrixd>:
push   %rbp
mov    %rsp,%rbp
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)
movsd  0xee2(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x20(%rax)
movsd  0xe8f(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x48(%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,0x50(%rax)
mov    -0x8(%rbp),%rax
movsd  0xdcd(%rip),%xmm0
movsd  %xmm0,0x58(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x60(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x68(%rax)
movsd  0xda0(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x70(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x78(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmGeneratePerspectiveProjectionMatrixd>:
movapd %xmm4,%xmm6
addsd  %xmm5,%xmm6
movapd %xmm5,%xmm7
mulsd  0xefc(%rip),%xmm5
subsd  %xmm4,%xmm7
mulsd  %xmm4,%xmm5
addsd  %xmm4,%xmm4
unpcklpd %xmm3,%xmm1
unpcklpd %xmm2,%xmm0
movapd %xmm1,%xmm2
subpd  %xmm0,%xmm2
movapd %xmm4,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,(%rdi)
addpd  %xmm1,%xmm0
divpd  %xmm2,%xmm0
unpckhpd %xmm2,%xmm2
divsd  %xmm2,%xmm4
xorpd  %xmm1,%xmm1
movupd %xmm1,0x8(%rdi)
movupd %xmm1,0x18(%rdi)
movsd  %xmm4,0x28(%rdi)
movupd %xmm1,0x30(%rdi)
movupd %xmm0,0x40(%rdi)
xorpd  0xe8f(%rip),%xmm6
divsd  %xmm7,%xmm6
movsd  %xmm6,0x50(%rdi)
movabs $0xbff0000000000000,%rax
mov    %rax,0x58(%rdi)
divsd  %xmm7,%xmm5
movupd %xmm1,0x60(%rdi)
movsd  %xmm5,0x70(%rdi)
movq   $0x0,0x78(%rdi)
ret

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

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