// File: /workspace/github_c_makefile_star2_O0/kisom[P]kam/compiler.c
// Function: parse_next
static int
parse_next(uint8_t cur)
{
	uint8_t	instr;

	if (compiler.in_num) {
		if ((cur > 0x2f) && (cur < 0x3a)) {
			if (compiler.buf_index == 5) {
				fprintf(stderr, "Compile failed: overflow.\n");
				return -1;
			}
			compiler.buf[compiler.buf_index++] = cur;
			return 0;
		} else {
			if (-1 == finalise_number()) {
				return -1;
			}
			compiler.in_num = 0;
		}
	}

	switch (cur) {
	case ' ':
	case '\t':
	case '\n':
	case '(':
		return 0;
	case ')':
		instr = INSTR_DO;
		if (0 == compiler.active_ops) {
			fprintf(stderr, "No active operators for DO.\n");
			return -1;
		}
		compiler.active_ops--;
		if (compiler.active_vals < 2) {
			fprintf(stderr, "Not enough values (%d) for DO.\n",
			    compiler.active_vals);
			return -1;
		}
		compiler.active_vals--;
		break;
	case '+':
		compiler.active_ops++;
		instr = INSTR_ADD;
		break;
	case '-':
		compiler.active_ops++;
		instr = INSTR_SUB;
		break;
	case '*':
		compiler.active_ops++;
		instr = INSTR_MUL;
		break;
	case '/':
		compiler.active_ops++;
		instr = INSTR_DIV;
		break;
	default:
		if ((cur > 0x2f) && (cur < 0x3a)) {
			compiler.in_num = 1;
			compiler.buf[compiler.buf_index++] = cur;
			return 0;
		} else {
			fprintf(stderr, "Unrecognised token %d\n", cur);
			return -1;
		}
	}
	enqueue8(compiler.q, instr);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
cmpl $0x0, 0x334b(%rip)      # 0x50c0
je 0x1e10
movzbl -0x5(%rbp), %eax
cmpl $0x2f, %eax
jle 0x1de8
movzbl -0x5(%rbp), %eax
cmpl $0x3a, %eax
jge 0x1de8
cmpl $0x5, 0x3338(%rip)      # 0x50cc
jne 0x1dba
movq 0x325b(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
leaq 0x1470(%rip), %rsi      # 0x3217
movb $0x0, %al
callq 0x10b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fae
movb -0x5(%rbp), %dl
movl 0x3309(%rip), %eax      # 0x50cc
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x32fe(%rip)      # 0x50cc
movslq %eax, %rcx
leaq 0x32e0(%rip), %rax      # 0x50b8
movb %dl, 0xc(%rax,%rcx)
movl $0x0, -0x4(%rbp)
jmp 0x1fae
callq 0x1fc0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x1e04
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fae
movl $0x0, 0x32b2(%rip)      # 0x50c0
jmp 0x1e10
movzbl -0x5(%rbp), %eax
addl $-0x9, %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0x26, %eax
ja 0x1f2b
movq -0x10(%rbp), %rax
leaq 0x11d3(%rip), %rcx      # 0x3004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x1fae
movb $0x6, -0x6(%rbp)
xorl %eax, %eax
cmpl 0x327e(%rip), %eax      # 0x50d0
jne 0x1e78
movq 0x319d(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
leaq 0x13cd(%rip), %rsi      # 0x3232
movb $0x0, %al
callq 0x10b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fae
movl 0x3252(%rip), %eax      # 0x50d0
addl $-0x1, %eax
movl %eax, 0x3249(%rip)      # 0x50d0
cmpl $0x2, 0x3246(%rip)      # 0x50d4
jge 0x1eba
movq 0x3161(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movl 0x3234(%rip), %edx      # 0x50d4
leaq 0x13a8(%rip), %rsi      # 0x324f
movb $0x0, %al
callq 0x10b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fae
movl 0x3214(%rip), %eax      # 0x50d4
addl $-0x1, %eax
movl %eax, 0x320b(%rip)      # 0x50d4
jmp 0x1f97
movl 0x31fc(%rip), %eax      # 0x50d0
addl $0x1, %eax
movl %eax, 0x31f3(%rip)      # 0x50d0
movb $0x1, -0x6(%rbp)
jmp 0x1f97
movl 0x31e4(%rip), %eax      # 0x50d0
addl $0x1, %eax
movl %eax, 0x31db(%rip)      # 0x50d0
movb $0x2, -0x6(%rbp)
jmp 0x1f97
movl 0x31cc(%rip), %eax      # 0x50d0
addl $0x1, %eax
movl %eax, 0x31c3(%rip)      # 0x50d0
movb $0x3, -0x6(%rbp)
jmp 0x1f97
movl 0x31b4(%rip), %eax      # 0x50d0
addl $0x1, %eax
movl %eax, 0x31ab(%rip)      # 0x50d0
movb $0x4, -0x6(%rbp)
jmp 0x1f97
movzbl -0x5(%rbp), %eax
cmpl $0x2f, %eax
jle 0x1f72
movzbl -0x5(%rbp), %eax
cmpl $0x3a, %eax
jge 0x1f72
movl $0x1, 0x3179(%rip)      # 0x50c0
movb -0x5(%rbp), %dl
movl 0x317c(%rip), %eax      # 0x50cc
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x3171(%rip)      # 0x50cc
movslq %eax, %rcx
leaq 0x3153(%rip), %rax      # 0x50b8
movb %dl, 0xc(%rax,%rcx)
movl $0x0, -0x4(%rbp)
jmp 0x1fae
movq 0x307f(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movzbl -0x5(%rbp), %edx
leaq 0x12e8(%rip), %rsi      # 0x326f
movb $0x0, %al
callq 0x10b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1fae
movq 0x311a(%rip), %rdi      # 0x50b8
movzbl -0x6(%rbp), %esi
callq 0x1590
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)