#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(unsigned char const);
unsigned is_number(const unsigned char *px, unsigned length) {
  unsigned i;
  for (i = 0; i < length; i++)
    if (!isdigit(px[i]))
      return 0;
  if (length == 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    116a <is_number+0x5a>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1157 <is_number+0x47>
movl   $0x0,-0x4(%rbp)
jmp    1187 <is_number+0x77>
jmp    115c <is_number+0x4c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <is_number+0x16>
cmpl   $0x0,-0x14(%rbp)
jne    1180 <is_number+0x70>
movl   $0x0,-0x4(%rbp)
jmp    1187 <is_number+0x77>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_number>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
test   %esi,%esi
je     1147 <is_number+0x37>
mov    %rdi,%r12
mov    %r14d,%ebx
xor    %r15d,%r15d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1151 <is_number+0x41>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <is_number+0x20>
xor    %r15d,%r15d
test   %r14d,%r14d
setne  %r15b
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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