#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 strlen(char const *);
int is_number(const char *p) {
  int i;
  int n = 0;
  for (i = 0; i < strlen(p) - 1; i++)
    if ((p[i] > 47) && (p[i] < 58))
      continue;
    else
      n = 1;
  return n;
}


x86 assembly (clang, -O0):
<is_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1192 <is_number+0x82>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jle    1178 <is_number+0x68>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jge    1178 <is_number+0x68>
jmp    1184 <is_number+0x74>
movl   $0x1,-0x10(%rbp)
jmp    1184 <is_number+0x74>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <is_number+0x1a>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_number>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
jl     1153 <is_number+0x43>
xor    %ebx,%ebx
mov    $0x1,%r15d
xor    %ebp,%ebp
movzbl (%r14,%rbx,1),%eax
add    $0xd0,%al
cmp    $0xa,%al
cmovae %r15d,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbx
jl     1130 <is_number+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_number(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %30, %1
%6 = load i32, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
%10 = icmp slt i32 %6, %9
br i1 %10, label %11, label %33
11: ; preds = %5
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sgt i32 %17, 47
br i1 %18, label %19, label %28
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp slt i32 %25, 58
br i1 %26, label %27, label %28
27: ; preds = %19
br label %30
28: ; preds = %19, %11
store i32 1, i32* %4
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29, %27
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %5
33: ; preds = %5
%34 = load i32, i32* %4
ret i32 %34
}

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