#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 */
struct forth_instance {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ iswhitespace(char);
int my_atoi(char *, struct forth_instance *);
int my_isdigit(intptr_t, struct forth_instance *);
scalar_t__ st_pop(struct forth_instance *);
int /*<<< orphan*/ st_push(struct forth_instance *, int);
void number(struct forth_instance *fi) {
  intptr_t i = 0;
  char *name;
  (void)st_pop(fi);
  name = (char *)st_pop(fi);
  if (name[0] == '-' && my_isdigit((intptr_t)name[1], fi) != -1)
    i = 2;
  while (!iswhitespace(name[i]) && name[i] != '\0') {
    if (my_isdigit((intptr_t)name[i], fi) == -1) {
      st_push(fi, 0);
      return;
    }
    i++;
  }
  st_push(fi, my_atoi(name, fi));
  st_push(fi, 1);
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <st_pop@plt>
mov    -0x8(%rbp),%rdi
call   1050 <st_pop@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11ad <number+0x5d>
mov    -0x18(%rbp),%rax
movsbq 0x1(%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <my_isdigit@plt>
cmp    $0xffffffff,%eax
je     11ad <number+0x5d>
movq   $0x2,-0x10(%rbp)
jmp    11b2 <number+0x62>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <iswhitespace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    11e8 <number+0x98>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11f8 <number+0xa8>
jmp    1238 <number+0xe8>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbq (%rax,%rcx,1),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <my_isdigit@plt>
cmp    $0xffffffff,%eax
jne    1227 <number+0xd7>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <st_push@plt>
jmp    1266 <number+0x116>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b2 <number+0x62>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <my_atoi@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1070 <st_push@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1070 <st_push@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1050 <st_pop@plt>
mov    %r15,%rdi
call   1050 <st_pop@plt>
mov    %rax,%r14
mov    (%rax),%al
cmp    $0x2d,%al
jne    118c <number+0x3c>
movsbq 0x1(%r14),%rdi
mov    %r15,%rsi
call   1060 <my_isdigit@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
setne  %bl
mov    (%r14,%rbx,2),%al
add    %rbx,%rbx
jmp    118e <number+0x3e>
xor    %ebx,%ebx
movsbl %al,%edi
call   1040 <iswhitespace@plt>
test   %eax,%eax
je     11c1 <number+0x71>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <my_atoi@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1070 <st_push@plt>
mov    $0x1,%esi
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <st_push@plt>
add    %r14,%rbx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbq -0x1(%rbx),%rdi
test   %rdi,%rdi
je     119a <number+0x4a>
mov    %r15,%rsi
call   1060 <my_isdigit@plt>
cmp    $0xffffffff,%eax
je     11f9 <number+0xa9>
movsbl (%rbx),%edi
call   1040 <iswhitespace@plt>
add    $0x1,%rbx
test   %eax,%eax
je     11d0 <number+0x80>
jmp    119a <number+0x4a>
xor    %esi,%esi
jmp    11b4 <number+0x64>

LLVM IR (-O0):
%struct.forth_instance = type { i32 }
define void @number(%struct.forth_instance* %0) {
%2 = alloca %struct.forth_instance*
%3 = alloca i64
%4 = alloca i8*
store %struct.forth_instance* %0, %struct.forth_instance** %2
store i64 0, i64* %3
%5 = load %struct.forth_instance*, %struct.forth_instance** %2
%6 = call i64 @st_pop(%struct.forth_instance* %5)
%7 = load %struct.forth_instance*, %struct.forth_instance** %2
%8 = call i64 @st_pop(%struct.forth_instance* %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 45
br i1 %14, label %15, label %24
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i64
%20 = load %struct.forth_instance*, %struct.forth_instance** %2
%21 = call i32 @my_isdigit(i64 %19, %struct.forth_instance* %20)
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %15
store i64 2, i64* %3
br label %24
24: ; preds = %23, %15, %1
br label %25
25: ; preds = %53, %24
%26 = load i8*, i8** %4
%27 = load i64, i64* %3
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @iswhitespace(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %25
%33 = load i8*, i8** %4
%34 = load i64, i64* %3
%35 = getelementptr inbounds i8, i8* %33, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br label %39
39: ; preds = %32, %25
%40 = phi i1 [ false, %25 ], [ %38, %32 ]
br i1 %40, label %41, label %56
41: ; preds = %39
%42 = load i8*, i8** %4
%43 = load i64, i64* %3
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i64
%47 = load %struct.forth_instance*, %struct.forth_instance** %2
%48 = call i32 @my_isdigit(i64 %46, %struct.forth_instance* %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %41
%51 = load %struct.forth_instance*, %struct.forth_instance** %2
%52 = call i32 @st_push(%struct.forth_instance* %51, i32 0)
br label %64
53: ; preds = %41
%54 = load i64, i64* %3
%55 = add nsw i64 %54, 1
store i64 %55, i64* %3
br label %25
56: ; preds = %39
%57 = load %struct.forth_instance*, %struct.forth_instance** %2
%58 = load i8*, i8** %4
%59 = load %struct.forth_instance*, %struct.forth_instance** %2
%60 = call i32 @my_atoi(i8* %58, %struct.forth_instance* %59)
%61 = call i32 @st_push(%struct.forth_instance* %57, i32 %60)
%62 = load %struct.forth_instance*, %struct.forth_instance** %2
%63 = call i32 @st_push(%struct.forth_instance* %62, i32 1)
br label %64
64: ; preds = %56, %50
ret void
}

LLVM IR (-O2):
%struct.forth_instance = type { i32 }
define void @number(%struct.forth_instance* %0) {
%2 = tail call i64 @st_pop(%struct.forth_instance* %0)
%3 = tail call i64 @st_pop(%struct.forth_instance* %0)
%4 = inttoptr i64 %3 to i8*
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 45
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i64
%11 = tail call i32 @my_isdigit(i64 %10, %struct.forth_instance* %0)
%12 = icmp eq i32 %11, -1
%13 = select i1 %12, i64 0, i64 2
%14 = getelementptr inbounds i8, i8* %4, i64 %13
%15 = load i8, i8* %14
br label %16
16: ; preds = %7, %1
%17 = phi i8 [ %5, %1 ], [ %15, %7 ]
%18 = phi i64 [ 0, %1 ], [ %13, %7 ]
%19 = tail call i32 @iswhitespace(i8 signext %17)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %38
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %4, i64 %18
br label %28
23: ; preds = %33
%24 = getelementptr inbounds i8, i8* %4, i64 %37
%25 = load i8, i8* %24
%26 = tail call i32 @iswhitespace(i8 signext %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %21, %23
%29 = phi i8* [ %24, %23 ], [ %22, %21 ]
%30 = phi i64 [ %37, %23 ], [ %18, %21 ]
%31 = load i8, i8* %29
%32 = icmp eq i8 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = sext i8 %31 to i64
%35 = tail call i32 @my_isdigit(i64 %34, %struct.forth_instance* %0)
%36 = icmp eq i32 %35, -1
%37 = add nuw nsw i64 %30, 1
br i1 %36, label %41, label %23
38: ; preds = %28, %23, %16
%39 = tail call i32 @my_atoi(i8* %4, %struct.forth_instance* %0)
%40 = tail call i32 @st_push(%struct.forth_instance* %0, i32 %39)
br label %41
41: ; preds = %33, %38
%42 = phi i32 [ 1, %38 ], [ 0, %33 ]
%43 = tail call i32 @st_push(%struct.forth_instance* %0, i32 %42)
ret void
}