// File: /workspace/github_c_makefile_star2_O3/Oric4ever[P]lcc65/6502/build/../src/string.c
// Function: stringn
char *stringn(char *str, int n) {
	int i;
	unsigned int h;
	char *s1, *s2, *end;
	struct string *p;

	assert(str);
	if (n > 0 && str[0] >= '0' && str[0] <= '9') {
		if (n == 1)
			return nums[str[0]-'0'];
		else if (str[1] >= '0' && str[1] <= '9' && n == 2)
			return nums[10*(str[0]-'0') + str[1]-'0'];
	}
	for (h = 0, i = n, end = str; i > 0; i--)
		h = (h<<1) + scatter[(int)*end++];
	h &= TABLESIZE-1;
	for (p = buckets[h]; p; p = p->link)
		if (n == p->len)
			for (s1 = str, s2 = p->str; *s1 == *s2++; )
				if (++s1 == end)
					return p->str;
	if (next + n + 1 >= strlimit) {
		int m = roundup(n, 8) + BUFSIZE;
		next = alloc(m);
		strlimit = next + m;
	}
	p = (struct string *) alloc(sizeof *p);
	p->len = n;
	for (p->str = next; str < end; )
		*next++ = *str++;
	*next++ = 0;
	p->link = buckets[h];
	buckets[h] = p;
	return p->str;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x16d31
movl %esi, %r14d
movq %rdi, %rbx
testl %esi, %esi
jle 0x16b92
movsbl (%rbx), %eax
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x16bc3
cmpl $0x1, %r14d
jne 0x16b9a
addl $-0x30, %eax
leaq 0x11dc7(%rip), %rcx     # 0x28950
leaq (%rcx,%rax,8), %rax
jmp 0x16d1f
xorl %r13d, %r13d
movq %rbx, %rbp
jmp 0x16bf6
movsbl 0x1(%rbx), %ecx
cmpl $0x30, %ecx
jl 0x16bc3
cmpb $0x3a, %cl
setae %dl
cmpl $0x2, %r14d
setne %sil
orb %dl, %sil
jne 0x16bc3
leal (%rax,%rax,4), %eax
leal (%rcx,%rax,2), %eax
addl $0xfffffdf0, %eax       # imm = 0xFFFFFDF0
jmp 0x16b82
movl %r14d, %ebp
leal 0x1(%r14), %eax
xorl %r13d, %r13d
leaq 0x9d4c(%rip), %rcx      # 0x20920
movq %rbx, %rdx
addl %r13d, %r13d
movsbq (%rdx), %rsi
incq %rdx
addl (%rcx,%rsi,4), %r13d
decl %eax
cmpl $0x1, %eax
ja 0x16bd7
addq %rbx, %rbp
andl $0x3ff, %r13d           # imm = 0x3FF
leaq 0x17123(%rip), %r15     # 0x2dd20
movq (%r15,%r13,8), %rax
testq %rax, %rax
je 0x16c30
cmpl %r14d, 0x8(%rax)
jne 0x16c2a
movq (%rax), %rcx
movq %rbx, %rdx
movb (%rdx), %sil
cmpb (%rcx), %sil
jne 0x16c2a
incq %rcx
incq %rdx
cmpq %rbp, %rdx
jne 0x16c12
jmp 0x16d1f
movq 0x10(%rax), %rax
jmp 0x16c01
movq 0x190e9(%rip), %rcx     # 0x2fd20
movslq %r14d, %rax
addq %rcx, %rax
incq %rax
leaq 0x13b29(%rip), %r12     # 0x2a770
movq (%r12), %rdx
cmpq 0x190d6(%rip), %rax     # 0x2fd28
jb 0x16caf
leal 0x7(%r14), %eax
andl $-0x8, %eax
cltq
leaq 0x1000(%rax), %r15
leal 0x1000(%rax), %ecx
movl %ecx, (%rdx)
movq 0x8(%rdx), %rcx
addq %rcx, %rax
addq $0x1000, %rax           # imm = 0x1000
cmpq 0x10(%rdx), %rax
jae 0x16c85
movq %rax, 0x8(%rdx)
jmp 0x16c97
movl %r15d, %edi
movq %r12, %rsi
callq 0x17800
movq %rax, %rcx
movq (%r12), %rdx
movq %rcx, 0x19082(%rip)     # 0x2fd20
addq %rcx, %r15
movq %r15, 0x19080(%rip)     # 0x2fd28
leaq 0x17071(%rip), %r15     # 0x2dd20
movl $0x18, (%rdx)
movq 0x8(%rdx), %rax
leaq 0x18(%rax), %rsi
cmpq 0x10(%rdx), %rsi
jae 0x16cc9
movq %rsi, 0x8(%rdx)
jmp 0x16ce1
leaq 0x13aa0(%rip), %rsi     # 0x2a770
movl $0x18, %edi
callq 0x17800
movq 0x1903f(%rip), %rcx     # 0x2fd20
movl %r14d, 0x8(%rax)
movq %rcx, (%rax)
cmpq %rbx, %rbp
jbe 0x16d05
subq %rbx, %rbp
xorl %edx, %edx
movb (%rbx,%rdx), %sil
movb %sil, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rbp
jne 0x16cf2
addq %rdx, %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x19010(%rip)     # 0x2fd20
movb $0x0, (%rcx)
movq (%r15,%r13,8), %rcx
movq %rcx, 0x10(%rax)
movq %rax, (%r15,%r13,8)
movq (%rax), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9aa2(%rip), %rdi      # 0x207da
leaq 0x9a9f(%rip), %rsi      # 0x207de
leaq 0x9aa8(%rip), %rcx      # 0x207ee
movl $0x8e, %edx
callq 0x30d0