#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 FLT_MIN;
double fabsf(double);
double fmaxf(int /*<<< orphan*/, double);
int /*<<< orphan*/ frexpf(double, int *);
int /*<<< orphan*/ ldexpf(double, int);
double ulp(double x) {
  x = fabsf(x);
  int exp;
  if (x == 0) {
    return FLT_MIN;
  } else {
    frexpf(x, &exp);
  }
  return fmaxf(ldexpf(1.0, exp - 24), FLT_MIN);
}


x86 assembly (clang, -O0):
<ulp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabsf@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1189 <ulp+0x49>
jp     1189 <ulp+0x49>
mov    0x2e6d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c1 <ulp+0x81>
movsd  -0x10(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
call   1050 <frexpf@plt>
mov    -0x14(%rbp),%edi
sub    $0x18,%edi
movsd  0xe5b(%rip),%xmm0
call   1060 <ldexpf@plt>
mov    %eax,%edi
mov    0x2e35(%rip),%rax
movsd  (%rax),%xmm0
call   1040 <fmaxf@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ulp>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114a <ulp+0x1a>
jp     114a <ulp+0x1a>
mov    0x2ea4(%rip),%rax
movsd  (%rax),%xmm0
pop    %rax
ret
andpd  0xeae(%rip),%xmm0
lea    0x4(%rsp),%rdi
call   1040 <frexpf@plt>
mov    0x4(%rsp),%edi
add    $0xffffffe8,%edi
movsd  0xea5(%rip),%xmm0
call   1050 <ldexpf@plt>
mov    0x2e71(%rip),%rcx
movsd  (%rcx),%xmm0
mov    %eax,%edi
pop    %rax
jmp    1030 <fmaxf@plt>

LLVM IR (-O0):
@FLT_MIN = global double 0.000000e+00
define double @ulp(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = call double @fabsf(double %5)
store double %6, double* %3
%7 = load double, double* %3
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load double, double* @FLT_MIN
store double %10, double* %2
br label %20
11: ; preds = %1
%12 = load double, double* %3
%13 = call i32 @frexpf(double %12, i32* %4)
br label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 24
%17 = call i32 @ldexpf(double 1.000000e+00, i32 %16)
%18 = load double, double* @FLT_MIN
%19 = call double @fmaxf(i32 %17, double %18)
store double %19, double* %2
br label %20
20: ; preds = %14, %9
%21 = load double, double* %2
ret double %21
}

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