#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 FALSE;
int /*<<< orphan*/ isdigit(char const);
bool string_isnumber(const char *str) {
  int pos;
  for (pos = 0; str[pos]; pos++) {
    if (!isdigit(str[pos]))
      return FALSE;
  }
  return pos > 0;
}


x86 assembly (clang, -O0):
<string_isnumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1173 <string_isnumber+0x63>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1160 <string_isnumber+0x50>
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1182 <string_isnumber+0x72>
jmp    1165 <string_isnumber+0x55>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <string_isnumber+0x13>
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_isnumber>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%bpl
test   %bpl,%bpl
je     1147 <string_isnumber+0x37>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1151 <string_isnumber+0x41>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <string_isnumber+0x20>
xor    %eax,%eax
test   %bpl,%bpl
setne  %al
jmp    115a <string_isnumber+0x4a>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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