#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 *);
bool isIntegerConstant(char *buf) {
  for (int i = 0; i < strlen(buf); i++) {
    char c = buf[i];
    switch (c) {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      break;
    default:
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<isIntegerConstant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1186 <isIntegerConstant+0x76>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
add    $0xffffffd0,%eax
sub    $0x9,%eax
ja     1167 <isIntegerConstant+0x57>
jmp    1162 <isIntegerConstant+0x52>
jmp    1173 <isIntegerConstant+0x63>
movl   $0x0,-0x4(%rbp)
jmp    118d <isIntegerConstant+0x7d>
jmp    1178 <isIntegerConstant+0x68>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <isIntegerConstant+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isIntegerConstant>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    1154 <isIntegerConstant+0x44>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%eax
add    $0xffffffd0,%eax
cmp    $0xa,%eax
jae    1151 <isIntegerConstant+0x41>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1130 <isIntegerConstant+0x20>
jmp    1154 <isIntegerConstant+0x44>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isIntegerConstant(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %25
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %5
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
switch i32 %18, label %20 [
i32 48, label %19
i32 49, label %19
i32 50, label %19
i32 51, label %19
i32 52, label %19
i32 53, label %19
i32 54, label %19
i32 55, label %19
i32 56, label %19
i32 57, label %19
]
19: ; preds = %11, %11, %11, %11, %11, %11, %11, %11, %11, %11
br label %21
20: ; preds = %11
store i32 0, i32* %2
br label %26
21: ; preds = %19
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %6
25: ; preds = %6
store i32 1, i32* %2
br label %26
26: ; preds = %25, %20
%27 = load i32, i32* %2
ret i32 %27
}

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