#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 */
scalar_t__ isdigit(int);
int is_number(char string[]) {
  char c = string[0];
  int i = 0;
  while (c != '\0') {
    int ci = c;
    if (isdigit(ci) == 0) {
      return 0;
    }
    c = string[i];
    i++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     117a <is_number+0x6a>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    115e <is_number+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    1181 <is_number+0x71>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <is_number+0x1c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_number>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
mov    $0x1,%ebp
test   %al,%al
je     114c <is_number+0x3c>
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     114a <is_number+0x3a>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <is_number+0x20>
jmp    114c <is_number+0x3c>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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