#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ isfinite(double);
int /*<<< orphan*/ stdout;
void shownum(double d) {
  if (!isfinite(d))
    fprintf(stdout, "\t??.??\n");
  else if (d == (int)d)
    fprintf(stdout, "\t%d\n", (int)d);
  else
    fprintf(stdout, "\t%g\n", d);
}


x86 assembly (clang, -O0):
<shownum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    115c <shownum+0x3c>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11bc <shownum+0x9c>
movsd  -0x8(%rbp),%xmm0
cvttsd2si -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jne    119b <shownum+0x7b>
jp     119b <shownum+0x7b>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
cvttsd2si -0x8(%rbp),%edx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b7 <shownum+0x97>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
movsd  -0x8(%rbp),%xmm0
lea    0xe5d(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
jmp    11bc <shownum+0x9c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shownum>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1040 <isfinite@plt>
test   %eax,%eax
je     1165 <shownum+0x45>
movapd (%rsp),%xmm0
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
ucomisd %xmm0,%xmm1
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
jne    1180 <shownum+0x60>
jp     1180 <shownum+0x60>
cvttsd2si %xmm0,%edx
lea    0xeae(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
jmp    1030 <fprintf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
jmp    1030 <fprintf@plt>
lea    0xe86(%rip),%rsi
mov    $0x1,%al
add    $0x18,%rsp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [8 x i8] c"\09??.??\0A\00"
@.str.1 = [5 x i8] c"\09%d\0A\00"
@.str.2 = [5 x i8] c"\09%g\0A\00"
define void @shownum(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call i32 @isfinite(double %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @stdout
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %25
9: ; preds = %1
%10 = load double, double* %2
%11 = load double, double* %2
%12 = fptosi double %11 to i32
%13 = sitofp i32 %12 to double
%14 = fcmp oeq double %10, %13
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load i32, i32* @stdout
%17 = load double, double* %2
%18 = fptosi double %17 to i32
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %24
20: ; preds = %9
%21 = load i32, i32* @stdout
%22 = load double, double* %2
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %22)
br label %24
24: ; preds = %20, %15
br label %25
25: ; preds = %24, %6
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [8 x i8] c"\09??.??\0A\00"
@.str.1 = [5 x i8] c"\09%d\0A\00"
@.str.2 = [5 x i8] c"\09%g\0A\00"
define void @shownum(double %0) {
%2 = tail call i32 @isfinite(double %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %16
7: ; preds = %1
%8 = fptosi double %0 to i32
%9 = sitofp i32 %8 to double
%10 = fcmp oeq double %9, %0
%11 = load i32, i32* @stdout
br i1 %10, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %16
14: ; preds = %7
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %0)
br label %16
16: ; preds = %12, %14, %4
ret void
}