#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*/ strchr(char *, char const);
size_t strlen(char const *);
int is_number(const char *s) {
  size_t i;
  for (i = 0; i < strlen(s); i++) {
    if (!strchr("0123456789", s[i])) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    1198 <is_number+0x78>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
lea    0xe9c(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
jne    1182 <is_number+0x62>
movl   $0x0,-0x4(%rbp)
jmp    119f <is_number+0x7f>
jmp    1187 <is_number+0x67>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1134 <is_number+0x14>
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   %rbx
push   %rax
mov    (%rdi),%al
mov    $0x1,%r14d
test   %al,%al
je     1184 <is_number+0x64>
mov    %rdi,%rbx
movsbl %al,%esi
lea    0xec0(%rip),%rdi
call   1040 <strchr@plt>
test   %eax,%eax
je     1181 <is_number+0x61>
mov    $0x1,%ebp
lea    0xeab(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbp
jae    1184 <is_number+0x64>
movsbl (%rbx,%rbp,1),%esi
mov    %r15,%rdi
call   1040 <strchr@plt>
add    $0x1,%rbp
test   %eax,%eax
jne    1160 <is_number+0x40>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
define i32 @is_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %4
br label %5
5: ; preds = %19, %1
%6 = load i64, i64* %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = icmp ult i64 %6, %8
br i1 %9, label %10, label %22
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i64, i64* %4
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %10
store i32 0, i32* %2
br label %23
18: ; preds = %10
br label %19
19: ; preds = %18
%20 = load i64, i64* %4
%21 = add i64 %20, 1
store i64 %21, i64* %4
br label %5
22: ; preds = %5
store i32 1, i32* %2
br label %23
23: ; preds = %22, %17
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [11 x i8] c"0123456789\00"
define i32 @is_number(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i32 @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4, %11
%8 = phi i64 [ %16, %11 ], [ 1, %4 ]
%9 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 %8
%13 = load i8, i8* %12
%14 = tail call i32 @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %13)
%15 = icmp eq i32 %14, 0
%16 = add nuw i64 %8, 1
br i1 %15, label %17, label %7
17: ; preds = %7, %11, %4, %1
%18 = phi i32 [ 1, %1 ], [ 0, %4 ], [ 0, %11 ], [ 1, %7 ]
ret i32 %18
}