#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*/ mlMatrixLoad(float *, float, float const, float const, float,
                                float, float const, float const, float, float,
                                float const, float const, float, float, float,
                                float, float);
int /*<<< orphan*/ mlMatrixTranslateTo(float *, float *, float *);
int /*<<< orphan*/ mlVectorCrossProductTo(float const *, float const *,
                                          float *);
int /*<<< orphan*/ mlVectorScaleTo(float const *, float, float *);
void mlMatrixLoadLook(float *a, const float *position, const float *forward,
                      const float *up) {
  float tmp[3], rotation[16];
  mlVectorCrossProductTo(forward, up, tmp);
  mlMatrixLoad(rotation, tmp[0], up[0], -forward[0], 0.0f, tmp[1], up[1],
               -forward[1], 0.0f, tmp[2], up[2], -forward[2], 0.0f, 0.0f, 0.0f,
               0.0f, 1.0f);
  mlVectorScaleTo(position, -1.0f, tmp);
  mlMatrixTranslateTo(rotation, tmp, a);
}


x86 assembly (clang, -O0):
<mlMatrixLoadLook>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1060 <mlVectorCrossProductTo@plt>
lea    -0x70(%rbp),%rdi
movss  -0x2c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
movss  -0x28(%rbp),%xmm4
mov    -0x20(%rbp),%rax
movss  0x4(%rax),%xmm5
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm3
movd   %xmm3,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm6
movss  -0x24(%rbp),%xmm12
mov    -0x20(%rbp),%rax
movss  0x8(%rax),%xmm11
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm3
movd   %xmm3,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm10
xorps  %xmm9,%xmm9
movss  0xe1a(%rip),%xmm8
movaps %xmm9,%xmm3
movaps %xmm9,%xmm7
movss  %xmm12,(%rsp)
movss  %xmm11,0x8(%rsp)
movss  %xmm10,0x10(%rsp)
movss  %xmm9,0x18(%rsp)
movss  %xmm9,0x20(%rsp)
movss  %xmm9,0x28(%rsp)
movss  %xmm9,0x30(%rsp)
movss  %xmm8,0x38(%rsp)
call   1050 <mlMatrixLoad@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
movss  0xdc2(%rip),%xmm0
call   1030 <mlVectorScaleTo@plt>
lea    -0x70(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1040 <mlMatrixTranslateTo@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlMatrixLoadLook>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x44(%rsp),%r15
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %r15,%rdx
call   1060 <mlVectorCrossProductTo@plt>
movss  (%rbx),%xmm2
movss  0x4(%rbx),%xmm6
movss  0x8(%rbx),%xmm3
movaps 0xe7b(%rip),%xmm8
xorps  %xmm8,%xmm2
movss  0x44(%rsp),%xmm0
movss  0x48(%rsp),%xmm4
movss  0x0(%r13),%xmm1
movss  0x4(%r13),%xmm5
xorps  %xmm8,%xmm6
movss  0x4c(%rsp),%xmm9
movss  0x8(%r13),%xmm7
xorps  %xmm8,%xmm3
movss  %xmm3,0x10(%rsp)
movss  %xmm7,0x8(%rsp)
movss  %xmm9,(%rsp)
movl   $0x3f800000,0x38(%rsp)
3f
movl   $0x0,0x30(%rsp)
movl   $0x0,0x28(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x18(%rsp)
lea    0x50(%rsp),%rbx
xorps  %xmm3,%xmm3
xorps  %xmm7,%xmm7
mov    %rbx,%rdi
call   1050 <mlMatrixLoad@plt>
movss  0xe05(%rip),%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <mlVectorScaleTo@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <mlMatrixTranslateTo@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mlMatrixLoadLook(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca [3 x float]
%10 = alloca [16 x float]
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%11 = load float*, float** %7
%12 = load float*, float** %8
%13 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%14 = call i32 @mlVectorCrossProductTo(float* %11, float* %12, float* %13)
%15 = getelementptr inbounds [16 x float], [16 x float]* %10, i64 0, i64 0
%16 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%17 = load float, float* %16
%18 = load float*, float** %8
%19 = getelementptr inbounds float, float* %18, i64 0
%20 = load float, float* %19
%21 = load float*, float** %7
%22 = getelementptr inbounds float, float* %21, i64 0
%23 = load float, float* %22
%24 = fneg float %23
%25 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%26 = load float, float* %25
%27 = load float*, float** %8
%28 = getelementptr inbounds float, float* %27, i64 1
%29 = load float, float* %28
%30 = load float*, float** %7
%31 = getelementptr inbounds float, float* %30, i64 1
%32 = load float, float* %31
%33 = fneg float %32
%34 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%35 = load float, float* %34
%36 = load float*, float** %8
%37 = getelementptr inbounds float, float* %36, i64 2
%38 = load float, float* %37
%39 = load float*, float** %7
%40 = getelementptr inbounds float, float* %39, i64 2
%41 = load float, float* %40
%42 = fneg float %41
%43 = call i32 @mlMatrixLoad(float* %15, float %17, float %20, float %24, float 0.000000e+00, float %26, float %29, float %33, float 0.000000e+00, float %35, float %38, float %42, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00)
%44 = load float*, float** %6
%45 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%46 = call i32 @mlVectorScaleTo(float* %44, float -1.000000e+00, float* %45)
%47 = getelementptr inbounds [16 x float], [16 x float]* %10, i64 0, i64 0
%48 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%49 = load float*, float** %5
%50 = call i32 @mlMatrixTranslateTo(float* %47, float* %48, float* %49)
ret void
}

LLVM IR (-O2):
define void @mlMatrixLoadLook(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca [3 x float]
%6 = alloca [16 x float]
%7 = bitcast [3 x float]* %5 to i8*
%8 = bitcast [16 x float]* %6 to i8*
%9 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%10 = call i32 @mlVectorCrossProductTo(float* %2, float* %3, float* %9)
%11 = getelementptr inbounds [16 x float], [16 x float]* %6, i64 0, i64 0
%12 = load float, float* %9
%13 = load float, float* %3
%14 = load float, float* %2
%15 = fneg float %14
%16 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %3, i64 1
%19 = load float, float* %18
%20 = getelementptr inbounds float, float* %2, i64 1
%21 = load float, float* %20
%22 = fneg float %21
%23 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
%24 = load float, float* %23
%25 = getelementptr inbounds float, float* %3, i64 2
%26 = load float, float* %25
%27 = getelementptr inbounds float, float* %2, i64 2
%28 = load float, float* %27
%29 = fneg float %28
%30 = call i32 @mlMatrixLoad(float* %11, float %12, float %13, float %15, float 0.000000e+00, float %17, float %19, float %22, float 0.000000e+00, float %24, float %26, float %29, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00)
%31 = call i32 @mlVectorScaleTo(float* %1, float -1.000000e+00, float* %9)
%32 = call i32 @mlMatrixTranslateTo(float* %11, float* %9, float* %0)
ret void
}