#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 */
typedef size_t uint8_t;

/* Variables and functions */
size_t strlen(char *);
uint8_t DoesStringIndicateAnInteger(char *str) {
  uint8_t len = strlen(str);
  for (uint8_t i = 0; i < len; i++) {
    if ((str[i] < '0') || (str[i] > '9'))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<DoesStringIndicateAnInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118c <DoesStringIndicateAnInteger+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1169 <DoesStringIndicateAnInteger+0x59>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1176 <DoesStringIndicateAnInteger+0x66>
movq   $0x0,-0x8(%rbp)
jmp    1194 <DoesStringIndicateAnInteger+0x84>
jmp    117b <DoesStringIndicateAnInteger+0x6b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1131 <DoesStringIndicateAnInteger+0x21>
movq   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoesStringIndicateAnInteger>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %rax,%rax
je     1130 <DoesStringIndicateAnInteger+0x20>
mov    (%r14),%cl
add    $0xc6,%cl
cmp    $0xf6,%cl
jae    1137 <DoesStringIndicateAnInteger+0x27>
xor    %ecx,%ecx
jmp    1161 <DoesStringIndicateAnInteger+0x51>
mov    $0x1,%ecx
jmp    1161 <DoesStringIndicateAnInteger+0x51>
mov    $0x1,%ecx
nopl   0x0(%rax)
mov    %rcx,%rdx
cmp    %rcx,%rax
je     1159 <DoesStringIndicateAnInteger+0x49>
movzbl (%r14,%rdx,1),%ebx
add    $0xc6,%bl
lea    0x1(%rdx),%rcx
cmp    $0xf5,%bl
ja     1140 <DoesStringIndicateAnInteger+0x30>
xor    %ecx,%ecx
cmp    %rax,%rdx
setae  %cl
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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