#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*/ mlVectorCrossProductTo(float const *, float const *,
                                          float *);
void mlMatrixLoadRotation(float *a, const float *forward, const float *up) {
  float right[3];
  unsigned int i;
  mlVectorCrossProductTo(forward, up, right);
  for (i = 0; i < 3; i++) {
    a[0 * 4 + i] = right[i];
    a[1 * 4 + i] = up[i];
    a[2 * 4 + i] = -forward[i];
    a[3 * 4 + i] = a[i * 4 + 3] = 0.0f;
  }
  a[15] = 1.0f;
}


x86 assembly (clang, -O0):
<mlMatrixLoadRotation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1030 <mlVectorCrossProductTo@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jae    11e0 <mlMatrixLoadRotation+0xd0>
mov    -0x28(%rbp),%eax
movss  -0x24(%rbp,%rax,4),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x0,%ecx
mov    %ecx,%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x4,%ecx
mov    %ecx,%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x8,%ecx
mov    %ecx,%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
mov    %ecx,%ecx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0xc,%ecx
mov    %ecx,%ecx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113c <mlMatrixLoadRotation+0x2c>
mov    -0x8(%rbp),%rax
movss  0xe14(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlMatrixLoadRotation>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x4(%rsp),%rdx
mov    %rsi,%rdi
mov    %r15,%rsi
call   1030 <mlVectorCrossProductTo@plt>
movss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  (%r15),%xmm0
movss  %xmm0,0x10(%rbx)
movss  (%r14),%xmm0
movaps 0xeae(%rip),%xmm1
xorps  %xmm1,%xmm0
movss  %xmm0,0x20(%rbx)
movl   $0x0,0xc(%rbx)
movl   $0x0,0x30(%rbx)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x4(%r15),%xmm0
movss  %xmm0,0x14(%rbx)
movss  0x4(%r14),%xmm0
xorps  %xmm1,%xmm0
movss  %xmm0,0x24(%rbx)
movl   $0x0,0x1c(%rbx)
movl   $0x0,0x34(%rbx)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
movss  0x8(%r15),%xmm0
movss  %xmm0,0x18(%rbx)
movss  0x8(%r14),%xmm0
xorps  %xmm1,%xmm0
movss  %xmm0,0x28(%rbx)
movl   $0x0,0x2c(%rbx)
movabs $0x3f80000000000000,%rax
mov    %rax,0x38(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mlMatrixLoadRotation(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [3 x float]
%8 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%9 = load float*, float** %5
%10 = load float*, float** %6
%11 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%12 = call i32 @mlVectorCrossProductTo(float* %9, float* %10, float* %11)
store i32 0, i32* %8
br label %13
13: ; preds = %58, %3
%14 = load i32, i32* %8
%15 = icmp ult i32 %14, 3
br i1 %15, label %16, label %61
16: ; preds = %13
%17 = load i32, i32* %8
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 %18
%20 = load float, float* %19
%21 = load float*, float** %4
%22 = load i32, i32* %8
%23 = add i32 0, %22
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds float, float* %21, i64 %24
store float %20, float* %25
%26 = load float*, float** %6
%27 = load i32, i32* %8
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
%30 = load float, float* %29
%31 = load float*, float** %4
%32 = load i32, i32* %8
%33 = add i32 4, %32
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds float, float* %31, i64 %34
store float %30, float* %35
%36 = load float*, float** %5
%37 = load i32, i32* %8
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds float, float* %36, i64 %38
%40 = load float, float* %39
%41 = fneg float %40
%42 = load float*, float** %4
%43 = load i32, i32* %8
%44 = add i32 8, %43
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds float, float* %42, i64 %45
store float %41, float* %46
%47 = load float*, float** %4
%48 = load i32, i32* %8
%49 = mul i32 %48, 4
%50 = add i32 %49, 3
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds float, float* %47, i64 %51
store float 0.000000e+00, float* %52
%53 = load float*, float** %4
%54 = load i32, i32* %8
%55 = add i32 12, %54
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds float, float* %53, i64 %56
store float 0.000000e+00, float* %57
br label %58
58: ; preds = %16
%59 = load i32, i32* %8
%60 = add i32 %59, 1
store i32 %60, i32* %8
br label %13
61: ; preds = %13
%62 = load float*, float** %4
%63 = getelementptr inbounds float, float* %62, i64 15
store float 1.000000e+00, float* %63
ret void
}

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