#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__ isdigit(int);
int isnumstr(const char *str) {
  const char *p;
  int ch;
  if (*(p = str) == '-')
    p++;
  if (!isdigit(*p++))
    return 0;
  while (isdigit(ch = *p))
    p++;
  return !ch;
}


x86 assembly (clang, -O0):
<isnumstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    113c <isnumstr+0x2c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    1169 <isnumstr+0x59>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <isnumstr+0x99>
jmp    116e <isnumstr+0x5e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
mov    %edi,-0x1c(%rbp)
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1198 <isnumstr+0x88>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116e <isnumstr+0x5e>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isnumstr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
cmpb   $0x2d,(%rdi)
sete   %bl
movsbl (%rdi,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     115f <isnumstr+0x4f>
add    %r14,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%ebp
movsbl %bpl,%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <isnumstr+0x30>
xor    %eax,%eax
test   %bpl,%bpl
sete   %al
jmp    1161 <isnumstr+0x51>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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