#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 long LLONG_MAX;
int /*<<< orphan*/ sprintf(char *, char *, char const *, ...);
void print_ulps_helper(const char *name, long long ulps, char **failp) {
  if (ulps == LLONG_MAX) {
    *failp += sprintf(*failp, " %s=HUGE", name);
  } else {
    *failp += sprintf(*failp, " %s=%.3f", name, (double)ulps / (1 << (12)));
  }
}


x86 assembly (clang, -O0):
<print_ulps_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2eb9(%rip),%rcx
cmp    (%rcx),%rax
jne    1168 <print_ulps_helper+0x58>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
jmp    11a5 <print_ulps_helper+0x95>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rdx
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe85(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ulps_helper>:
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%rdx
mov    0x2eca(%rip),%rax
mov    (%rbx),%rdi
cmp    %rsi,(%rax)
jne    1136 <print_ulps_helper+0x26>
lea    0xedb(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    1151 <print_ulps_helper+0x41>
cvtsi2sd %rsi,%xmm0
mulsd  0xebd(%rip),%xmm0
lea    0xec7(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
cltq
add    %rax,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@LLONG_MAX = global i64 0
@.str = [9 x i8] c" %s=HUGE\00"
@.str.1 = [9 x i8] c" %s=%.3f\00"
define void @print_ulps_helper(i8* %0, i64 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8**
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8** %2, i8*** %6
%7 = load i64, i64* %5
%8 = load i64, i64* @LLONG_MAX
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %3
%11 = load i8**, i8*** %6
%12 = load i8*, i8** %11
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %15
%17 = sext i32 %14 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8* %18, i8** %15
br label %31
19: ; preds = %3
%20 = load i8**, i8*** %6
%21 = load i8*, i8** %20
%22 = load i8*, i8** %4
%23 = load i64, i64* %5
%24 = sitofp i64 %23 to double
%25 = fdiv double %24, 4.096000e+03
%26 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %22, double %25)
%27 = load i8**, i8*** %6
%28 = load i8*, i8** %27
%29 = sext i32 %26 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %27
br label %31
31: ; preds = %19, %10
ret void
}

LLVM IR (-O2):
@LLONG_MAX = global i64 0
@.str = [9 x i8] c" %s=HUGE\00"
@.str.1 = [9 x i8] c" %s=%.3f\00"
define void @print_ulps_helper(i8* %0, i64 %1, i8** nocapture %2) {
%4 = load i64, i64* @LLONG_MAX
%5 = icmp eq i64 %4, %1
%6 = load i8*, i8** %2
br i1 %5, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %13
9: ; preds = %3
%10 = sitofp i64 %1 to double
%11 = fmul double %10, 0x3F30000000000000
%12 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0, double %11)
br label %13
13: ; preds = %9, %7
%14 = phi i32 [ %12, %9 ], [ %8, %7 ]
%15 = load i8*, i8** %2
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8* %17, i8** %2
ret void
}