#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*/ isdigit(char);
short isnum(char *str) {
  if (!str)
    return 0;
  if (*str == '-')
    str++;
  if (!str)
    return 0;
  while (*str) {
    if (!isdigit(*str))
      return 0;
    str++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1132 <isnum+0x22>
movw   $0x0,-0x2(%rbp)
jmp    11ad <isnum+0x9d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    114e <isnum+0x3e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <isnum+0x54>
movw   $0x0,-0x2(%rbp)
jmp    11ad <isnum+0x9d>
jmp    1169 <isnum+0x59>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a7 <isnum+0x97>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1196 <isnum+0x86>
movw   $0x0,-0x2(%rbp)
jmp    11ad <isnum+0x9d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1169 <isnum+0x59>
movw   $0x1,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isnum>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1159 <isnum+0x49>
xor    %ecx,%ecx
cmpb   $0x2d,(%rdi)
sete   %cl
mov    (%rdi,%rcx,1),%al
mov    $0x1,%bp
test   %al,%al
je     115b <isnum+0x4b>
lea    (%rcx,%rdi,1),%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1159 <isnum+0x49>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <isnum+0x30>
jmp    115b <isnum+0x4b>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @isnum(i8* %0) {
%2 = alloca i16
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i16 0, i16* %2
br label %34
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %15
15: ; preds = %12, %7
%16 = load i8*, i8** %3
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %15
store i16 0, i16* %2
br label %34
19: ; preds = %15
br label %20
20: ; preds = %30, %19
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i32 @isdigit(i8 signext %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %24
store i16 0, i16* %2
br label %34
30: ; preds = %24
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %20
33: ; preds = %20
store i16 1, i16* %2
br label %34
34: ; preds = %33, %29, %18, %6
%35 = load i16, i16* %2
ret i16 %35
}

LLVM IR (-O2):
define signext i16 @isnum(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 45
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %19, label %13
10: ; preds = %13
%11 = load i8, i8* %18
%12 = icmp eq i8 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %3, %10
%14 = phi i8 [ %11, %10 ], [ %8, %3 ]
%15 = phi i8* [ %18, %10 ], [ %7, %3 ]
%16 = tail call i32 @isdigit(i8 signext %14)
%17 = icmp eq i32 %16, 0
%18 = getelementptr inbounds i8, i8* %15, i64 1
br i1 %17, label %19, label %10
19: ; preds = %13, %10, %3, %1
%20 = phi i16 [ 0, %1 ], [ 1, %3 ], [ 0, %13 ], [ 1, %10 ]
ret i16 %20
}