#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 */
scalar_t__ abs(float);
float best_interval_size(float dist, float interval) {
  float no_of_fps = dist / interval;
  int lower = (int)no_of_fps;
  int higher = lower + 1;
  float lowDif = dist / ((float)lower);
  float highDif = dist / ((float)higher);
  if (abs(lowDif - interval) < abs(highDif - interval)) {
    return lowDif;
  } else {
    return highDif;
  }
}


x86 assembly (clang, -O0):
<best_interval_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
cvttss2si -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
call   1030 <abs@plt>
mov    %rax,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    11a9 <best_interval_size+0x99>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11b3 <best_interval_size+0xa3>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<best_interval_size>:
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
movaps %xmm1,%xmm3
movss  %xmm1,0x8(%rsp)
cvttss2si %xmm2,%eax
add    $0x1,%eax
cvttps2dq %xmm2,%xmm2
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
cvtdq2ps %xmm2,%xmm2
movaps %xmm0,%xmm4
divss  %xmm2,%xmm4
movss  %xmm4,0xc(%rsp)
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
movaps %xmm4,%xmm0
subss  %xmm3,%xmm0
call   1030 <abs@plt>
mov    %rax,%rbx
movss  0x4(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
call   1030 <abs@plt>
movss  0xc(%rsp),%xmm0
cmp    %rax,%rbx
jl     1182 <best_interval_size+0x72>
movss  0x4(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @best_interval_size(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
store float %0, float* %4
store float %1, float* %5
%11 = load float, float* %4
%12 = load float, float* %5
%13 = fdiv float %11, %12
store float %13, float* %6
%14 = load float, float* %6
%15 = fptosi float %14 to i32
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
store i32 %17, i32* %8
%18 = load float, float* %4
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to float
%21 = fdiv float %18, %20
store float %21, float* %9
%22 = load float, float* %4
%23 = load i32, i32* %8
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
store float %25, float* %10
%26 = load float, float* %9
%27 = load float, float* %5
%28 = fsub float %26, %27
%29 = call i64 @abs(float %28)
%30 = load float, float* %10
%31 = load float, float* %5
%32 = fsub float %30, %31
%33 = call i64 @abs(float %32)
%34 = icmp slt i64 %29, %33
br i1 %34, label %35, label %37
35: ; preds = %2
%36 = load float, float* %9
store float %36, float* %3
br label %39
37: ; preds = %2
%38 = load float, float* %10
store float %38, float* %3
br label %39
39: ; preds = %37, %35
%40 = load float, float* %3
ret float %40
}

LLVM IR (-O2):
define float @best_interval_size(float %0, float %1) {
%3 = fdiv float %0, %1
%4 = fptosi float %3 to i32
%5 = add nsw i32 %4, 1
%6 = sitofp i32 %4 to float
%7 = fdiv float %0, %6
%8 = sitofp i32 %5 to float
%9 = fdiv float %0, %8
%10 = fsub float %7, %1
%11 = tail call i64 @abs(float %10)
%12 = fsub float %9, %1
%13 = tail call i64 @abs(float %12)
%14 = icmp slt i64 %11, %13
%15 = select i1 %14, float %7, float %9
ret float %15
}