#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 */
scalar_t__ ERANGE;
double HUGE_VAL;
scalar_t__ errno;
double strtod(char const *, char **);
int is_number(const char *s) {
  double r;
  char *ep;
  errno = 0;
  r = strtod(s, &ep);
  if (ep == s || r == HUGE_VAL || errno == ERANGE)
    return 0;
  while (*ep == ' ' || *ep == '\t' || *ep == '\n')
    ep++;
  if (*ep == '\0')
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<is_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ead(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1185 <is_number+0x75>
movsd  -0x18(%rbp),%xmm0
mov    0x2e92(%rip),%rax
ucomisd (%rax),%xmm0
jne    116b <is_number+0x5b>
jp     116b <is_number+0x5b>
jmp    1185 <is_number+0x75>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rax
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%rax
jne    1191 <is_number+0x81>
movl   $0x0,-0x4(%rbp)
jmp    1214 <is_number+0x104>
jmp    1196 <is_number+0x86>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x21(%rbp)
je     11d0 <is_number+0xc0>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x21(%rbp)
je     11d0 <is_number+0xc0>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11e0 <is_number+0xd0>
jmp    11f1 <is_number+0xe1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1196 <is_number+0x86>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    120d <is_number+0xfd>
movl   $0x1,-0x4(%rbp)
jmp    1214 <is_number+0x104>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_number>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb2(%rip),%r14
movq   $0x0,(%r14)
mov    %rsp,%rsi
call   1030 <strtod@plt>
mov    (%rsp),%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
je     117e <is_number+0x6e>
mov    0x2ea9(%rip),%rdx
ucomisd (%rdx),%xmm0
jne    1147 <is_number+0x37>
jnp    117e <is_number+0x6e>
mov    (%r14),%rdx
mov    0x2e8f(%rip),%rsi
cmp    (%rsi),%rdx
jne    1164 <is_number+0x54>
jmp    117e <is_number+0x6e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
movzbl (%rcx),%edx
lea    -0x9(%rdx),%esi
cmp    $0x2,%sil
jb     1160 <is_number+0x50>
cmp    $0x20,%dl
je     1160 <is_number+0x50>
test   %dl,%dl
jne    117e <is_number+0x6e>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errno = global i64 0
@HUGE_VAL = global double 0.000000e+00
@ERANGE = global i64 0
define i32 @is_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca double
%5 = alloca i8*
store i8* %0, i8** %3
store i64 0, i64* @errno
%6 = load i8*, i8** %3
%7 = call double @strtod(i8* %6, i8** %5)
store double %7, double* %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %3
%10 = icmp eq i8* %8, %9
br i1 %10, label %19, label %11
11: ; preds = %1
%12 = load double, double* %4
%13 = load double, double* @HUGE_VAL
%14 = fcmp oeq double %12, %13
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i64, i64* @errno
%17 = load i64, i64* @ERANGE
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15, %11, %1
store i32 0, i32* %2
br label %48
20: ; preds = %15
br label %21
21: ; preds = %38, %20
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 32
br i1 %25, label %36, label %26
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 9
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = load i8*, i8** %5
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br label %36
36: ; preds = %31, %26, %21
%37 = phi i1 [ true, %26 ], [ true, %21 ], [ %35, %31 ]
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
br label %21
41: ; preds = %36
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
store i32 1, i32* %2
br label %48
47: ; preds = %41
store i32 0, i32* %2
br label %48
48: ; preds = %47, %46, %19
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@errno = global i64 0
@HUGE_VAL = global double 0.000000e+00
@ERANGE = global i64 0
define i32 @is_number(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i64 0, i64* @errno
%4 = call double @strtod(i8* %0, i8** %2)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, %0
%7 = load double, double* @HUGE_VAL
%8 = fcmp oeq double %4, %7
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %20, label %10
10: ; preds = %1
%11 = load i64, i64* @errno
%12 = load i64, i64* @ERANGE
%13 = icmp eq i64 %11, %12
br i1 %13, label %20, label %14
14: ; preds = %10, %17
%15 = phi i8* [ %18, %17 ], [ %5, %10 ]
%16 = load i8, i8* %15
switch i8 %16, label %20 [
i8 32, label %17
i8 9, label %17
i8 10, label %17
i8 0, label %19
]
17: ; preds = %14, %14, %14
%18 = getelementptr inbounds i8, i8* %15, i64 1
br label %14
19: ; preds = %14
br label %20
20: ; preds = %14, %19, %1, %10
%21 = phi i32 [ 0, %10 ], [ 0, %1 ], [ 1, %19 ], [ 0, %14 ]
ret i32 %21
}