#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 */
typedef double int16_t;

/* Variables and functions */
int M_PI;
int acos(double);
double atan2(double, double);
double sqrt(double);
double CompassAndClino(int16_t gx0, int16_t gy0, int16_t gz0, int16_t mx0,
                       int16_t my0, int16_t mz0, double *compass,
                       double *clino) {
  double gx = gx0;
  double gy = gy0;
  double gz = gz0;
  double glen = sqrt(gx * gx + gy * gy + gz * gz);
  double mx = mx0;
  double my = my0;
  double mz = mz0;
  double mlen = sqrt(mx * mx + my * my + mz * mz);
  double angle = acos((gx * mx + gy * my + gz * mz) / (glen * mlen));
  double mgx = my * gz - mz * gy;
  double mgy = mz * gx - mx * gz;
  double mgz = mx * gy - my * gx;
  double gmgx = gy * mgz - gz * mgy;
  double gmgy = gz * mgx - gx * mgz;
  double gmgz = gx * mgy - gy * mgx;
  double egx = 0.0 * gz - 0.0 * gy;
  double egy = 0.0 * gx - 1.0 * gz;
  double egz = 1.0 * gy - 0.0 * gx;
  double gegx = gy * egz - gz * egy;
  double gegy = gz * egx - gx * egz;
  double gegz = gx * egy - gy * egx;
  double em0x = gegy * gmgz - gegz * gmgy;
  double em0y = gegz * gmgx - gegx * gmgz;
  double em0z = gegx * gmgy - gegy * gmgx;
  double s = sqrt(em0x * em0x + em0y * em0y + em0z * em0z);
  double em0g = gegx * gx + gegy * gy + gegz * gz;
  double c = gegx * gmgx + gegy * gmgy + gegz * gmgz;
  if (em0g > 0)
    s *= -1.0;
  *clino = acos(gx / glen) - M_PI / 2;
  *compass = atan2(s, c);
  if (*compass < 0.0)
    *compass += 2 * M_PI;
  return angle;
}


x86 assembly (clang, -O0):
<CompassAndClino>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  -0x80(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <acos@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  -0xa0(%rbp),%xmm2
ff
movsd  -0x58(%rbp),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x48(%rbp),%xmm1
mulsd  -0xa0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  -0x98(%rbp),%xmm2
ff
movsd  -0x50(%rbp),%xmm1
mulsd  -0x90(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
xorps  %xmm2,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  0xbee(%rip),%xmm1
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
xorps  %xmm2,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  -0xd0(%rbp),%xmm2
ff
movsd  -0x58(%rbp),%xmm1
mulsd  -0xc8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  -0xc0(%rbp),%xmm2
ff
movsd  -0x48(%rbp),%xmm1
mulsd  -0xd0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  -0xc8(%rbp),%xmm2
ff
movsd  -0x50(%rbp),%xmm1
mulsd  -0xc0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0xe0(%rbp),%xmm0
ff
movsd  -0xb8(%rbp),%xmm2
ff
movsd  -0xe8(%rbp),%xmm1
ff
mulsd  -0xb0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0xe8(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm2
ff
movsd  -0xd8(%rbp),%xmm1
ff
mulsd  -0xb8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
movsd  -0xb0(%rbp),%xmm2
ff
movsd  -0xe0(%rbp),%xmm1
ff
mulsd  -0xa8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0xf0(%rbp),%xmm1
ff
movsd  -0xf0(%rbp),%xmm2
ff
movsd  -0xf8(%rbp),%xmm0
ff
mulsd  -0xf8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x100(%rbp),%xmm0
ff
movsd  -0x100(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x108(%rbp)
ff
movsd  -0xd8(%rbp),%xmm1
ff
movsd  -0x48(%rbp),%xmm2
movsd  -0xe0(%rbp),%xmm0
ff
mulsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xe8(%rbp),%xmm0
ff
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  -0xd8(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
movsd  -0xe0(%rbp),%xmm0
ff
mulsd  -0xb0(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xe8(%rbp),%xmm0
ff
movsd  -0xb8(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
movsd  -0x110(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    170a <CompassAndClino+0x5da>
movsd  0x90e(%rip),%xmm0
mulsd  -0x108(%rbp),%xmm0
ff
movsd  %xmm0,-0x108(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
call   1040 <acos@plt>
mov    %eax,-0x11c(%rbp)
mov    0x28c2(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x11c(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x108(%rbp),%xmm0
ff
movsd  -0x118(%rbp),%xmm1
ff
call   1030 <atan2@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1790 <CompassAndClino+0x660>
mov    0x286d(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x38(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x88(%rbp),%xmm0
ff
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CompassAndClino>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movaps %xmm5,(%rsp)
movaps %xmm4,0x20(%rsp)
movaps %xmm3,0x30(%rsp)
movapd %xmm1,0x50(%rsp)
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movapd %xmm0,0x60(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm2,0x40(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     1193 <CompassAndClino+0x63>
sqrtsd %xmm0,%xmm0
jmp    119c <CompassAndClino+0x6c>
call   1050 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x18(%rsp)
movapd 0x20(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movapd 0x30(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd (%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11d3 <CompassAndClino+0xa3>
sqrtsd %xmm0,%xmm0
jmp    11d8 <CompassAndClino+0xa8>
call   1050 <sqrt@plt>
movapd 0x50(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
movapd 0x60(%rsp),%xmm2
mulsd  0x30(%rsp),%xmm2
addsd  %xmm1,%xmm2
movapd 0x40(%rsp),%xmm1
mulsd  (%rsp),%xmm1
addsd  %xmm2,%xmm1
mulsd  0x18(%rsp),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1040 <acos@plt>
mov    %eax,%ebp
movsd  0xde0(%rip),%xmm0
movapd (%rsp),%xmm4
xorpd  %xmm4,%xmm0
movapd 0x30(%rsp),%xmm5
movapd %xmm5,%xmm1
movapd 0x40(%rsp),%xmm2
mulsd  %xmm2,%xmm1
movapd 0x60(%rsp),%xmm6
mulsd  %xmm6,%xmm4
subsd  %xmm1,%xmm4
movapd %xmm2,%xmm1
movapd %xmm2,%xmm10
movapd 0x20(%rsp),%xmm2
unpcklpd %xmm2,%xmm1
mulsd  %xmm6,%xmm2
movapd 0x50(%rsp),%xmm3
mulsd  %xmm3,%xmm5
subsd  %xmm2,%xmm5
movapd %xmm4,%xmm2
mulsd  %xmm10,%xmm2
movapd %xmm3,%xmm12
mulsd  %xmm5,%xmm12
movapd %xmm5,%xmm11
subsd  %xmm2,%xmm12
movapd %xmm3,%xmm2
movapd %xmm3,%xmm9
unpcklpd %xmm3,%xmm2
movapd 0xd6e(%rip),%xmm3
unpcklpd %xmm0,%xmm3
mulpd  %xmm2,%xmm3
xorpd  %xmm0,%xmm0
unpcklpd %xmm10,%xmm0
mulpd  %xmm1,%xmm0
addpd  %xmm3,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
mulsd  %xmm9,%xmm1
movapd %xmm6,%xmm3
mulsd  %xmm6,%xmm4
subsd  %xmm1,%xmm4
xorpd  %xmm8,%xmm8
movapd %xmm6,%xmm1
mulsd  %xmm8,%xmm1
movapd %xmm9,%xmm2
subsd  %xmm1,%xmm2
subsd  %xmm10,%xmm1
movapd %xmm6,%xmm5
mulsd  %xmm1,%xmm5
mulsd  %xmm10,%xmm1
movapd %xmm9,%xmm7
mulsd  %xmm2,%xmm7
subsd  %xmm1,%xmm7
unpcklpd %xmm11,%xmm2
movapd %xmm6,%xmm1
unpcklpd %xmm6,%xmm1
mulpd  %xmm2,%xmm1
unpcklpd %xmm10,%xmm10
mulpd  %xmm0,%xmm10
subpd  %xmm1,%xmm10
mulsd  %xmm9,%xmm0
subsd  %xmm0,%xmm5
movapd %xmm10,%xmm6
unpckhpd %xmm10,%xmm6
movapd %xmm7,%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm6,%xmm1
mulsd  %xmm5,%xmm1
movapd %xmm12,%xmm2
mulsd  %xmm10,%xmm2
movapd %xmm10,%xmm3
mulsd  %xmm4,%xmm3
subsd  %xmm1,%xmm3
movapd %xmm4,(%rsp)
movapd %xmm4,%xmm1
mulsd  %xmm7,%xmm1
movapd %xmm5,%xmm4
mulsd  %xmm12,%xmm4
subsd  %xmm1,%xmm4
subsd  %xmm2,%xmm0
mulsd  %xmm4,%xmm4
mulsd  %xmm3,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
ucomisd %xmm8,%xmm0
jb     13a3 <CompassAndClino+0x273>
sqrtsd %xmm0,%xmm0
jmp    13f4 <CompassAndClino+0x2c4>
movapd %xmm12,0x30(%rsp)
movapd %xmm5,0x20(%rsp)
movapd %xmm7,0x90(%rsp)
movapd %xmm10,0x80(%rsp)
movapd %xmm6,0x70(%rsp)
call   1050 <sqrt@plt>
movapd 0x70(%rsp),%xmm6
movapd 0x80(%rsp),%xmm10
movapd 0x90(%rsp),%xmm7
movapd 0x20(%rsp),%xmm5
movapd 0x30(%rsp),%xmm12
movapd 0x50(%rsp),%xmm3
mulsd  %xmm10,%xmm3
movapd %xmm7,%xmm1
movapd 0x60(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
movapd 0x40(%rsp),%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm10,%xmm6
mulsd  %xmm7,%xmm12
addsd  %xmm6,%xmm12
movapd (%rsp),%xmm1
mulsd  %xmm5,%xmm1
addsd  %xmm12,%xmm1
movapd %xmm1,(%rsp)
movapd 0xbd7(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm4,%xmm4
cmpltsd %xmm3,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm0,%xmm4
orpd   %xmm1,%xmm4
movapd %xmm4,0x40(%rsp)
divsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm0
call   1040 <acos@plt>
mov    0x2b6a(%rip),%rbx
mov    (%rbx),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
sub    %edx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14)
movapd 0x40(%rsp),%xmm0
movapd (%rsp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%r15)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    14ca <CompassAndClino+0x39a>
mov    (%rbx),%eax
add    %eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
add    $0xa8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @CompassAndClino(double %0, double %1, double %2, double %3, double %4, double %5, double* %6, double* %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double*
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
%35 = alloca double
%36 = alloca double
%37 = alloca double
%38 = alloca double
%39 = alloca double
%40 = alloca double
%41 = alloca double
%42 = alloca double
%43 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double* %6, double** %15
store double* %7, double** %16
%44 = load double, double* %9
store double %44, double* %17
%45 = load double, double* %10
store double %45, double* %18
%46 = load double, double* %11
store double %46, double* %19
%47 = load double, double* %17
%48 = load double, double* %17
%49 = load double, double* %18
%50 = load double, double* %18
%51 = fmul double %49, %50
%52 = call double @llvm.fmuladd.f64(double %47, double %48, double %51)
%53 = load double, double* %19
%54 = load double, double* %19
%55 = call double @llvm.fmuladd.f64(double %53, double %54, double %52)
%56 = call double @sqrt(double %55)
store double %56, double* %20
%57 = load double, double* %12
store double %57, double* %21
%58 = load double, double* %13
store double %58, double* %22
%59 = load double, double* %14
store double %59, double* %23
%60 = load double, double* %21
%61 = load double, double* %21
%62 = load double, double* %22
%63 = load double, double* %22
%64 = fmul double %62, %63
%65 = call double @llvm.fmuladd.f64(double %60, double %61, double %64)
%66 = load double, double* %23
%67 = load double, double* %23
%68 = call double @llvm.fmuladd.f64(double %66, double %67, double %65)
%69 = call double @sqrt(double %68)
store double %69, double* %24
%70 = load double, double* %17
%71 = load double, double* %21
%72 = load double, double* %18
%73 = load double, double* %22
%74 = fmul double %72, %73
%75 = call double @llvm.fmuladd.f64(double %70, double %71, double %74)
%76 = load double, double* %19
%77 = load double, double* %23
%78 = call double @llvm.fmuladd.f64(double %76, double %77, double %75)
%79 = load double, double* %20
%80 = load double, double* %24
%81 = fmul double %79, %80
%82 = fdiv double %78, %81
%83 = call i32 @acos(double %82)
%84 = sitofp i32 %83 to double
store double %84, double* %25
%85 = load double, double* %22
%86 = load double, double* %19
%87 = load double, double* %23
%88 = load double, double* %18
%89 = fmul double %87, %88
%90 = fneg double %89
%91 = call double @llvm.fmuladd.f64(double %85, double %86, double %90)
store double %91, double* %26
%92 = load double, double* %23
%93 = load double, double* %17
%94 = load double, double* %21
%95 = load double, double* %19
%96 = fmul double %94, %95
%97 = fneg double %96
%98 = call double @llvm.fmuladd.f64(double %92, double %93, double %97)
store double %98, double* %27
%99 = load double, double* %21
%100 = load double, double* %18
%101 = load double, double* %22
%102 = load double, double* %17
%103 = fmul double %101, %102
%104 = fneg double %103
%105 = call double @llvm.fmuladd.f64(double %99, double %100, double %104)
store double %105, double* %28
%106 = load double, double* %18
%107 = load double, double* %28
%108 = load double, double* %19
%109 = load double, double* %27
%110 = fmul double %108, %109
%111 = fneg double %110
%112 = call double @llvm.fmuladd.f64(double %106, double %107, double %111)
store double %112, double* %29
%113 = load double, double* %19
%114 = load double, double* %26
%115 = load double, double* %17
%116 = load double, double* %28
%117 = fmul double %115, %116
%118 = fneg double %117
%119 = call double @llvm.fmuladd.f64(double %113, double %114, double %118)
store double %119, double* %30
%120 = load double, double* %17
%121 = load double, double* %27
%122 = load double, double* %18
%123 = load double, double* %26
%124 = fmul double %122, %123
%125 = fneg double %124
%126 = call double @llvm.fmuladd.f64(double %120, double %121, double %125)
store double %126, double* %31
%127 = load double, double* %19
%128 = load double, double* %18
%129 = fmul double 0.000000e+00, %128
%130 = fneg double %129
%131 = call double @llvm.fmuladd.f64(double 0.000000e+00, double %127, double %130)
store double %131, double* %32
%132 = load double, double* %17
%133 = load double, double* %19
%134 = fmul double 1.000000e+00, %133
%135 = fneg double %134
%136 = call double @llvm.fmuladd.f64(double 0.000000e+00, double %132, double %135)
store double %136, double* %33
%137 = load double, double* %18
%138 = load double, double* %17
%139 = fmul double 0.000000e+00, %138
%140 = fneg double %139
%141 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %137, double %140)
store double %141, double* %34
%142 = load double, double* %18
%143 = load double, double* %34
%144 = load double, double* %19
%145 = load double, double* %33
%146 = fmul double %144, %145
%147 = fneg double %146
%148 = call double @llvm.fmuladd.f64(double %142, double %143, double %147)
store double %148, double* %35
%149 = load double, double* %19
%150 = load double, double* %32
%151 = load double, double* %17
%152 = load double, double* %34
%153 = fmul double %151, %152
%154 = fneg double %153
%155 = call double @llvm.fmuladd.f64(double %149, double %150, double %154)
store double %155, double* %36
%156 = load double, double* %17
%157 = load double, double* %33
%158 = load double, double* %18
%159 = load double, double* %32
%160 = fmul double %158, %159
%161 = fneg double %160
%162 = call double @llvm.fmuladd.f64(double %156, double %157, double %161)
store double %162, double* %37
%163 = load double, double* %36
%164 = load double, double* %31
%165 = load double, double* %37
%166 = load double, double* %30
%167 = fmul double %165, %166
%168 = fneg double %167
%169 = call double @llvm.fmuladd.f64(double %163, double %164, double %168)
store double %169, double* %38
%170 = load double, double* %37
%171 = load double, double* %29
%172 = load double, double* %35
%173 = load double, double* %31
%174 = fmul double %172, %173
%175 = fneg double %174
%176 = call double @llvm.fmuladd.f64(double %170, double %171, double %175)
store double %176, double* %39
%177 = load double, double* %35
%178 = load double, double* %30
%179 = load double, double* %36
%180 = load double, double* %29
%181 = fmul double %179, %180
%182 = fneg double %181
%183 = call double @llvm.fmuladd.f64(double %177, double %178, double %182)
store double %183, double* %40
%184 = load double, double* %38
%185 = load double, double* %38
%186 = load double, double* %39
%187 = load double, double* %39
%188 = fmul double %186, %187
%189 = call double @llvm.fmuladd.f64(double %184, double %185, double %188)
%190 = load double, double* %40
%191 = load double, double* %40
%192 = call double @llvm.fmuladd.f64(double %190, double %191, double %189)
%193 = call double @sqrt(double %192)
store double %193, double* %41
%194 = load double, double* %35
%195 = load double, double* %17
%196 = load double, double* %36
%197 = load double, double* %18
%198 = fmul double %196, %197
%199 = call double @llvm.fmuladd.f64(double %194, double %195, double %198)
%200 = load double, double* %37
%201 = load double, double* %19
%202 = call double @llvm.fmuladd.f64(double %200, double %201, double %199)
store double %202, double* %42
%203 = load double, double* %35
%204 = load double, double* %29
%205 = load double, double* %36
%206 = load double, double* %30
%207 = fmul double %205, %206
%208 = call double @llvm.fmuladd.f64(double %203, double %204, double %207)
%209 = load double, double* %37
%210 = load double, double* %31
%211 = call double @llvm.fmuladd.f64(double %209, double %210, double %208)
store double %211, double* %43
%212 = load double, double* %42
%213 = fcmp ogt double %212, 0.000000e+00
br i1 %213, label %214, label %217
214: ; preds = %8
%215 = load double, double* %41
%216 = fmul double %215, -1.000000e+00
store double %216, double* %41
br label %217
217: ; preds = %214, %8
%218 = load double, double* %17
%219 = load double, double* %20
%220 = fdiv double %218, %219
%221 = call i32 @acos(double %220)
%222 = load i32, i32* @M_PI
%223 = sdiv i32 %222, 2
%224 = sub nsw i32 %221, %223
%225 = sitofp i32 %224 to double
%226 = load double*, double** %16
store double %225, double* %226
%227 = load double, double* %41
%228 = load double, double* %43
%229 = call double @atan2(double %227, double %228)
%230 = load double*, double** %15
store double %229, double* %230
%231 = load double*, double** %15
%232 = load double, double* %231
%233 = fcmp olt double %232, 0.000000e+00
br i1 %233, label %234, label %241
234: ; preds = %217
%235 = load i32, i32* @M_PI
%236 = mul nsw i32 2, %235
%237 = sitofp i32 %236 to double
%238 = load double*, double** %15
%239 = load double, double* %238
%240 = fadd double %239, %237
store double %240, double* %238
br label %241
241: ; preds = %234, %217
%242 = load double, double* %25
ret double %242
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @CompassAndClino(double %0, double %1, double %2, double %3, double %4, double %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = fmul double %1, %1
%10 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %9)
%11 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %10)
%12 = tail call double @sqrt(double %11)
%13 = fmul double %4, %4
%14 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %13)
%15 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %14)
%16 = tail call double @sqrt(double %15)
%17 = fmul double %1, %4
%18 = tail call double @llvm.fmuladd.f64(double %0, double %3, double %17)
%19 = tail call double @llvm.fmuladd.f64(double %2, double %5, double %18)
%20 = fmul double %12, %16
%21 = fdiv double %19, %20
%22 = tail call i32 @acos(double %21)
%23 = fneg double %5
%24 = fneg double %3
%25 = fmul double %24, %2
%26 = tail call double @llvm.fmuladd.f64(double %5, double %0, double %25)
%27 = fneg double %4
%28 = fmul double %27, %0
%29 = tail call double @llvm.fmuladd.f64(double %3, double %1, double %28)
%30 = fneg double %26
%31 = fmul double %30, %2
%32 = tail call double @llvm.fmuladd.f64(double %1, double %29, double %31)
%33 = insertelement <2 x double> poison, double %1, i64 0
%34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
%35 = insertelement <2 x double> <double -0.000000e+00, double poison>, double %23, i64 1
%36 = fmul <2 x double> %34, %35
%37 = insertelement <2 x double> poison, double %2, i64 0
%38 = insertelement <2 x double> %37, double %4, i64 1
%39 = insertelement <2 x double> <double 0.000000e+00, double poison>, double %2, i64 1
%40 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %38, <2 x double> %39, <2 x double> %36)
%41 = extractelement <2 x double> %40, i64 1
%42 = fneg double %41
%43 = fmul double %42, %1
%44 = tail call double @llvm.fmuladd.f64(double %0, double %26, double %43)
%45 = fneg double %2
%46 = tail call double @llvm.fmuladd.f64(double %0, double 0.000000e+00, double %45)
%47 = fmul double %0, 0.000000e+00
%48 = fsub double %1, %47
%49 = fneg double %46
%50 = fmul double %49, %2
%51 = tail call double @llvm.fmuladd.f64(double %1, double %48, double %50)
%52 = insertelement <2 x double> poison, double %48, i64 0
%53 = insertelement <2 x double> %52, double %29, i64 1
%54 = fneg <2 x double> %53
%55 = insertelement <2 x double> poison, double %0, i64 0
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> zeroinitializer
%57 = fmul <2 x double> %56, %54
%58 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> zeroinitializer
%59 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %58, <2 x double> %40, <2 x double> %57)
%60 = extractelement <2 x double> %40, i64 0
%61 = fneg double %60
%62 = fmul double %61, %1
%63 = tail call double @llvm.fmuladd.f64(double %0, double %46, double %62)
%64 = fneg double %63
%65 = extractelement <2 x double> %59, i64 1
%66 = fmul double %65, %64
%67 = extractelement <2 x double> %59, i64 0
%68 = tail call double @llvm.fmuladd.f64(double %67, double %44, double %66)
%69 = fneg double %51
%70 = fmul double %44, %69
%71 = tail call double @llvm.fmuladd.f64(double %63, double %32, double %70)
%72 = fneg double %67
%73 = fmul double %32, %72
%74 = tail call double @llvm.fmuladd.f64(double %51, double %65, double %73)
%75 = fmul double %71, %71
%76 = tail call double @llvm.fmuladd.f64(double %68, double %68, double %75)
%77 = tail call double @llvm.fmuladd.f64(double %74, double %74, double %76)
%78 = tail call double @sqrt(double %77)
%79 = fmul double %67, %1
%80 = tail call double @llvm.fmuladd.f64(double %51, double %0, double %79)
%81 = tail call double @llvm.fmuladd.f64(double %63, double %2, double %80)
%82 = fmul double %67, %65
%83 = tail call double @llvm.fmuladd.f64(double %51, double %32, double %82)
%84 = tail call double @llvm.fmuladd.f64(double %63, double %44, double %83)
%85 = fcmp ogt double %81, 0.000000e+00
%86 = fneg double %78
%87 = select i1 %85, double %86, double %78
%88 = fdiv double %0, %12
%89 = tail call i32 @acos(double %88)
%90 = load i32, i32* @M_PI
%91 = sdiv i32 %90, -2
%92 = add i32 %91, %89
%93 = sitofp i32 %92 to double
store double %93, double* %7
%94 = tail call double @atan2(double %87, double %84)
store double %94, double* %6
%95 = fcmp olt double %94, 0.000000e+00
br i1 %95, label %96, label %101
96: ; preds = %8
%97 = load i32, i32* @M_PI
%98 = shl nsw i32 %97, 1
%99 = sitofp i32 %98 to double
%100 = fadd double %94, %99
store double %100, double* %6
br label %101
101: ; preds = %96, %8
%102 = sitofp i32 %22 to double
ret double %102
}