#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 */
long double DBL_MIN;
long double fabsl(long double);
long double fmax(int /*<<< orphan*/, long double);
int /*<<< orphan*/ frexpl(long double, int *);
int /*<<< orphan*/ ldexp(double, int);
long double ulp(long double x) {
  x = fabsl(x);
  int exp;
  if (x == 0) {
    return DBL_MIN;
  } else {
    frexpl(x, &exp);
  }
  return fmax(ldexp(1.0, exp - 53), DBL_MIN);
}


x86 assembly (clang, -O0):
<ulp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fabs
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1173 <ulp+0x43>
jp     1173 <ulp+0x43>
jmp    1162 <ulp+0x32>
mov    0x2e77(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
jmp    11af <ulp+0x7f>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    -0x24(%rbp),%rdi
call   1040 <frexpl@plt>
mov    -0x24(%rbp),%edi
add    $0xffffffcb,%edi
movsd  0xe6e(%rip),%xmm0
call   1030 <ldexp@plt>
mov    %eax,%edi
mov    0x2e40(%rip),%rax
fldt   (%rax)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <fmax@plt>
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ulp>:
sub    $0x18,%rsp
fldt   0x20(%rsp)
fldz
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jne    1154 <ulp+0x24>
jp     1154 <ulp+0x24>
fstp   %st(0)
mov    0x2e93(%rip),%rax
fldt   (%rax)
add    $0x18,%rsp
ret
fabs
fstpt  (%rsp)
lea    0x14(%rsp),%rdi
call   1040 <frexpl@plt>
mov    0x14(%rsp),%edi
add    $0xffffffcb,%edi
movsd  0xe8e(%rip),%xmm0
call   1030 <ldexp@plt>
mov    0x2e62(%rip),%rcx
fldt   (%rcx)
fstpt  (%rsp)
mov    %eax,%edi
call   1050 <fmax@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@DBL_MIN = global x86_fp80 0xK00000000000000000000
define x86_fp80 @ulp(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca i32
store x86_fp80 %0, x86_fp80* %3
%5 = load x86_fp80, x86_fp80* %3
%6 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %5)
store x86_fp80 %6, x86_fp80* %3
%7 = load x86_fp80, x86_fp80* %3
%8 = fcmp oeq x86_fp80 %7, 0xK00000000000000000000
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load x86_fp80, x86_fp80* @DBL_MIN
store x86_fp80 %10, x86_fp80* %2
br label %20
11: ; preds = %1
%12 = load x86_fp80, x86_fp80* %3
%13 = call i32 @frexpl(x86_fp80 %12, i32* %4)
br label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 53
%17 = call i32 @ldexp(double 1.000000e+00, i32 %16)
%18 = load x86_fp80, x86_fp80* @DBL_MIN
%19 = call x86_fp80 @fmax(i32 %17, x86_fp80 %18)
store x86_fp80 %19, x86_fp80* %2
br label %20
20: ; preds = %14, %9
%21 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %21
}

LLVM IR (-O2):
@DBL_MIN = global x86_fp80 0xK00000000000000000000
define x86_fp80 @ulp(x86_fp80 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = fcmp oeq x86_fp80 %0, 0xK00000000000000000000
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = load x86_fp80, x86_fp80* @DBL_MIN
br label %15
7: ; preds = %1
%8 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %0)
%9 = call i32 @frexpl(x86_fp80 %8, i32* %2)
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -53
%12 = tail call i32 @ldexp(double 1.000000e+00, i32 %11)
%13 = load x86_fp80, x86_fp80* @DBL_MIN
%14 = tail call x86_fp80 @fmax(i32 %12, x86_fp80 %13)
br label %15
15: ; preds = %7, %5
%16 = phi x86_fp80 [ %6, %5 ], [ %14, %7 ]
ret x86_fp80 %16
}