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


x86 assembly (clang, -O0):
<isnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1145 <isnum+0x35>
movl   $0x0,-0x4(%rbp)
jmp    1190 <isnum+0x80>
jmp    114a <isnum+0x3a>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,0x1(%rax)
je     1189 <isnum+0x79>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1184 <isnum+0x74>
movl   $0x0,-0x4(%rbp)
jmp    1190 <isnum+0x80>
jmp    114a <isnum+0x3a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isnum>:
movsbl (%rdi),%ecx
add    $0xffffffd0,%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
ja     1133 <isnum+0x33>
add    $0x1,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rdi),%ecx
test   %ecx,%ecx
je     1134 <isnum+0x34>
add    $0xffffffd0,%ecx
add    $0x1,%rdi
cmp    $0xa,%ecx
jb     1120 <isnum+0x20>
ret
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @isnum(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = add nsw i32 %3, -48
%5 = icmp ult i32 %4, 10
br i1 %5, label %6, label %15
6: ; preds = %1, %11
%7 = phi i8* [ %8, %11 ], [ %0, %1 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = sext i8 %9 to i32
%13 = add nsw i32 %12, -48
%14 = icmp ult i32 %13, 10
br i1 %14, label %6, label %15
15: ; preds = %6, %11, %1
%16 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 0, %11 ]
ret i32 %16
}