#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*/ AnglesToAxis(float *, float **);
int /*<<< orphan*/ MatToQuat(float **, float *);
void EulerToQuat(float ang[3], float q[4]) {
  float mat[3][3];
  int *i;
  i = (int *)ang;
  if (!i[0] && !i[1] && !i[2]) {
    q[0] = 0;
    q[1] = 0;
    q[2] = 0;
    q[3] = 1.0f;
  } else {
    AnglesToAxis(ang, mat);
    MatToQuat(mat, q);
  }
}


x86 assembly (clang, -O0):
<EulerToQuat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmpl   $0x0,(%rax)
jne    119a <EulerToQuat+0x7a>
mov    -0x48(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    119a <EulerToQuat+0x7a>
mov    -0x48(%rbp),%rax
cmpl   $0x0,0x8(%rax)
jne    119a <EulerToQuat+0x7a>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movss  0xe70(%rip),%xmm0
movss  %xmm0,0xc(%rax)
jmp    11b4 <EulerToQuat+0x94>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <AnglesToAxis@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <MatToQuat@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EulerToQuat>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
cmpl   $0x0,(%rdi)
jne    113b <EulerToQuat+0x1b>
cmpl   $0x0,0x4(%rdi)
jne    113b <EulerToQuat+0x1b>
cmpl   $0x0,0x8(%rdi)
je     1159 <EulerToQuat+0x39>
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <AnglesToAxis@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <MatToQuat@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
movaps 0xea0(%rip),%xmm0
movups %xmm0,(%r14)
jmp    1151 <EulerToQuat+0x31>

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

LLVM IR (-O2):
define void @EulerToQuat(float* %0, float* %1) {
%3 = alloca [3 x [3 x float]]
%4 = bitcast [3 x [3 x float]]* %3 to i8*
%5 = bitcast float* %0 to i32*
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = getelementptr inbounds float, float* %0, i64 1
%10 = bitcast float* %9 to i32*
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = getelementptr inbounds float, float* %0, i64 2
%15 = bitcast float* %14 to i32*
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = bitcast float* %1 to <4 x float>*
store <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00>, <4 x float>* %19
br label %24
20: ; preds = %13, %8, %2
%21 = bitcast [3 x [3 x float]]* %3 to float**
%22 = call i32 @AnglesToAxis(float* %0, float** %21)
%23 = call i32 @MatToQuat(float** %21, float* %1)
br label %24
24: ; preds = %20, %18
ret void
}