// File: /workspace/github_c_makefile_star2_O2/tabemann[P]attoforth/src/runtime/inner.c
// Function: af_parse_2number
af_bool_t af_parse_2number(af_global_t* global, af_cell_t base,
			   af_byte_t* text, size_t length,
			   af_sign_2cell_t* result) {
  af_sign_2cell_t value = 0;
  af_bool_t success = FALSE;
  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--) {
	  if(*text == '.' && length == 0) {
	    success = TRUE;
	    break;
	  }
	  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 0x3aa7
movq %rdx, %rdi
movzbl (%rdx), %eax
cmpl $0x23, %eax
je 0x3987
cmpl $0x24, %eax
je 0x3963
cmpl $0x2f, %eax
je 0x3975
cmpl $0x25, %eax
jne 0x3997
incq %rdi
decq %rcx
movabsq $0x2, %rsi
jmp 0x3997
incq %rdi
decq %rcx
movabsq $0x10, %rsi
jmp 0x3997
incq %rdi
decq %rcx
movabsq $0x8, %rsi
jmp 0x3997
incq %rdi
decq %rcx
movabsq $0xa, %rsi
testq %rcx, %rcx
sete %al
leaq -0x2(%rsi), %rdx
cmpq $0x23, %rdx
setae %dl
orb %al, %dl
jne 0x3aa7
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movb (%rdi), %r9b
xorl %eax, %eax
cmpb $0x2d, %r9b
sete %al
cmpq %rax, %rcx
je 0x3ab0
negq %rax
xorl %edx, %edx
movb %r9b, -0x1(%rsp)
cmpb $0x2d, %r9b
sete %dl
addq %rdx, %rdi
leaq -0xa(%rsi), %rbx
addq %rax, %rcx
negq %rcx
movabsq $0x1, %r14
xorl %eax, %eax
xorl %r15d, %r15d
leaq (%rcx,%r14), %rdx
cmpq $0x1, %rdx
je 0x3ab9
movb -0x1(%rdi,%r14), %r9b
testq %rdx, %rdx
jne 0x3a1e
cmpb $0x2e, %r9b
je 0x3ac3
movzbl %r9b, %r12d
mulq %rsi
leal -0x30(%r9), %r11d
cmpb $0x9, %r11b
ja 0x3a3d
addl $-0x30, %r12d
cmpl %esi, %r12d
jb 0x3a8b
jmp 0x3ad8
leal -0x61(%r9), %r11d
cmpb $0x19, %r11b
ja 0x3a5b
leal -0x61(%r12), %r9d
cmpq %r9, %rbx
jbe 0x3ad8
addl $-0x57, %r12d
jmp 0x3a8b
addb $-0x41, %r9b
xorl %r13d, %r13d
movl $0x0, %ebp
cmpb $0x19, %r9b
ja 0x3b24
leal -0x41(%r12), %r10d
movl $0x0, %r11d
movl $0x0, %r9d
cmpq %r10, %rbx
jbe 0x3ae3
addl $-0x37, %r12d
imulq %rsi, %r15
addq %r15, %rdx
movl %r12d, %r9d
addq %r9, %rax
adcq $0x0, %rdx
incq %r14
movq %rdx, %r15
jmp 0x39fc
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r9d, %r9d
jmp 0x3b19
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r9d, %r9d
jmp 0x3b0f
xorl %ebp, %ebp
movq %rax, %r13
movq %r15, %r11
jmp 0x3ae0
movb $0x1, %bpl
movq %rax, %r13
movq %r15, %r11
movabsq $-0x1, %r9
jmp 0x3ae3
xorl %r13d, %r13d
xorl %r11d, %r11d
xorl %ebp, %ebp
xorl %r9d, %r9d
cmpb $0x2d, -0x1(%rsp)
sete %dl
xorl %ecx, %ecx
movq %r13, %rax
negq %rax
sbbq %r11, %rcx
testb %bpl, %dl
cmoveq %r11, %rcx
cmoveq %r13, %rax
movabsq $-0x1, %rdx
cmovneq %rdx, %r9
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movq %rax, (%r8)
movq %rcx, 0x8(%r8)
movq %r9, %rax
retq
xorl %r11d, %r11d
jmp 0x3ae0