#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 scalar_t__ uint8_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
float FLT_MAX;
float FLT_MIN;
float detector_calc_accel(const uint32_t ticks_per_sec,
                          const size_t num_tooth_posns, const uint32_t t0_ticks,
                          const uint8_t t0_teeth, const uint32_t t1_ticks,
                          const uint8_t t1_teeth) {
  if (t0_ticks == 0)
    return FLT_MIN;
  if (t1_ticks == 0)
    return FLT_MAX;
  float left_denom, right_denom, left_term, right_term;
  float t0_ticks_f = (float)t0_ticks;
  float t1_ticks_f = (float)t1_ticks;
  float t0_teeth_f = (float)t0_teeth;
  float t1_teeth_f = (float)t1_teeth;
  float unit_conversion =
      2.0 * 3.14159265359 * (float)ticks_per_sec * (float)ticks_per_sec;
  left_denom = t1_ticks_f * t1_ticks_f * (float)num_tooth_posns;
  right_denom = t1_ticks_f * t0_ticks_f * (float)num_tooth_posns;
  left_term = t1_teeth_f / left_denom;
  right_term = t0_teeth_f / right_denom;
  return unit_conversion * (left_term - right_term);
}


x86 assembly (clang, -O0):
<detector_calc_accel>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    113c <detector_calc_accel+0x3c>
mov    0x2eba(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a5 <detector_calc_accel+0x1a5>
cmpq   $0x0,-0x30(%rbp)
jne    115c <detector_calc_accel+0x5c>
mov    0x2e92(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a5 <detector_calc_accel+0x1a5>
cvtsi2ssq -0x20(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
cvtsi2ssq -0x30(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
cvtsi2ssq -0x28(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
cvtsi2ssq -0x38(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
cvtsi2ssq -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe66(%rip),%xmm2
movaps %xmm1,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x50(%rbp),%xmm0
mulss  %xmm0,%xmm0
movss  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x64(%rbp)
test   %rax,%rax
movss  %xmm0,-0x60(%rbp)
js     11f9 <detector_calc_accel+0xf9>
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x68(%rbp),%xmm0
movss  -0x60(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x50(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x74(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x70(%rbp)
test   %rax,%rax
movss  %xmm0,-0x6c(%rbp)
js     125c <detector_calc_accel+0x15c>
movss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  -0x74(%rbp),%xmm0
movss  -0x6c(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x58(%rbp),%xmm0
divss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x54(%rbp),%xmm0
divss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x5c(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
subss  -0x48(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<detector_calc_accel>:
test   %rdx,%rdx
je     1151 <detector_calc_accel+0x51>
test   %r8,%r8
je     115d <detector_calc_accel+0x5d>
cvtsi2ss %rdx,%xmm1
cvtsi2ss %r8,%xmm3
cvtsi2ss %rcx,%xmm2
cvtsi2ss %r9,%xmm0
cvtsi2ss %rdi,%xmm4
cvtss2sd %xmm4,%xmm4
movsd  0xed1(%rip),%xmm5
mulsd  %xmm4,%xmm5
mulsd  %xmm4,%xmm5
xorps  %xmm4,%xmm4
cvtsd2ss %xmm5,%xmm4
movaps %xmm3,%xmm5
mulss  %xmm3,%xmm5
test   %rsi,%rsi
js     1169 <detector_calc_accel+0x69>
cvtsi2ss %rsi,%xmm6
jmp    117e <detector_calc_accel+0x7e>
mov    0x2e90(%rip),%rax
movss  (%rax),%xmm0
ret
mov    0x2e7c(%rip),%rax
movss  (%rax),%xmm0
ret
mov    %rsi,%rax
shr    %rax
and    $0x1,%esi
or     %rax,%rsi
cvtsi2ss %rsi,%xmm6
addss  %xmm6,%xmm6
mulss  %xmm6,%xmm5
divss  %xmm5,%xmm0
mulss  %xmm3,%xmm1
mulss  %xmm6,%xmm1
divss  %xmm1,%xmm2
subss  %xmm2,%xmm0
mulss  %xmm4,%xmm0
ret

LLVM IR (-O0):
@FLT_MIN = global float 0.000000e+00
@FLT_MAX = global float 0.000000e+00
define float @detector_calc_accel(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5) {
%7 = alloca float
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
store i64 %0, i64* %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store i64 %5, i64* %13
%23 = load i64, i64* %10
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %6
%26 = load float, float* @FLT_MIN
store float %26, float* %7
br label %73
27: ; preds = %6
%28 = load i64, i64* %12
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load float, float* @FLT_MAX
store float %31, float* %7
br label %73
32: ; preds = %27
%33 = load i64, i64* %10
%34 = sitofp i64 %33 to float
store float %34, float* %18
%35 = load i64, i64* %12
%36 = sitofp i64 %35 to float
store float %36, float* %19
%37 = load i64, i64* %11
%38 = sitofp i64 %37 to float
store float %38, float* %20
%39 = load i64, i64* %13
%40 = sitofp i64 %39 to float
store float %40, float* %21
%41 = load i64, i64* %8
%42 = sitofp i64 %41 to float
%43 = fpext float %42 to double
%44 = fmul double 0x401921FB54442EEA, %43
%45 = load i64, i64* %8
%46 = sitofp i64 %45 to float
%47 = fpext float %46 to double
%48 = fmul double %44, %47
%49 = fptrunc double %48 to float
store float %49, float* %22
%50 = load float, float* %19
%51 = load float, float* %19
%52 = fmul float %50, %51
%53 = load i64, i64* %9
%54 = uitofp i64 %53 to float
%55 = fmul float %52, %54
store float %55, float* %14
%56 = load float, float* %19
%57 = load float, float* %18
%58 = fmul float %56, %57
%59 = load i64, i64* %9
%60 = uitofp i64 %59 to float
%61 = fmul float %58, %60
store float %61, float* %15
%62 = load float, float* %21
%63 = load float, float* %14
%64 = fdiv float %62, %63
store float %64, float* %16
%65 = load float, float* %20
%66 = load float, float* %15
%67 = fdiv float %65, %66
store float %67, float* %17
%68 = load float, float* %22
%69 = load float, float* %16
%70 = load float, float* %17
%71 = fsub float %69, %70
%72 = fmul float %68, %71
store float %72, float* %7
br label %73
73: ; preds = %32, %30, %25
%74 = load float, float* %7
ret float %74
}

LLVM IR (-O2):
@FLT_MIN = global float 0.000000e+00
@FLT_MAX = global float 0.000000e+00
define float @detector_calc_accel(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5) {
%7 = icmp eq i64 %2, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = load float, float* @FLT_MIN
br label %33
10: ; preds = %6
%11 = icmp eq i64 %4, 0
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = load float, float* @FLT_MAX
br label %33
14: ; preds = %10
%15 = sitofp i64 %2 to float
%16 = sitofp i64 %4 to float
%17 = sitofp i64 %3 to float
%18 = sitofp i64 %5 to float
%19 = sitofp i64 %0 to float
%20 = fpext float %19 to double
%21 = fmul double %20, 0x401921FB54442EEA
%22 = fmul double %21, %20
%23 = fptrunc double %22 to float
%24 = fmul float %16, %16
%25 = uitofp i64 %1 to float
%26 = fmul float %24, %25
%27 = fmul float %15, %16
%28 = fmul float %27, %25
%29 = fdiv float %18, %26
%30 = fdiv float %17, %28
%31 = fsub float %29, %30
%32 = fmul float %31, %23
br label %33
33: ; preds = %14, %12, %8
%34 = phi float [ %9, %8 ], [ %13, %12 ], [ %32, %14 ]
ret float %34
}