#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fabs(int /*<<< orphan*/);
int /*<<< orphan*/ fmod(double, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isinf(double);
scalar_t__ isnan(double);
scalar_t__ rint(double);
void pnum6(FILE *fp, double num) {
  if (isinf(num)) {
    fprintf(fp, "   inf");
  } else if (isnan(num)) {
    fprintf(fp, "   nan");
  } else if (fabs(fmod(num, 1)) < 1e-6) {
    fprintf(fp, " % 3d  ", (int)rint(num));
  } else {
    fprintf(fp, " % 5.1f", num);
  }
}


x86 assembly (clang, -O0):
<pnum6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1080 <isinf@plt>
cmp    $0x0,%rax
je     119c <pnum6+0x3c>
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    123f <pnum6+0xdf>
movsd  -0x10(%rbp),%xmm0
call   1070 <isnan@plt>
cmp    $0x0,%rax
je     11c7 <pnum6+0x67>
mov    -0x8(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    123a <pnum6+0xda>
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%edi
call   1030 <fmod@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe17(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    121e <pnum6+0xbe>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <rint@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1235 <pnum6+0xd5>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xdf0(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    123a <pnum6+0xda>
jmp    123f <pnum6+0xdf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnum6>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
call   1090 <isinf@plt>
test   %rax,%rax
je     1191 <pnum6+0x21>
lea    0xe71(%rip),%rdi
jmp    11a8 <pnum6+0x38>
movsd  0x8(%rsp),%xmm0
call   1070 <isnan@plt>
test   %rax,%rax
je     11bf <pnum6+0x4f>
lea    0xe5f(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x10,%rsp
pop    %rbx
jmp    1080 <fwrite@plt>
movsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
call   1030 <fmod@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
test   %eax,%eax
jle    11f6 <pnum6+0x86>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
add    $0x10,%rsp
pop    %rbx
jmp    1050 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
call   1060 <rint@plt>
lea    0xe06(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c" inf\00"
@.str.1 = [7 x i8] c" nan\00"
@.str.2 = [8 x i8] c" % 3d \00"
@.str.3 = [8 x i8] c" % 5.1f\00"
define void @pnum6(i32* %0, double %1) {
%3 = alloca i32*
%4 = alloca double
store i32* %0, i32** %3
store double %1, double* %4
%5 = load double, double* %4
%6 = call i64 @isinf(double %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32*, i32** %3
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %36
11: ; preds = %2
%12 = load double, double* %4
%13 = call i64 @isnan(double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %35
18: ; preds = %11
%19 = load double, double* %4
%20 = call i32 @fmod(double %19, i32 1)
%21 = call i32 @fabs(i32 %20)
%22 = sitofp i32 %21 to double
%23 = fcmp olt double %22, 0x3EB0C6F7A0B5ED8D
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load i32*, i32** %3
%26 = load double, double* %4
%27 = call i64 @rint(double %26)
%28 = trunc i64 %27 to i32
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %34
30: ; preds = %18
%31 = load i32*, i32** %3
%32 = load double, double* %4
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %32)
br label %34
34: ; preds = %30, %24
br label %35
35: ; preds = %34, %15
br label %36
36: ; preds = %35, %8
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c" inf\00"
@.str.1 = [7 x i8] c" nan\00"
@.str.2 = [8 x i8] c" % 3d \00"
@.str.3 = [8 x i8] c" % 5.1f\00"
define void @pnum6(i32* nocapture %0, double %1) {
%3 = tail call i64 @isinf(double %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %22
7: ; preds = %2
%8 = tail call i64 @isnan(double %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %22
12: ; preds = %7
%13 = tail call i32 @fmod(double %1, i32 1)
%14 = tail call i32 @fabs(i32 %13)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = tail call i64 @rint(double %1)
%18 = trunc i64 %17 to i32
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %12
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %1)
br label %22
22: ; preds = %10, %20, %16, %5
ret void
}