#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 abs(short);
int atan2f(float, float);
void ComplementaryFilter(short accData[3], short gyrData[3], float *pitch,
                         float *roll) {
  float pitchAcc, rollAcc;
  *pitch += ((float)gyrData[0] / 65.536) * 0.01;
  *roll -= ((float)gyrData[1] / 65.536) * 0.01;
  int forceMagnitudeApprox =
      abs(accData[0]) + abs(accData[1]) + abs(accData[2]);
  if (forceMagnitudeApprox > 8192 && forceMagnitudeApprox < 32768) {
    pitchAcc =
        atan2f((float)accData[1], (float)accData[2]) * 180 / 3.14159265359;
    *pitch = *pitch * 0.98 + pitchAcc * 0.02;
    rollAcc =
        atan2f((float)accData[0], (float)accData[2]) * 180 / 3.14159265359;
    *roll = *roll * 0.98 + rollAcc * 0.02;
  }
}


x86 assembly (clang, -O0):
<ComplementaryFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movswl (%rax),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe99(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movswl 0x2(%rax),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe79(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm0,%rcx
movabs $0x8000000000000000,%rdx
xor    %rdx,%rcx
movq   %rcx,%xmm0
movsd  0xe42(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movswl (%rax),%edi
call   1030 <abs@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movswl 0x2(%rax),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movswl 0x4(%rax),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x2000,-0x2c(%rbp)
jle    130a <ComplementaryFilter+0x1ea>
cmpl   $0x8000,-0x2c(%rbp)
jge    130a <ComplementaryFilter+0x1ea>
mov    -0x8(%rbp),%rax
movswl 0x2(%rax),%ecx
cvtsi2ss %ecx,%xmm0
movswl 0x4(%rax),%eax
cvtsi2ss %eax,%xmm1
call   1040 <atan2f@plt>
imul   $0xb4,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdd0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd9e(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd8a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movswl (%rax),%ecx
cvtsi2ss %ecx,%xmm0
movswl 0x4(%rax),%eax
cvtsi2ss %eax,%xmm1
call   1040 <atan2f@plt>
imul   $0xb4,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd60(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd2e(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd1a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComplementaryFilter>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movswl (%rsi),%eax
cvtsi2sd %eax,%xmm0
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
divsd  0xec0(%rip),%xmm0
movss  (%rdx),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xeb8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rdx)
movswl 0x2(%rsi),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movss  (%rcx),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  0xe95(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rcx)
movswl (%rdi),%edi
call   1030 <abs@plt>
mov    %eax,%r12d
movswl 0x2(%rbx),%edi
call   1030 <abs@plt>
mov    %eax,%ebp
movswl 0x4(%rbx),%edi
call   1030 <abs@plt>
add    %r12d,%ebp
add    %ebp,%eax
add    $0xffffdfff,%eax
cmp    $0x5ffe,%eax
ja     1280 <ComplementaryFilter+0x160>
movswl 0x2(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movswl 0x4(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
call   1040 <atan2f@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe29(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  (%r15),%xmm1
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  0xe18(%rip),%xmm0
mulsd  0xe18(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15)
movswl (%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movswl 0x4(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
call   1040 <atan2f@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xdc9(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  (%r14),%xmm1
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  0xdb8(%rip),%xmm0
mulsd  0xdb8(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ComplementaryFilter(i16* %0, i16* %1, float* %2, float* %3) {
%5 = alloca i16*
%6 = alloca i16*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float
%10 = alloca float
%11 = alloca i32
store i16* %0, i16** %5
store i16* %1, i16** %6
store float* %2, float** %7
store float* %3, float** %8
%12 = load i16*, i16** %6
%13 = getelementptr inbounds i16, i16* %12, i64 0
%14 = load i16, i16* %13
%15 = sitofp i16 %14 to float
%16 = fpext float %15 to double
%17 = fdiv double %16, 6.553600e+01
%18 = load float*, float** %7
%19 = load float, float* %18
%20 = fpext float %19 to double
%21 = call double @llvm.fmuladd.f64(double %17, double 1.000000e-02, double %20)
%22 = fptrunc double %21 to float
store float %22, float* %18
%23 = load i16*, i16** %6
%24 = getelementptr inbounds i16, i16* %23, i64 1
%25 = load i16, i16* %24
%26 = sitofp i16 %25 to float
%27 = fpext float %26 to double
%28 = fdiv double %27, 6.553600e+01
%29 = load float*, float** %8
%30 = load float, float* %29
%31 = fpext float %30 to double
%32 = fneg double %28
%33 = call double @llvm.fmuladd.f64(double %32, double 1.000000e-02, double %31)
%34 = fptrunc double %33 to float
store float %34, float* %29
%35 = load i16*, i16** %5
%36 = getelementptr inbounds i16, i16* %35, i64 0
%37 = load i16, i16* %36
%38 = call i32 @abs(i16 signext %37)
%39 = load i16*, i16** %5
%40 = getelementptr inbounds i16, i16* %39, i64 1
%41 = load i16, i16* %40
%42 = call i32 @abs(i16 signext %41)
%43 = add nsw i32 %38, %42
%44 = load i16*, i16** %5
%45 = getelementptr inbounds i16, i16* %44, i64 2
%46 = load i16, i16* %45
%47 = call i32 @abs(i16 signext %46)
%48 = add nsw i32 %43, %47
store i32 %48, i32* %11
%49 = load i32, i32* %11
%50 = icmp sgt i32 %49, 8192
br i1 %50, label %51, label %99
51: ; preds = %4
%52 = load i32, i32* %11
%53 = icmp slt i32 %52, 32768
br i1 %53, label %54, label %99
54: ; preds = %51
%55 = load i16*, i16** %5
%56 = getelementptr inbounds i16, i16* %55, i64 1
%57 = load i16, i16* %56
%58 = sitofp i16 %57 to float
%59 = load i16*, i16** %5
%60 = getelementptr inbounds i16, i16* %59, i64 2
%61 = load i16, i16* %60
%62 = sitofp i16 %61 to float
%63 = call i32 @atan2f(float %58, float %62)
%64 = mul nsw i32 %63, 180
%65 = sitofp i32 %64 to double
%66 = fdiv double %65, 0x400921FB54442EEA
%67 = fptrunc double %66 to float
store float %67, float* %9
%68 = load float*, float** %7
%69 = load float, float* %68
%70 = fpext float %69 to double
%71 = load float, float* %9
%72 = fpext float %71 to double
%73 = fmul double %72, 2.000000e-02
%74 = call double @llvm.fmuladd.f64(double %70, double 0x3FEF5C28F5C28F5C, double %73)
%75 = fptrunc double %74 to float
%76 = load float*, float** %7
store float %75, float* %76
%77 = load i16*, i16** %5
%78 = getelementptr inbounds i16, i16* %77, i64 0
%79 = load i16, i16* %78
%80 = sitofp i16 %79 to float
%81 = load i16*, i16** %5
%82 = getelementptr inbounds i16, i16* %81, i64 2
%83 = load i16, i16* %82
%84 = sitofp i16 %83 to float
%85 = call i32 @atan2f(float %80, float %84)
%86 = mul nsw i32 %85, 180
%87 = sitofp i32 %86 to double
%88 = fdiv double %87, 0x400921FB54442EEA
%89 = fptrunc double %88 to float
store float %89, float* %10
%90 = load float*, float** %8
%91 = load float, float* %90
%92 = fpext float %91 to double
%93 = load float, float* %10
%94 = fpext float %93 to double
%95 = fmul double %94, 2.000000e-02
%96 = call double @llvm.fmuladd.f64(double %92, double 0x3FEF5C28F5C28F5C, double %95)
%97 = fptrunc double %96 to float
%98 = load float*, float** %8
store float %97, float* %98
br label %99
99: ; preds = %54, %51, %4
ret void
}

LLVM IR (-O2):
define void @ComplementaryFilter(i16* nocapture %0, i16* nocapture %1, float* nocapture %2, float* nocapture %3) {
%5 = load i16, i16* %1
%6 = sitofp i16 %5 to double
%7 = fdiv double %6, 6.553600e+01
%8 = load float, float* %2
%9 = fpext float %8 to double
%10 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e-02, double %9)
%11 = fptrunc double %10 to float
store float %11, float* %2
%12 = getelementptr inbounds i16, i16* %1, i64 1
%13 = load i16, i16* %12
%14 = sitofp i16 %13 to double
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fdiv double %14, -6.553600e+01
%18 = tail call double @llvm.fmuladd.f64(double %17, double 1.000000e-02, double %16)
%19 = fptrunc double %18 to float
store float %19, float* %3
%20 = load i16, i16* %0
%21 = tail call i32 @abs(i16 signext %20)
%22 = getelementptr inbounds i16, i16* %0, i64 1
%23 = load i16, i16* %22
%24 = tail call i32 @abs(i16 signext %23)
%25 = getelementptr inbounds i16, i16* %0, i64 2
%26 = load i16, i16* %25
%27 = tail call i32 @abs(i16 signext %26)
%28 = add i32 %21, -8193
%29 = add i32 %28, %24
%30 = add i32 %29, %27
%31 = icmp ult i32 %30, 24575
br i1 %31, label %32, label %63
32: ; preds = %4
%33 = load i16, i16* %22
%34 = sitofp i16 %33 to float
%35 = load i16, i16* %25
%36 = sitofp i16 %35 to float
%37 = tail call i32 @atan2f(float %34, float %36)
%38 = mul nsw i32 %37, 180
%39 = sitofp i32 %38 to double
%40 = fdiv double %39, 0x400921FB54442EEA
%41 = fptrunc double %40 to float
%42 = load float, float* %2
%43 = fpext float %42 to double
%44 = fpext float %41 to double
%45 = fmul double %44, 2.000000e-02
%46 = tail call double @llvm.fmuladd.f64(double %43, double 0x3FEF5C28F5C28F5C, double %45)
%47 = fptrunc double %46 to float
store float %47, float* %2
%48 = load i16, i16* %0
%49 = sitofp i16 %48 to float
%50 = load i16, i16* %25
%51 = sitofp i16 %50 to float
%52 = tail call i32 @atan2f(float %49, float %51)
%53 = mul nsw i32 %52, 180
%54 = sitofp i32 %53 to double
%55 = fdiv double %54, 0x400921FB54442EEA
%56 = fptrunc double %55 to float
%57 = load float, float* %3
%58 = fpext float %57 to double
%59 = fpext float %56 to double
%60 = fmul double %59, 2.000000e-02
%61 = tail call double @llvm.fmuladd.f64(double %58, double 0x3FEF5C28F5C28F5C, double %60)
%62 = fptrunc double %61 to float
store float %62, float* %3
br label %63
63: ; preds = %32, %4
ret void
}