#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 */
float atan(float);
float sqrt(float);
int KALMANFILTER_eulerAccel(float *phi_est, float *theta_est, float ax,
                            float ay, float az) {
  float temp;
  *theta_est = atan(ax / sqrt(ay * ay + az * az));
  *phi_est = -atan(ay / sqrt(ax * ax + az * az));
  return 1;
}


x86 assembly (clang, -O0):
<KALMANFILTER_eulerAccel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  %xmm2,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
divss  %xmm1,%xmm0
call   1030 <atan@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
divss  %xmm1,%xmm0
call   1030 <atan@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KALMANFILTER_eulerAccel>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movss  %xmm0,0xc(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
mulss  %xmm2,%xmm2
movss  %xmm1,0x14(%rsp)
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
movss  %xmm2,0x10(%rsp)
addss  %xmm2,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     115c <KALMANFILTER_eulerAccel+0x3c>
sqrtss %xmm0,%xmm0
jmp    1161 <KALMANFILTER_eulerAccel+0x41>
call   1040 <sqrt@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1030 <atan@plt>
movss  %xmm0,(%rbx)
movss  0xc(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  0x10(%rsp),%xmm0
ucomiss 0xe82(%rip),%xmm0
jb     1196 <KALMANFILTER_eulerAccel+0x76>
sqrtss %xmm0,%xmm0
jmp    119b <KALMANFILTER_eulerAccel+0x7b>
call   1040 <sqrt@plt>
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1030 <atan@plt>
xorps  0xe4c(%rip),%xmm0
movss  %xmm0,(%r14)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @KALMANFILTER_eulerAccel(float* %0, float* %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float*
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store float* %0, float** %6
store float* %1, float** %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%12 = load float, float* %8
%13 = load float, float* %9
%14 = load float, float* %9
%15 = load float, float* %10
%16 = load float, float* %10
%17 = fmul float %15, %16
%18 = call float @llvm.fmuladd.f32(float %13, float %14, float %17)
%19 = call float @sqrt(float %18)
%20 = fdiv float %12, %19
%21 = call float @atan(float %20)
%22 = load float*, float** %7
store float %21, float* %22
%23 = load float, float* %9
%24 = load float, float* %8
%25 = load float, float* %8
%26 = load float, float* %10
%27 = load float, float* %10
%28 = fmul float %26, %27
%29 = call float @llvm.fmuladd.f32(float %24, float %25, float %28)
%30 = call float @sqrt(float %29)
%31 = fdiv float %23, %30
%32 = call float @atan(float %31)
%33 = fneg float %32
%34 = load float*, float** %6
store float %33, float* %34
ret i32 1
}

LLVM IR (-O2):
define i32 @KALMANFILTER_eulerAccel(float* nocapture writeonly %0, float* nocapture writeonly %1, float %2, float %3, float %4) {
%6 = fmul float %4, %4
%7 = tail call float @llvm.fmuladd.f32(float %3, float %3, float %6)
%8 = tail call float @sqrt(float %7)
%9 = fdiv float %2, %8
%10 = tail call float @atan(float %9)
store float %10, float* %1
%11 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %6)
%12 = tail call float @sqrt(float %11)
%13 = fdiv float %3, %12
%14 = tail call float @atan(float %13)
%15 = fneg float %14
store float %15, float* %0
ret i32 1
}