int is_numconst(char *buffer) {
  char *p;
  bwx_DEBUG(__FUNCTION__);
  if (buffer[0] == '\0') {
    return 0;
  }
  p = buffer;
  while (*p != '\0') {
    switch (*p) {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      break;
    default:
      return 0;
    }
    ++p;
  }
  return -1;
}


x86 assembly (clang, -O0):
<is_numconst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <bwx_DEBUG@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1146 <is_numconst+0x36>
movl   $0x0,-0x4(%rbp)
jmp    119f <is_numconst+0x8f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1198 <is_numconst+0x88>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffd0,%eax
sub    $0x9,%eax
ja     117b <is_numconst+0x6b>
jmp    1176 <is_numconst+0x66>
jmp    1187 <is_numconst+0x77>
movl   $0x0,-0x4(%rbp)
jmp    119f <is_numconst+0x8f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114e <is_numconst+0x3e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_numconst>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <bwx_DEBUG@plt>
mov    (%rbx),%al
test   %al,%al
je     114b <is_numconst+0x3b>
add    $0x1,%rbx
movsbl %al,%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     114b <is_numconst+0x3b>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <is_numconst+0x20>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__FUNCTION__.is_numconst = [12 x i8] c"is_numconst\00"
define i32 @is_numconst(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @__FUNCTION__.is_numconst, i64 0, i64 0))
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %29
12: ; preds = %1
%13 = load i8*, i8** %3
store i8* %13, i8** %4
br label %14
14: ; preds = %25, %12
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %24 [
i32 48, label %23
i32 49, label %23
i32 50, label %23
i32 51, label %23
i32 52, label %23
i32 53, label %23
i32 54, label %23
i32 55, label %23
i32 56, label %23
i32 57, label %23
]
23: ; preds = %19, %19, %19, %19, %19, %19, %19, %19, %19, %19
br label %25
24: ; preds = %19
store i32 0, i32* %2
br label %29
25: ; preds = %23
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
br label %14
28: ; preds = %14
store i32 -1, i32* %2
br label %29
29: ; preds = %28, %24, %11
%30 = load i32, i32* %2
ret i32 %30
}

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