// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_graphics.c
// Function: subtilis_parser_colour
void subtilis_parser_colour(subtilis_parser_t *p, subtilis_token_t *t,
			    subtilis_error_t *err)
{
	size_t i;
	subtilis_exp_t *e;
	const char *tbuf;
	subtilis_exp_t *rgb[3];
	subtilis_exp_t *tint = NULL;

	memset(rgb, 0, sizeof(rgb));

	subtilis_lexer_get(p->l, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	e = subtilis_parser_int_var_expression(p, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	tbuf = subtilis_token_get_text(t);
	if ((t->type != SUBTILIS_TOKEN_OPERATOR) || strcmp(tbuf, ",")) {
		if ((t->type == SUBTILIS_TOKEN_KEYWORD) &&
		    (t->tok.keyword.type == SUBTILIS_KEYWORD_TINT)) {
			if (!(p->backend.caps & SUBTILIS_BACKEND_HAVE_TINT)) {
				subtilis_error_set_not_supported(
				    err, "TINT on this target",
				    p->l->stream->name, p->l->line);
				goto cleanup;
			}
			subtilis_lexer_get(p->l, t, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;

			tint = subtilis_parser_int_var_expression(p, t, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;

			subtilis_ir_section_add_instr_no_reg2(
			    p->current, SUBTILIS_OP_INSTR_TCOL_TINT,
			    e->exp.ir_op, tint->exp.ir_op, err);
		} else {
			subtilis_ir_section_add_instr_no_reg(
			    p->current, SUBTILIS_OP_INSTR_TCOL, e->exp.ir_op,
			    err);
		}
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	} else {
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_parser_statement_int_args(p, t, rgb, 3, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_ir_section_add_instr4(
		    p->current, SUBTILIS_OP_INSTR_PALETTE, e->exp.ir_op,
		    rgb[0]->exp.ir_op, rgb[1]->exp.ir_op, rgb[2]->exp.ir_op,
		    err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

	if (!p->settings.ignore_graphics_errors)
		subtilis_exp_handle_errors(p, err);

cleanup:

	for (i = 0; i < 3; i++)
		subtilis_exp_delete(rgb[i]);

	subtilis_exp_delete(tint);
	subtilis_exp_delete(e);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x12110
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f3de
jmp 0x2f641
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x24a80
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f401
jmp 0x2f641
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x2f430
movq -0x30(%rbp), %rdi
leaq 0x7b187(%rip), %rsi     # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
je 0x2f54e
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x2f51a
movq -0x10(%rbp), %rax
cmpl $0x85, 0x8(%rax)
jne 0x2f51a
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x2f4a7
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x13, %esi
leaq 0x7b575(%rip), %rdx     # 0xaa9f8
leaq 0x7bdec(%rip), %rcx     # 0xab276
leaq 0x7b57b(%rip), %rax     # 0xaaa0c
movq %rax, (%rsp)
movl $0x279, 0x8(%rsp)       # imm = 0x279
callq 0x156d0
jmp 0x2f604
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f4c9
jmp 0x2f604
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x24a80
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f4ec
jmp 0x2f604
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %r8
movq 0x148(%rcx), %rdx
movq 0x148(%rax), %rcx
movl $0x82, %esi
callq 0x385a0
jmp 0x2f53b
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x148(%rax), %rdx
movl $0x81, %esi
callq 0x38540
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f549
jmp 0x2f604
jmp 0x2f5e8
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f570
jmp 0x2f604
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq -0x18(%rbp), %r8
movl $0x3, %ecx
callq 0x24b30
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f595
jmp 0x2f604
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x148(%rdx), %rdx
movq 0x148(%rcx), %rcx
movq 0x148(%r8), %r8
movq 0x148(%rsi), %r9
movl $0x83, %esi
movq %rax, (%rsp)
callq 0x386c0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2f5e6
jmp 0x2f604
jmp 0x2f5e8
movq -0x8(%rbp), %rax
testb $0x1, 0xb9(%rax)
jne 0x2f602
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x36ce0
jmp 0x2f604
movq $0x0, -0x20(%rbp)
cmpq $0x3, -0x20(%rbp)
jae 0x2f62f
movq -0x20(%rbp), %rax
movq -0x50(%rbp,%rax,8), %rdi
callq 0x36ee0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2f60c
movq -0x58(%rbp), %rdi
callq 0x36ee0
movq -0x28(%rbp), %rdi
callq 0x36ee0
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)