#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 *);
int number(char *string) {
  int length = strlen(string);
  if (length <= 0) {
    return 0;
  }
  for (int i = 0; i < length; i++) {
    if (string[i] < '0' || string[i] > '9') {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     113e <number+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <number+0x91>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119a <number+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     117b <number+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1187 <number+0x77>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <number+0x91>
jmp    118c <number+0x7c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <number+0x35>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jle    1161 <number+0x51>
mov    (%r14),%dl
add    $0xc6,%dl
cmp    $0xf6,%dl
jb     1161 <number+0x51>
mov    %ecx,%ecx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rdx
cmp    %rax,%rcx
je     1159 <number+0x49>
movzbl (%r14,%rdx,1),%ebx
add    $0xc6,%bl
lea    0x1(%rdx),%rax
cmp    $0xf5,%bl
ja     1140 <number+0x30>
xor    %eax,%eax
cmp    %rcx,%rdx
setae  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @number(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 1
br i1 %3, label %22, label %4
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = zext i32 %2 to i64
%7 = load i8, i8* %0
%8 = add i8 %7, -58
%9 = icmp ult i8 %8, -10
br i1 %9, label %22, label %10
10: ; preds = %4, %13
%11 = phi i64 [ %18, %13 ], [ 1, %4 ]
%12 = icmp eq i64 %11, %6
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %0, i64 %11
%15 = load i8, i8* %14
%16 = add i8 %15, -58
%17 = icmp ult i8 %16, -10
%18 = add nuw nsw i64 %11, 1
br i1 %17, label %19, label %10
19: ; preds = %10, %13
%20 = icmp uge i64 %11, %5
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %4, %19, %1
%23 = phi i32 [ 0, %1 ], [ 0, %4 ], [ %21, %19 ]
ret i32 %23
}