#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 int uint64_t;
typedef int /*<<< orphan*/ mpfr_t;

/* Variables and functions */
int /*<<< orphan*/ MPFR_RNDN;
double mpfr_get_d(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set_d(int /*<<< orphan*/, double, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int leeway_of(mpfr_t temp, mpfr_t f) {
  double d1 = mpfr_get_d(f, MPFR_RNDN);
  double d2 = 0.0;
  mpfr_set_d(temp, d1, MPFR_RNDN);
  mpfr_sub(temp, f, temp, MPFR_RNDN);
  d2 = mpfr_get_d(temp, MPFR_RNDN);
  return ((((*((uint64_t *)((char *)&d1)))) >> 52) & 0x7ff) - 52 -
         ((((*((uint64_t *)((char *)&d2)))) >> 52) & 0x7ff);
}


x86 assembly (clang, -O0):
<leeway_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_get_d@plt>
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
call   1050 <mpfr_set_d@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    0x2e66(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_sub@plt>
mov    -0x4(%rbp),%edi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_get_d@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x34,%ecx
sar    %cl,%eax
and    $0x7ff,%eax
sub    $0x34,%eax
mov    -0x18(%rbp),%edx
mov    $0x34,%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0x7ff,%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leeway_of>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2ea9(%rip),%r14
mov    (%r14),%esi
mov    %ebx,%edi
call   1040 <mpfr_get_d@plt>
mov    (%r14),%esi
mov    %ebp,%edi
call   1050 <mpfr_set_d@plt>
mov    (%r14),%ecx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <mpfr_sub@plt>
mov    (%r14),%esi
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <mpfr_get_d@plt>

LLVM IR (-O0):
@MPFR_RNDN = global i32 0
define i32 @leeway_of(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* @MPFR_RNDN
%9 = call double @mpfr_get_d(i32 %7, i32 %8)
store double %9, double* %5
store double 0.000000e+00, double* %6
%10 = load i32, i32* %3
%11 = load double, double* %5
%12 = load i32, i32* @MPFR_RNDN
%13 = call i32 @mpfr_set_d(i32 %10, double %11, i32 %12)
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = load i32, i32* @MPFR_RNDN
%18 = call i32 @mpfr_sub(i32 %14, i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* @MPFR_RNDN
%21 = call double @mpfr_get_d(i32 %19, i32 %20)
store double %21, double* %6
%22 = bitcast double* %5 to i8*
%23 = bitcast i8* %22 to i32*
%24 = load i32, i32* %23
%25 = ashr i32 %24, 52
%26 = and i32 %25, 2047
%27 = sub nsw i32 %26, 52
%28 = bitcast double* %6 to i8*
%29 = bitcast i8* %28 to i32*
%30 = load i32, i32* %29
%31 = ashr i32 %30, 52
%32 = and i32 %31, 2047
%33 = sub nsw i32 %27, %32
ret i32 %33
}

LLVM IR (-O2):
@MPFR_RNDN = global i32 0
define i32 @leeway_of(i32 %0, i32 %1) {
%3 = load i32, i32* @MPFR_RNDN
%4 = tail call double @mpfr_get_d(i32 %1, i32 %3)
%5 = load i32, i32* @MPFR_RNDN
%6 = tail call i32 @mpfr_set_d(i32 %0, double %4, i32 %5)
%7 = load i32, i32* @MPFR_RNDN
%8 = tail call i32 @mpfr_sub(i32 %0, i32 %1, i32 %0, i32 %7)
%9 = load i32, i32* @MPFR_RNDN
%10 = tail call double @mpfr_get_d(i32 %0, i32 %9)
ret i32 poison
}