// File: /workspace/github_c_makefile_star2_O1/tabemann[P]attoforth/src/runtime/inner.c
// Function: af_parse_number
af_bool_t af_parse_number(af_global_t* global, af_cell_t base,  af_byte_t* text,
			  size_t length, af_sign_cell_t* result) {
  af_sign_cell_t value = 0;
  af_bool_t success = TRUE;
  af_bool_t negative = FALSE;
  if(length > 0) {
    if(*text == '%') {
      base = 2;
      text++;
      length--;
    } else if(*text == '/') {
      base = 8;
      text++;
      length--;
    } else if(*text == '#') {
      base = 10;
      text++;
      length--;
    } else if(*text == '$') {
      base = 16;
      text++;
      length--;
    }
    if(length > 0 && base >= 2 && base <= 36) {
      if(*text == '-') {
	negative = TRUE;
	text++;
	length--;
      }
      if(length > 0) {
	while(length--) {
	  value *= base;
	  if(*text >= '0' && *text <= '9') {
	    if(*text - '0' < base) {
	      value += *text++ - '0';
	    } else {
	      value = 0;
	      success = FALSE;
	      break;
	    }
	  } else if(*text >= 'a' && *text <= 'z') {
	    if(*text - 'a' < base - 10) {
	      value += (*text++ - 'a') + 10;
	    } else {
	      value = 0;
	      success = FALSE;
	      break;
	    }
	  } else if(*text >= 'A' && *text <= 'Z') {
	    if(*text - 'A' < base - 10) {
	      value += (*text++ - 'A') + 10;
	    } else {
	      value = 0;
	      success = FALSE;
	      break;
	    }
	  } else {
	    value = 0;
	    success = FALSE;
	    break;
	  }
	}
	if(success && negative) {
	  value = -value;
	}
      } else {
	value = 0;
	success = FALSE;
      }
    } else {
      value = 0;
      success = FALSE;
    }
  } else {
    value = 0;
    success = FALSE;
  }
  *result = value;
  return success;
}

// Assembly:
testq %rcx, %rcx
je 0x39b7
movzbl (%rdx), %eax
cmpl $0x24, %eax
jg 0x38ba
cmpl $0x23, %eax
je 0x38d1
cmpl $0x24, %eax
jne 0x38e9
incq %rdx
decq %rcx
movl $0x10, %esi
jmp 0x38e9
cmpl $0x2f, %eax
je 0x38de
cmpl $0x25, %eax
jne 0x38e9
incq %rdx
decq %rcx
movl $0x2, %esi
jmp 0x38e9
incq %rdx
decq %rcx
movl $0xa, %esi
jmp 0x38e9
incq %rdx
decq %rcx
movl $0x8, %esi
testq %rcx, %rcx
sete %al
leaq -0x2(%rsi), %rdi
cmpq $0x23, %rdi
setae %dil
orb %al, %dil
jne 0x39b7
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movb (%rdx), %al
xorl %edi, %edi
cmpb $0x2d, %al
sete %dil
cmpq %rdi, %rcx
je 0x39bd
negq %rdi
xorl %r9d, %r9d
cmpb $0x2d, %al
sete %r9b
addq %r9, %rdx
leaq -0xa(%rsi), %r9
addq %rdi, %rcx
negq %rcx
xorl %edi, %edi
xorl %ebx, %ebx
xorl %r10d, %r10d
xorl %r11d, %r11d
movzbl (%rdx,%rbx), %r14d
leal -0x30(%r14), %ebp
cmpb $0x9, %bpl
ja 0x395c
andl $0xf, %r14d
cmpq %r14, %rsi
ja 0x3995
jmp 0x39c3
leal -0x61(%r14), %ebp
cmpb $0x19, %bpl
ja 0x3975
leal -0x61(%r14), %r15d
cmpq %r15, %r9
jbe 0x39c3
addl $-0x57, %r14d
jmp 0x3995
movl %r14d, %ebp
addb $-0x41, %bpl
cmpb $0x19, %bpl
ja 0x39c3
leal -0x41(%r14), %r12d
movl $0x0, %r15d
cmpq %r12, %r9
jbe 0x39c6
addl $-0x37, %r14d
imulq %rsi, %r11
addq %r14, %r11
incq %rbx
movq %rcx, %r10
addq %rbx, %r10
sete %r10b
jne 0x3942
movq $-0x1, %r15
movq %r11, %rdi
jmp 0x39c6
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x39eb
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x39e3
xorl %r15d, %r15d
cmpb $0x2d, %al
sete %al
movq %rdi, %rcx
negq %rcx
testb %r10b, %al
cmoveq %rdi, %rcx
movq $-0x1, %rax
cmoveq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
movq %rcx, (%r8)
retq