#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 sqrt(double);
int diff(unsigned fr1_, unsigned long long fr1t, unsigned fr2_,
         unsigned long long fr2t) {
  double fr1 = ((double)fr1_) / ((double)fr1t),
         fr2 = ((double)fr2_) / ((double)fr2t);
  double diff = sqrt(fr2) - sqrt(fr1);
  return diff * 65536. + .5;
}


x86 assembly (clang, -O0):
<diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
cvtsi2sd %rax,%xmm0
movq   -0x10(%rbp),%xmm1
movaps 0xed6(%rip),%xmm3
punpckldq %xmm3,%xmm1
movapd 0xeda(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm4
unpckhpd %xmm1,%xmm1
addsd  %xmm4,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm0
movq   -0x20(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff>:
push   %rax
mov    %edi,%eax
cvtsi2sd %rax,%xmm4
movq   %rsi,%xmm0
movdqa 0xedb(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xedf(%rip),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
divsd  %xmm3,%xmm4
mov    %edx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movq   %rcx,%xmm3
punpckldq %xmm1,%xmm3
subpd  %xmm2,%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
addsd  %xmm3,%xmm1
divsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     1198 <diff+0x88>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
ucomisd %xmm2,%xmm4
jae    11b5 <diff+0xa5>
movapd %xmm4,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm1
jmp    11bc <diff+0xac>
movsd  %xmm4,(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm4
movapd %xmm0,%xmm1
ucomisd %xmm2,%xmm4
jb     1183 <diff+0x73>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
subsd  %xmm0,%xmm1
mulsd  0xe58(%rip),%xmm1
addsd  0xe58(%rip),%xmm1
cvttsd2si %xmm1,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @diff(i32 %0, i64 %1, i32 %2, i64 %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i64 %3, i64* %8
%12 = load i32, i32* %5
%13 = uitofp i32 %12 to double
%14 = load i64, i64* %6
%15 = uitofp i64 %14 to double
%16 = fdiv double %13, %15
store double %16, double* %9
%17 = load i32, i32* %7
%18 = uitofp i32 %17 to double
%19 = load i64, i64* %8
%20 = uitofp i64 %19 to double
%21 = fdiv double %18, %20
store double %21, double* %10
%22 = load double, double* %10
%23 = call double @sqrt(double %22)
%24 = load double, double* %9
%25 = call double @sqrt(double %24)
%26 = fsub double %23, %25
store double %26, double* %11
%27 = load double, double* %11
%28 = call double @llvm.fmuladd.f64(double %27, double 6.553600e+04, double 5.000000e-01)
%29 = fptosi double %28 to i32
ret i32 %29
}

LLVM IR (-O2):
define i32 @diff(i32 %0, i64 %1, i32 %2, i64 %3) {
%5 = uitofp i32 %0 to double
%6 = uitofp i64 %1 to double
%7 = fdiv double %5, %6
%8 = uitofp i32 %2 to double
%9 = uitofp i64 %3 to double
%10 = fdiv double %8, %9
%11 = tail call double @sqrt(double %10)
%12 = tail call double @sqrt(double %7)
%13 = fsub double %11, %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double 6.553600e+04, double 5.000000e-01)
%15 = fptosi double %14 to i32
ret i32 %15
}