#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 lexer_valid_decimal(const char *text) {
  int i;
  i = 0;
  if (text[0] == '-')
    i = 1;
  while (i < strlen(text)) {
    if ((text[i] < '0') || (text[i] > '9'))
      return 0;
    i++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<lexer_valid_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    113a <lexer_valid_decimal+0x2a>
movl   $0x1,-0x14(%rbp)
jmp    113f <lexer_valid_decimal+0x2f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    119f <lexer_valid_decimal+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1185 <lexer_valid_decimal+0x75>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1191 <lexer_valid_decimal+0x81>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <lexer_valid_decimal+0x96>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <lexer_valid_decimal+0x2f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_valid_decimal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%r15b
xor    %ebp,%ebp
cmp    $0x2d,%r15b
sete   %bpl
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    %ebp,%eax
jle    115f <lexer_valid_decimal+0x4f>
xor    %ebp,%ebp
cmp    $0x2d,%r15b
sete   %bpl
movzbl (%rbx,%rbp,1),%eax
add    $0xc6,%al
cmp    $0xf5,%al
jbe    115c <lexer_valid_decimal+0x4c>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %ebp,%eax
jg     1140 <lexer_valid_decimal+0x30>
jmp    115f <lexer_valid_decimal+0x4f>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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