#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_digit(char *string) {
  const char numbers[11] = "0987654321";
  int i, y;
  for (i = 0; i < strlen(string); i++) {
    for (y = 0; y < strlen(numbers); i++) {
      if (string[i] != numbers[y]) {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x1b(%rbp)
mov    0xeda(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xed2(%rip),%al
mov    %al,-0x11(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11d0 <is_digit+0xc0>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x1b(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11bd <is_digit+0xad>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movslq -0x24(%rbp),%rcx
movsbl -0x1b(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11aa <is_digit+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <is_digit+0xc7>
jmp    11af <is_digit+0x9f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1165 <is_digit+0x55>
jmp    11c2 <is_digit+0xb2>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1142 <is_digit+0x32>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_digit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movabs $0x3334353637383930,%rax
35 34 33
mov    %rax,0x8(%rsp)
movl   $0x313233,0xf(%rsp)
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a5 <is_digit+0x95>
xor    %ebp,%ebp
lea    0x8(%rsp),%r15
jmp    115f <is_digit+0x4f>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jge    11a5 <is_digit+0x95>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1150 <is_digit+0x40>
movslq %ebp,%rbx
add    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
cmp    0x8(%rsp),%al
jne    119e <is_digit+0x8e>
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0x1,%rbx
add    $0x1,%ebp
test   %eax,%eax
jg     1180 <is_digit+0x70>
jmp    1150 <is_digit+0x40>
mov    $0x1,%eax
jmp    11a7 <is_digit+0x97>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.is_digit.numbers = [11 x i8] c"0987654321\00"
define i32 @is_digit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [11 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast [11 x i8]* %4 to i8*
store i32 0, i32* %5
br label %8
8: ; preds = %38, %1
%9 = load i32, i32* %5
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %41
13: ; preds = %8
store i32 0, i32* %6
br label %14
14: ; preds = %34, %13
%15 = load i32, i32* %6
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %37
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%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 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %25, %30
br i1 %31, label %32, label %33
32: ; preds = %19
store i32 1, i32* %2
br label %42
33: ; preds = %19
br label %34
34: ; preds = %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %14
37: ; preds = %14
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %8
41: ; preds = %8
store i32 0, i32* %2
br label %42
42: ; preds = %41, %32
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@__const.is_digit.numbers = [11 x i8] c"0987654321\00"
define i32 @is_digit(i8* %0) {
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%4 = call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %29
6: ; preds = %1, %24
%7 = phi i32 [ %26, %24 ], [ 0, %1 ]
%8 = call i32 @strlen(i8* %3)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = sext i32 %7 to i64
br label %12
12: ; preds = %10, %18
%13 = phi i64 [ %11, %10 ], [ %19, %18 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = load i8, i8* %3
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %12
%19 = add i64 %13, 1
%20 = call i32 @strlen(i8* %3)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %12, label %22
22: ; preds = %18
%23 = trunc i64 %19 to i32
br label %24
24: ; preds = %22, %6
%25 = phi i32 [ %7, %6 ], [ %23, %22 ]
%26 = add nsw i32 %25, 1
%27 = call i32 @strlen(i8* %0)
%28 = icmp slt i32 %26, %27
br i1 %28, label %6, label %29
29: ; preds = %24, %12, %1
%30 = phi i32 [ 0, %1 ], [ 1, %12 ], [ 0, %24 ]
ret i32 %30
}