#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 fabs(double);
scalar_t__ hIsFinite(double);
scalar_t__ hIsInd(double);
scalar_t__ hIsInf(double);
scalar_t__ hIsNan(double);
scalar_t__ hIsNeg(double);
scalar_t__ hIsZero(double);
int hPrintNumber(int, unsigned long long, int, int, int);
unsigned long long hScaleDoubleToULL(double, int *);
int fb_PrintUsingDouble(int fnum, double value, int mask) {
  int val_exp = 0;
  int flags;
  unsigned long long val_ull = 1;
  flags = 0x10;
  if (hIsNeg(value))
    flags |= 0x1;
  if (hIsZero(value)) {
    val_ull = 0;
    val_exp = 0;
  } else if (hIsFinite(value)) {
    value = fabs(value);
    val_ull = hScaleDoubleToULL(value, &val_exp);
  } else {
    if (hIsInf(value))
      flags |= 0x2;
    else if (hIsInd(value))
      flags |= 0x4;
    else if (hIsNan(value))
      flags |= 0x8;
    else
      ((void)0);
  }
  return hPrintNumber(fnum, val_ull, val_exp, flags, mask);
}


x86 assembly (clang, -O0):
<fb_PrintUsingDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x1,-0x28(%rbp)
movl   $0x10,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <hIsNeg@plt>
cmp    $0x0,%rax
je     11c6 <fb_PrintUsingDouble+0x46>
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <hIsZero@plt>
cmp    $0x0,%rax
je     11ee <fb_PrintUsingDouble+0x6e>
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    12ad <fb_PrintUsingDouble+0x12d>
movsd  -0x10(%rbp),%xmm0
call   1070 <hIsFinite@plt>
cmp    $0x0,%rax
je     122e <fb_PrintUsingDouble+0xae>
movsd  -0x10(%rbp),%xmm0
movaps 0xdf2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x18(%rbp),%rdi
call   1060 <hScaleDoubleToULL@plt>
mov    %rax,-0x28(%rbp)
jmp    12a8 <fb_PrintUsingDouble+0x128>
movsd  -0x10(%rbp),%xmm0
call   1080 <hIsInf@plt>
cmp    $0x0,%rax
je     1250 <fb_PrintUsingDouble+0xd0>
mov    -0x1c(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    12a3 <fb_PrintUsingDouble+0x123>
movsd  -0x10(%rbp),%xmm0
call   1090 <hIsInd@plt>
cmp    $0x0,%rax
je     1272 <fb_PrintUsingDouble+0xf2>
mov    -0x1c(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x1c(%rbp)
jmp    129e <fb_PrintUsingDouble+0x11e>
movsd  -0x10(%rbp),%xmm0
call   10a0 <hIsNan@plt>
cmp    $0x0,%rax
je     1294 <fb_PrintUsingDouble+0x114>
mov    -0x1c(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x1c(%rbp)
jmp    1299 <fb_PrintUsingDouble+0x119>
jmp    1299 <fb_PrintUsingDouble+0x119>
jmp    129e <fb_PrintUsingDouble+0x11e>
jmp    12a3 <fb_PrintUsingDouble+0x123>
jmp    12a8 <fb_PrintUsingDouble+0x128>
jmp    12ad <fb_PrintUsingDouble+0x12d>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1050 <hPrintNumber@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_PrintUsingDouble>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
movaps %xmm0,0x10(%rsp)
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
call   1030 <hIsNeg@plt>
cmp    $0x1,%rax
mov    $0x11,%ebx
sbb    $0x0,%ebx
movaps 0x10(%rsp),%xmm0
call   1040 <hIsZero@plt>
test   %rax,%rax
je     11c8 <fb_PrintUsingDouble+0x48>
movl   $0x0,0xc(%rsp)
xor    %edx,%edx
xor    %esi,%esi
jmp    123a <fb_PrintUsingDouble+0xba>
movaps 0x10(%rsp),%xmm0
call   1070 <hIsFinite@plt>
test   %rax,%rax
je     11f6 <fb_PrintUsingDouble+0x76>
movaps 0x10(%rsp),%xmm0
andps  0xe1d(%rip),%xmm0
lea    0xc(%rsp),%rdi
call   1060 <hScaleDoubleToULL@plt>
mov    %rax,%rsi
mov    0xc(%rsp),%edx
jmp    123a <fb_PrintUsingDouble+0xba>
movaps 0x10(%rsp),%xmm0
call   1080 <hIsInf@plt>
test   %rax,%rax
je     120a <fb_PrintUsingDouble+0x8a>
or     $0x2,%ebx
jmp    1233 <fb_PrintUsingDouble+0xb3>
movaps 0x10(%rsp),%xmm0
call   1090 <hIsInd@plt>
test   %rax,%rax
je     121e <fb_PrintUsingDouble+0x9e>
or     $0x4,%ebx
jmp    1233 <fb_PrintUsingDouble+0xb3>
movaps 0x10(%rsp),%xmm0
call   10a0 <hIsNan@plt>
mov    %ebx,%ecx
or     $0x8,%ecx
test   %rax,%rax
cmovne %ecx,%ebx
mov    $0x1,%esi
xor    %edx,%edx
mov    %ebp,%edi
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1050 <hPrintNumber@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fb_PrintUsingDouble(i32 %0, double %1, i32 %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i32 %0, i32* %4
store double %1, double* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i64 1, i64* %9
store i32 16, i32* %8
%10 = load double, double* %5
%11 = call i64 @hIsNeg(double %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i32, i32* %8
%15 = or i32 %14, 1
store i32 %15, i32* %8
br label %16
16: ; preds = %13, %3
%17 = load double, double* %5
%18 = call i64 @hIsZero(double %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i64 0, i64* %9
store i32 0, i32* %7
br label %56
21: ; preds = %16
%22 = load double, double* %5
%23 = call i64 @hIsFinite(double %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load double, double* %5
%27 = call double @llvm.fabs.f64(double %26)
store double %27, double* %5
%28 = load double, double* %5
%29 = call i64 @hScaleDoubleToULL(double %28, i32* %7)
store i64 %29, i64* %9
br label %55
30: ; preds = %21
%31 = load double, double* %5
%32 = call i64 @hIsInf(double %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %8
%36 = or i32 %35, 2
store i32 %36, i32* %8
br label %54
37: ; preds = %30
%38 = load double, double* %5
%39 = call i64 @hIsInd(double %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %8
%43 = or i32 %42, 4
store i32 %43, i32* %8
br label %53
44: ; preds = %37
%45 = load double, double* %5
%46 = call i64 @hIsNan(double %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* %8
%50 = or i32 %49, 8
store i32 %50, i32* %8
br label %52
51: ; preds = %44
br label %52
52: ; preds = %51, %48
br label %53
53: ; preds = %52, %41
br label %54
54: ; preds = %53, %34
br label %55
55: ; preds = %54, %25
br label %56
56: ; preds = %55, %20
%57 = load i32, i32* %4
%58 = load i64, i64* %9
%59 = load i32, i32* %7
%60 = load i32, i32* %8
%61 = load i32, i32* %6
%62 = call i32 @hPrintNumber(i32 %57, i64 %58, i32 %59, i32 %60, i32 %61)
ret i32 %62
}

LLVM IR (-O2):
define i32 @fb_PrintUsingDouble(i32 %0, double %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = tail call i64 @hIsNeg(double %1)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32 16, i32 17
%9 = tail call i64 @hIsZero(double %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %3
store i32 0, i32* %4
br label %34
12: ; preds = %3
%13 = tail call i64 @hIsFinite(double %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = tail call double @llvm.fabs.f64(double %1)
%17 = call i64 @hScaleDoubleToULL(double %16, i32* %4)
%18 = load i32, i32* %4
br label %34
19: ; preds = %12
%20 = tail call i64 @hIsInf(double %1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = or i32 %8, 2
br label %34
24: ; preds = %19
%25 = tail call i64 @hIsInd(double %1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = or i32 %8, 4
br label %34
29: ; preds = %24
%30 = tail call i64 @hIsNan(double %1)
%31 = icmp eq i64 %30, 0
%32 = or i32 %8, 8
%33 = select i1 %31, i32 %8, i32 %32
br label %34
34: ; preds = %29, %15, %27, %22, %11
%35 = phi i32 [ 0, %11 ], [ %18, %15 ], [ 0, %22 ], [ 0, %27 ], [ 0, %29 ]
%36 = phi i32 [ %8, %11 ], [ %8, %15 ], [ %23, %22 ], [ %28, %27 ], [ %33, %29 ]
%37 = phi i64 [ 0, %11 ], [ %17, %15 ], [ 1, %22 ], [ 1, %27 ], [ 1, %29 ]
%38 = call i32 @hPrintNumber(i32 %0, i64 %37, i32 %35, i32 %36, i32 %2)
ret i32 %38
}