#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 fabs(int);
int paliwal_window(int i, int j, int n, int m, int r) {
  double s, f;
  s = ((double)m) / n;
  f = fabs(i - (((double)j) / s));
  if (f <= r)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<paliwal_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <fabs@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
cvtsi2sdl -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     117c <paliwal_window+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    1183 <paliwal_window+0x73>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paliwal_window>:
push   %rbx
cvtsi2sd %ecx,%xmm0
mov    %r8d,%ebx
cvtsi2sd %edx,%xmm1
divsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
cvtsi2sd %esi,%xmm2
divsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <fabs@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @paliwal_window(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%14 = load i32, i32* %10
%15 = sitofp i32 %14 to double
%16 = load i32, i32* %9
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
store double %18, double* %12
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to double
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to double
%23 = load double, double* %12
%24 = fdiv double %22, %23
%25 = fsub double %20, %24
%26 = fptosi double %25 to i32
%27 = call double @fabs(i32 %26)
store double %27, double* %13
%28 = load double, double* %13
%29 = load i32, i32* %11
%30 = sitofp i32 %29 to double
%31 = fcmp ole double %28, %30
br i1 %31, label %32, label %33
32: ; preds = %5
store i32 1, i32* %6
br label %34
33: ; preds = %5
store i32 0, i32* %6
br label %34
34: ; preds = %33, %32
%35 = load i32, i32* %6
ret i32 %35
}

LLVM IR (-O2):
define i32 @paliwal_window(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = sitofp i32 %3 to double
%7 = sitofp i32 %2 to double
%8 = fdiv double %6, %7
%9 = sitofp i32 %0 to double
%10 = sitofp i32 %1 to double
%11 = fdiv double %10, %8
%12 = fsub double %9, %11
%13 = fptosi double %12 to i32
%14 = tail call double @fabs(i32 %13)
%15 = sitofp i32 %4 to double
%16 = fcmp ole double %14, %15
%17 = zext i1 %16 to i32
ret i32 %17
}