// File: /workspace/github_c_makefile_star2_O1/oridb[P]mc/parse/tok.c
// Function: number
static Tok *
number(int base)
{
	Tok *t;
	int start;
	int c;
	int isfloat;
	int maybefloat;
	int unsignedval;
	/* because we allow '_' in numbers, and strtod/stroull don't, we
	 * need a buffer that holds the number without '_'.
	 */
	char buf[2048];
	char *endp;
	size_t nbuf;

	t = NULL;
	isfloat = 0;
	start = fidx;
	nbuf = 0;
	/* allow floating point literals only if the previous token was
	 * not a dot; this lets the user write "foo.1.2" to access nested
	 * tuple fields.
	 */
	maybefloat = !curtok || (curtok->type != Tdot);
	for (c = peek(); isxdigit(c) || (maybefloat && c == '.') || c == '_'; c = peek()) {
		next();
		if (c == '_')
			continue;
		if (nbuf >= sizeof buf - 1) {
			buf[nbuf - 1] = '\0';
			lfatal(curloc, "number %s... too long to represent", buf);
		}

		/* float radix */
		if (c == '.') {
			isfloat = 1;
			buf[nbuf++] = c;
		/* exponential notation */
		} else if (base == 10 && (c == 'e' || c == 'E')) {
			isfloat = 1;
			buf[nbuf++] = c;
			if ((peek() == '+' || peek() == '-') && nbuf < sizeof buf - 1)
				buf[nbuf++] = next();
		/* out of range */
		} else if (hexval(c) < 0 || hexval(c) >= base) {
			lfatal(curloc, "Integer digit '%c' outside of base %d", c, base);
		/* just a number */
		} else {
			buf[nbuf++] = c;
		}
	}
	buf[nbuf] = '\0';

	/* we only support base 10 floats */
	if (isfloat) {
		if (base != 10)
			lfatal(curloc, "%s is not a valid floating point value", buf);
		t = mktok(Tfloatlit);
		t->id = strdupn(&fbuf[start], fidx - start);
		t->fltval = strtod(buf, &endp);
		if (endp == buf)
			lfatal(curloc, "%s is not a valid floating point value", buf);
	} else {
		t = mktok(Tintlit);
		t->id = strdupn(&fbuf[start], fidx - start);
		t->intval = strtoull(buf, &endp, base);
		if (endp == buf)
			lfatal(curloc, "%s is not a valid integer value", buf);
			
		/* check suffixes:
		 *   u -> unsigned
		 *   l -> 64 bit
		 *   i -> 32 bit
		 *   w -> 16 bit
		 *   b -> 8 bit
		 */
		unsignedval = 0;
nextsuffix
:
		switch (peek()) {
		case 'u':
		case 'U':
			if (unsignedval == 1)
				lfatal(curloc, "Duplicate 'u' integer specifier");
			next();
			unsignedval = 1;
			goto nextsuffix;
		case 'l':
		case 'L':
			next();
			if (unsignedval)
				t->inttype = Tyuint64;
			else
				t->inttype = Tyint64;
			break;
		case 'i':
		case 'I':
			next();
			if (unsignedval)
				t->inttype = Tyuint32;
			else
				t->inttype = Tyint32;
			break;
		case 's':
		case 'S':
			next();
			if (unsignedval)
				t->inttype = Tyuint16;
			else
				t->inttype = Tyint16;
			break;
		case 'b':
		case 'B':
			next();
			if (unsignedval)
				t->inttype = Tyuint8;
			else
				t->inttype = Tyint8;
			break;
		default:
			if (unsignedval)
				lfatal(
						curloc, "Unrecognized character int type specifier after 'u'");
			break;
		}
	}

	return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movl %edi, %r15d
movslq 0x3fa43(%rip), %rcx     # 0x621b8
movq 0x3fa4c(%rip), %rax     # 0x621c8
testq %rax, %rax
je 0x2278e
cmpl $0x14b, (%rax)          # imm = 0x14B
setne 0x7(%rsp)
jmp 0x22793
movb $0x1, 0x7(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl 0x3fa0a(%rip), %ecx     # 0x621a8
jge 0x227ab
movq 0x3f9f9(%rip), %rax     # 0x621a0
movsbl (%rax,%rcx), %ebp
movq %rcx, 0x8(%rsp)
xorl %r13d, %r13d
callq 0x4390
movq %rax, %r14
xorl %r12d, %r12d
movq (%r14), %rax
movslq %ebp, %rcx
testb $0x10, 0x1(%rax,%rcx,2)
jne 0x227e0
cmpl $0x2e, %ebp
sete %al
cmpl $0x5f, %ebp
je 0x227e0
andb 0x7(%rsp), %al
je 0x22926
movslq 0x3f9d1(%rip), %rax     # 0x621b8
movl 0x3f9bb(%rip), %esi     # 0x621a8
leaq 0x1(%rax), %rdx
movl %edx, 0x3f9c1(%rip)     # 0x621b8
cmpl $0x5f, %ebp
je 0x228a7
cmpq $0x7ff, %r12            # imm = 0x7FF
jae 0x22b74
movl $0x1, %ebx
cmpl $0x2e, %ebp
jne 0x22825
movq %r12, %rcx
movb $0x2e, %bpl
movl $0x1, %r13d
jmp 0x2289f
cmpl $0xa, %r15d
jne 0x2286f
movl %ebp, %ecx
andl $-0x21, %ecx
cmpl $0x45, %ecx
jne 0x2286f
leaq 0x1(%r12), %rcx
movb %bpl, 0x20(%rsp,%r12)
cmpl %esi, %edx
jge 0x228e4
movq 0x3f952(%rip), %rdi     # 0x621a0
cmpb $0x2b, (%rdi,%rdx)
jne 0x228cf
cmpq $0x7fe, %r12            # imm = 0x7FE
jne 0x228fc
movl $0x7ff, %r12d           # imm = 0x7FF
movl $0x1, %r13d
jmp 0x228a7
movq %r13, 0x10(%rsp)
movl %r15d, %r13d
movsbl %bpl, %r15d
movl %r15d, %edi
callq 0x22718
movl %r15d, %edi
movl %r13d, %r15d
movq 0x10(%rsp), %r13
callq 0x22718
movq %r12, %rcx
cmpl %r15d, %eax
jge 0x22b94
addq %rbx, %r12
movb %bpl, 0x20(%rsp,%rcx)
movslq 0x3f90a(%rip), %rax     # 0x621b8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl 0x3f8ef(%rip), %eax     # 0x621a8
jge 0x227be
movq 0x3f8da(%rip), %rcx     # 0x621a0
movsbl (%rcx,%rax), %ebp
jmp 0x227be
cmpl %esi, %edx
jge 0x228e4
movq 0x3f8c6(%rip), %rdi     # 0x621a0
cmpb $0x2d, (%rdi,%rdx)
sete %dil
jmp 0x228e6
xorl %edi, %edi
cmpq $0x7fe, %r12            # imm = 0x7FE
setne %r8b
movl $0x1, %r13d
testb %r8b, %dil
je 0x22921
movb $-0x1, %bpl
cmpl %esi, %edx
jge 0x2290e
movq 0x3f896(%rip), %rsi     # 0x621a0
movb (%rsi,%rdx), %bpl
addl $0x2, %eax
movl %eax, 0x3f8a1(%rip)     # 0x621b8
movl $0x2, %ebx
jmp 0x2281d
movq %rcx, %r12
jmp 0x228a7
movb $0x0, 0x20(%rsp,%r12)
testl %r13d, %r13d
je 0x229b8
cmpl $0xa, %r15d
jne 0x22bc3
movl $0x48, %edi
callq 0x2d348
movq %rax, %r14
movl $0x139, (%rax)          # imm = 0x139
movq 0x3f857(%rip), %rax     # 0x621b0
movq %rax, 0x4(%r14)
movq 0x3f83c(%rip), %rdi     # 0x621a0
movq 0x8(%rsp), %rax
addq %rax, %rdi
movslq 0x3f845(%rip), %rsi     # 0x621b8
subq %rax, %rsi
callq 0x2e4ec
movq %rax, 0x10(%r14)
leaq 0x20(%rsp), %rbx
leaq 0x18(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40f0
movsd %xmm0, 0x28(%r14)
cmpq %rbx, (%r15)
je 0x22bc3
movq %r14, %rax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x48, %edi
callq 0x2d348
movq %rax, %r14
movl $0x137, (%rax)          # imm = 0x137
movq 0x3f7de(%rip), %rax     # 0x621b0
movq %rax, 0x4(%r14)
movq 0x3f7c3(%rip), %rdi     # 0x621a0
movq 0x8(%rsp), %rax
addq %rax, %rdi
movslq 0x3f7cc(%rip), %rsi     # 0x621b8
subq %rax, %rsi
callq 0x2e4ec
movq %rax, 0x10(%r14)
movl %r15d, %edx
leaq 0x20(%rsp), %r15
leaq 0x18(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4210
movq %rax, 0x18(%r14)
cmpq %r15, (%r12)
je 0x22bd3
movslq 0x3f783(%rip), %rdx     # 0x621a8
movslq 0x3f78c(%rip), %rsi     # 0x621b8
movq 0x3f76d(%rip), %rdi     # 0x621a0
leal 0x1(%rsi), %eax
movb $0x1, %cl
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpq %rdx, %rsi
jge 0x22a4b
movsbl (%rdi,%rsi), %r9d
cmpl $0x61, %r9d
jg 0x22a62
cmpl $0x52, %r9d
jle 0x22aa5
cmpl $0x55, %r9d
je 0x22a72
jmp 0x22b2a
cmpl $0x72, %r9d
jle 0x22a8e
cmpl $0x75, %r9d
jne 0x22b48
testb $0x1, %r8b
jne 0x22bae
incq %rsi
movl %eax, 0x3f733(%rip)     # 0x621b8
incl %eax
movb $0x1, %r8b
xorl %ecx, %ecx
jmp 0x22a3b
cmpl $0x62, %r9d
je 0x22ad3
cmpl $0x69, %r9d
je 0x22aeb
cmpl $0x6c, %r9d
je 0x22abb
jmp 0x22b4e
cmpl $0x42, %r9d
je 0x22ad3
cmpl $0x49, %r9d
je 0x22aeb
cmpl $0x4c, %r9d
jne 0x22b4e
movl %eax, 0x3f6f7(%rip)     # 0x621b8
testb $0x1, %cl
je 0x22b03
movl $0x8, 0x20(%r14)
jmp 0x229a3
movl %eax, 0x3f6df(%rip)     # 0x621b8
testb $0x1, %cl
je 0x22b10
movl $0x4, 0x20(%r14)
jmp 0x229a3
movl %eax, 0x3f6c7(%rip)     # 0x621b8
testb $0x1, %cl
je 0x22b1d
movl $0x7, 0x20(%r14)
jmp 0x229a3
movl $0xe, 0x20(%r14)
jmp 0x229a3
movl $0xa, 0x20(%r14)
jmp 0x229a3
movl $0xd, 0x20(%r14)
jmp 0x229a3
cmpl $0x53, %r9d
jne 0x22b4e
movl %eax, 0x3f682(%rip)     # 0x621b8
testb $0x1, %cl
je 0x22b67
movl $0x5, 0x20(%r14)
jmp 0x229a3
cmpl $0x73, %r9d
je 0x22b30
testb $0x1, %cl
jne 0x229a3
movq 0x3f652(%rip), %rdi     # 0x621b0
leaq 0x15019(%rip), %rsi     # 0x37b7e
jmp 0x22bbc
movl $0xb, 0x20(%r14)
jmp 0x229a3
leaq 0x20(%rsp), %rdx
movb $0x0, -0x1(%r12,%rdx)
movq 0x3f62a(%rip), %rdi     # 0x621b0
leaq 0x14f41(%rip), %rsi     # 0x37ace
xorl %eax, %eax
callq 0x13b8e
movq 0x3f615(%rip), %rdi     # 0x621b0
leaq 0x14f4f(%rip), %rsi     # 0x37af1
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x13b8e
movq 0x3f5fb(%rip), %rdi     # 0x621b0
leaq 0x14fa2(%rip), %rsi     # 0x37b5e
xorl %eax, %eax
callq 0x13b8e
movq 0x3f5e6(%rip), %rdi     # 0x621b0
leaq 0x14f46(%rip), %rsi     # 0x37b17
jmp 0x22be1
movq 0x3f5d6(%rip), %rdi     # 0x621b0
leaq 0x14f5d(%rip), %rsi     # 0x37b3e
leaq 0x20(%rsp), %rdx
jmp 0x22b8d