#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 inf();
scalar_t__ memcmp(double *, double *, int);
int isinf(double n) {
  static double pinf = 0.0;
  static double ninf = 0.0;
  if (pinf == 0.0) {
    pinf = inf();
    ninf = -pinf;
  }
  return memcmp(&n, &pinf, sizeof n) == 0 || memcmp(&n, &ninf, sizeof n) == 0;
}


x86 assembly (clang, -O0):
<isinf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0x2f03(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117e <isinf+0x5e>
jp     117e <isinf+0x5e>
mov    $0x0,%al
call   1040 <inf@plt>
movsd  %xmm0,0x2ee1(%rip)
movsd  0x2ed9(%rip),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,0x2ec2(%rip)
lea    0x2eb3(%rip),%rsi
lea    -0x8(%rbp),%rdi
mov    $0x8,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x9(%rbp)
je     11c4 <isinf+0xa4>
lea    0x2e94(%rip),%rsi
lea    -0x8(%rbp),%rdi
mov    $0x8,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isinf>:
push   %rax
movsd  %xmm0,(%rsp)
movsd  0x2f0a(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1159 <isinf+0x39>
jp     1159 <isinf+0x39>
xor    %eax,%eax
call   1040 <inf@plt>
movsd  %xmm0,0x2eef(%rip)
xorpd  0xeaf(%rip),%xmm0
movlpd %xmm0,0x2ee7(%rip)
lea    0x2ed8(%rip),%rsi
mov    %rsp,%rdi
mov    $0x8,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1193 <isinf+0x73>
lea    0x2ec7(%rip),%rsi
mov    %rsp,%rdi
mov    $0x8,%edx
call   1030 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@isinf.pinf = internal global double 0.000000e+00
@isinf.ninf = internal global double 0.000000e+00
define i32 @isinf(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* @isinf.pinf
%4 = fcmp oeq double %3, 0.000000e+00
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = call double (...) @inf()
store double %6, double* @isinf.pinf
%7 = load double, double* @isinf.pinf
%8 = fneg double %7
store double %8, double* @isinf.ninf
br label %9
9: ; preds = %5, %1
%10 = call i64 @memcmp(double* %2, double* @isinf.pinf, i32 8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = call i64 @memcmp(double* %2, double* @isinf.ninf, i32 8)
%14 = icmp eq i64 %13, 0
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
@isinf.pinf = internal global double 0.000000e+00
@isinf.ninf = internal global double 0.000000e+00
define i32 @isinf(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* @isinf.pinf
%4 = fcmp oeq double %3, 0.000000e+00
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call double (...) @inf()
store double %6, double* @isinf.pinf
%7 = fneg double %6
store double %7, double* @isinf.ninf
br label %8
8: ; preds = %5, %1
%9 = call i64 @memcmp(double* %2, double* @isinf.pinf, i32 8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = call i64 @memcmp(double* %2, double* @isinf.ninf, i32 8)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %11, %8
%16 = phi i32 [ 1, %8 ], [ %14, %11 ]
ret i32 %16
}