#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 */
double accelerometer_read_x();
double accelerometer_read_y();
double accelerometer_read_z();
float atan2(float, float);
void accelerometer_read(float *theta_y, float *theta_x) {
  float xg = accelerometer_read_x() / 256.0;
  float yg = accelerometer_read_y() / 256.0;
  float zg = accelerometer_read_z() / 256.0;
  *theta_y = -atan2(yg, zg);
  *theta_x = atan2(xg, zg);
}


x86 assembly (clang, -O0):
<accelerometer_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <accelerometer_read_x@plt>
movsd  0xea1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <accelerometer_read_y@plt>
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <accelerometer_read_z@plt>
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
call   1030 <atan2@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accelerometer_read>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <accelerometer_read_x@plt>
mulsd  0xea4(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x14(%rsp)
xor    %eax,%eax
call   1060 <accelerometer_read_y@plt>
mulsd  0xe8b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <accelerometer_read_z@plt>
mulsd  0xe72(%rip),%xmm0
cvtsd2ss %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <atan2@plt>
xorps  0xe66(%rip),%xmm0
movss  %xmm0,(%rbx)
movss  0x14(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <atan2@plt>
movss  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @accelerometer_read(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%8 = call double (...) @accelerometer_read_x()
%9 = fdiv double %8, 2.560000e+02
%10 = fptrunc double %9 to float
store float %10, float* %5
%11 = call double (...) @accelerometer_read_y()
%12 = fdiv double %11, 2.560000e+02
%13 = fptrunc double %12 to float
store float %13, float* %6
%14 = call double (...) @accelerometer_read_z()
%15 = fdiv double %14, 2.560000e+02
%16 = fptrunc double %15 to float
store float %16, float* %7
%17 = load float, float* %6
%18 = load float, float* %7
%19 = call float @atan2(float %17, float %18)
%20 = fneg float %19
%21 = load float*, float** %3
store float %20, float* %21
%22 = load float, float* %5
%23 = load float, float* %7
%24 = call float @atan2(float %22, float %23)
%25 = load float*, float** %4
store float %24, float* %25
ret void
}

LLVM IR (-O2):
define void @accelerometer_read(float* nocapture writeonly %0, float* nocapture writeonly %1) {
%3 = tail call double (...) @accelerometer_read_x()
%4 = fmul double %3, 3.906250e-03
%5 = fptrunc double %4 to float
%6 = tail call double (...) @accelerometer_read_y()
%7 = fmul double %6, 3.906250e-03
%8 = fptrunc double %7 to float
%9 = tail call double (...) @accelerometer_read_z()
%10 = fmul double %9, 3.906250e-03
%11 = fptrunc double %10 to float
%12 = tail call float @atan2(float %8, float %11)
%13 = fneg float %12
store float %13, float* %0
%14 = tail call float @atan2(float %5, float %11)
store float %14, float* %1
ret void
}