// File: /workspace/github_c_makefile_star2_O3/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 0x3c13
movq %rdx, %rdi
movzbl (%rdx), %eax
cmpl $0x24, %eax
jg 0x3ad2
cmpl $0x23, %eax
je 0x3ae9
cmpl $0x24, %eax
jne 0x3b01
incq %rdi
decq %rcx
movl $0x10, %esi
jmp 0x3b01
cmpl $0x2f, %eax
je 0x3af6
cmpl $0x25, %eax
jne 0x3b01
incq %rdi
decq %rcx
movl $0x2, %esi
jmp 0x3b01
incq %rdi
decq %rcx
movl $0xa, %esi
jmp 0x3b01
incq %rdi
decq %rcx
movl $0x8, %esi
testq %rcx, %rcx
sete %al
leaq -0x2(%rsi), %rdx
cmpq $0x23, %rdx
setae %dl
orb %al, %dl
jne 0x3c13
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 0x3c1c
negq %rax
xorl %edx, %edx
movb %r9b, -0x9(%rsp)
cmpb $0x2d, %r9b
sete %dl
addq %rdx, %rdi
leaq -0xa(%rsi), %r14
addq %rax, %rcx
negq %rcx
movq $0x0, -0x8(%rsp)
xorl %r12d, %r12d
xorl %eax, %eax
xorl %r15d, %r15d
movq $-0x1, %rbx
leaq (%rcx,%r12), %rdx
incq %rdx
sete %dl
movzbl (%rdi,%r12), %r13d
cmpl $0x2e, %r13d
sete %bpl
andb %dl, %bpl
jne 0x3c25
mulq %rsi
leal -0x30(%r13), %r9d
cmpb $0x9, %r9b
ja 0x3baa
addl $-0x30, %r13d
cmpl %esi, %r13d
jb 0x3be6
jmp 0x3c36
leal -0x61(%r13), %r9d
cmpb $0x19, %r9b
ja 0x3bc3
leal -0x61(%r13), %r9d
cmpq %r9, %r14
jbe 0x3c36
addl $-0x57, %r13d
jmp 0x3be6
leal -0x41(%r13), %r9d
cmpb $0x19, %r9b
ja 0x3c3f
leal -0x41(%r13), %r10d
movl $0x0, %r11d
movl $0x0, %r9d
cmpq %r10, %r14
jbe 0x3c45
addl $-0x37, %r13d
imulq %rsi, %r15
addq %rdx, %r15
movl %r13d, %edx
addq %rdx, %rax
adcq $0x0, %r15
incq %r12
movq %rcx, %rdx
addq %r12, %rdx
jne 0x3b6f
xorl %r9d, %r9d
movq %rax, -0x8(%rsp)
movq %r15, %r11
jmp 0x3c45
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r9d, %r9d
jmp 0x3c76
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r9d, %r9d
jmp 0x3c6c
movq %rax, -0x8(%rsp)
movq %r15, %r11
movq $-0x1, %r9
jmp 0x3c45
movq $0x0, -0x8(%rsp)
xorl %r11d, %r11d
xorl %r9d, %r9d
cmpb $0x2d, -0x9(%rsp)
sete %dl
xorl %ecx, %ecx
movq -0x8(%rsp), %rsi
movq %rsi, %rax
negq %rax
sbbq %r11, %rcx
testb %bpl, %dl
cmoveq %r11, %rcx
cmoveq %rsi, %rax
cmovneq %rbx, %r9
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movq %rax, (%r8)
movq %rcx, 0x8(%r8)
movq %r9, %rax
retq