#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
void finn_mat4_ortho(float *mat, float left, float right, float bottom,
                     float top, float near, float far) {
  float lr = 1 / (left - right);
  float bt = 1 / (bottom - top);
  float nf = 1 / (near - far);
  memset(mat, 0, sizeof(float) * 16);
  mat[0] = -2.0f * lr;
  mat[5] = -2.0f * bt;
  mat[10] = 2.0f * nf;
  mat[12] = (left + right) * lr;
  mat[13] = (top + bottom) * bt;
  mat[14] = (far + near) * nf;
  mat[15] = 1.0f;
}


x86 assembly (clang, -O0):
<finn_mat4_ortho>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  %xmm4,-0x1c(%rbp)
movss  %xmm5,-0x20(%rbp)
movss  -0xc(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
movss  0xeb4(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm1
subss  -0x18(%rbp),%xmm1
movss  0xe99(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm1
subss  -0x20(%rbp),%xmm1
movss  0xe7e(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movss  0xe65(%rip),%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  0xe50(%rip),%xmm0
mulss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  0xe36(%rip),%xmm0
mulss  -0x2c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x28(%rax)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x30(%rax)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x34(%rax)
movss  -0x20(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
movss  0xdd0(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finn_mat4_ortho>:
push   %rbx
sub    $0x30,%rsp
movss  %xmm5,0x28(%rsp)
movss  %xmm4,0x2c(%rsp)
movss  %xmm3,0x1c(%rsp)
movss  %xmm2,0x24(%rsp)
movss  %xmm1,0x18(%rsp)
movss  %xmm0,0x20(%rsp)
mov    %rdi,%rbx
movaps %xmm0,%xmm6
subss  %xmm1,%xmm6
movss  0xeb5(%rip),%xmm1
movaps %xmm1,%xmm0
divss  %xmm6,%xmm0
movss  %xmm0,0x10(%rsp)
movaps %xmm2,%xmm0
subss  %xmm3,%xmm0
movaps %xmm1,%xmm2
divss  %xmm0,%xmm2
movss  %xmm2,0x14(%rsp)
movaps %xmm4,%xmm0
subss  %xmm5,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movss  0xe73(%rip),%xmm0
movss  0x10(%rsp),%xmm3
movaps %xmm3,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  0x14(%rsp),%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,0x14(%rbx)
movss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x28(%rbx)
movss  0x20(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
mulss  %xmm3,%xmm0
movss  %xmm0,0x30(%rbx)
movss  0x24(%rsp),%xmm0
addss  0x1c(%rsp),%xmm0
mulss  %xmm2,%xmm0
movss  %xmm0,0x34(%rbx)
movss  0x2c(%rsp),%xmm0
addss  0x28(%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x38(%rbx)
movl   $0x3f800000,0x3c(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @finn_mat4_ortho(float* %0, float %1, float %2, float %3, float %4, float %5, float %6) {
%8 = alloca float*
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
store float* %0, float** %8
store float %1, float* %9
store float %2, float* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
store float %6, float* %14
%18 = load float, float* %9
%19 = load float, float* %10
%20 = fsub float %18, %19
%21 = fdiv float 1.000000e+00, %20
store float %21, float* %15
%22 = load float, float* %11
%23 = load float, float* %12
%24 = fsub float %22, %23
%25 = fdiv float 1.000000e+00, %24
store float %25, float* %16
%26 = load float, float* %13
%27 = load float, float* %14
%28 = fsub float %26, %27
%29 = fdiv float 1.000000e+00, %28
store float %29, float* %17
%30 = load float*, float** %8
%31 = call i32 @memset(float* %30, i32 0, i32 64)
%32 = load float, float* %15
%33 = fmul float -2.000000e+00, %32
%34 = load float*, float** %8
%35 = getelementptr inbounds float, float* %34, i64 0
store float %33, float* %35
%36 = load float, float* %16
%37 = fmul float -2.000000e+00, %36
%38 = load float*, float** %8
%39 = getelementptr inbounds float, float* %38, i64 5
store float %37, float* %39
%40 = load float, float* %17
%41 = fmul float 2.000000e+00, %40
%42 = load float*, float** %8
%43 = getelementptr inbounds float, float* %42, i64 10
store float %41, float* %43
%44 = load float, float* %9
%45 = load float, float* %10
%46 = fadd float %44, %45
%47 = load float, float* %15
%48 = fmul float %46, %47
%49 = load float*, float** %8
%50 = getelementptr inbounds float, float* %49, i64 12
store float %48, float* %50
%51 = load float, float* %12
%52 = load float, float* %11
%53 = fadd float %51, %52
%54 = load float, float* %16
%55 = fmul float %53, %54
%56 = load float*, float** %8
%57 = getelementptr inbounds float, float* %56, i64 13
store float %55, float* %57
%58 = load float, float* %14
%59 = load float, float* %13
%60 = fadd float %58, %59
%61 = load float, float* %17
%62 = fmul float %60, %61
%63 = load float*, float** %8
%64 = getelementptr inbounds float, float* %63, i64 14
store float %62, float* %64
%65 = load float*, float** %8
%66 = getelementptr inbounds float, float* %65, i64 15
store float 1.000000e+00, float* %66
ret void
}

LLVM IR (-O2):
define void @finn_mat4_ortho(float* %0, float %1, float %2, float %3, float %4, float %5, float %6) {
%8 = fsub float %1, %2
%9 = fdiv float 1.000000e+00, %8
%10 = fsub float %3, %4
%11 = fdiv float 1.000000e+00, %10
%12 = fsub float %5, %6
%13 = fdiv float 1.000000e+00, %12
%14 = tail call i32 @memset(float* %0, i32 0, i32 64)
%15 = fmul float %9, -2.000000e+00
store float %15, float* %0
%16 = fmul float %11, -2.000000e+00
%17 = getelementptr inbounds float, float* %0, i64 5
store float %16, float* %17
%18 = fmul float %13, 2.000000e+00
%19 = getelementptr inbounds float, float* %0, i64 10
store float %18, float* %19
%20 = fadd float %1, %2
%21 = fmul float %20, %9
%22 = getelementptr inbounds float, float* %0, i64 12
store float %21, float* %22
%23 = fadd float %3, %4
%24 = fmul float %23, %11
%25 = getelementptr inbounds float, float* %0, i64 13
store float %24, float* %25
%26 = fadd float %5, %6
%27 = fmul float %26, %13
%28 = getelementptr inbounds float, float* %0, i64 14
store float %27, float* %28
%29 = getelementptr inbounds float, float* %0, i64 15
store float 1.000000e+00, float* %29
ret void
}