// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/parse.c
// Function: statement
static struct token *statement(struct token *token, struct statement **tree)
{
	struct statement *stmt = alloc_statement(token->pos, STMT_NONE);

	*tree = stmt;
	if (token_type(token) == TOKEN_IDENT) {
		struct symbol *s = lookup_keyword(token->ident, NS_KEYWORD);
		if (s && s->op->statement)
			return s->op->statement(token, stmt);

		if (match_op(token->next, ':')) {
			struct symbol *s = label_symbol(token, 0);
			token = handle_label_attributes(token->next->next, s);
			if (s->stmt) {
				sparse_error(stmt->pos, "label '%s' redefined", show_ident(s->ident));
				// skip the label to avoid multiple definitions
				return statement(token, tree);
			}
			stmt->type = STMT_LABEL;
			stmt->label_identifier = s;
			stmt->label_scope = label_scope;
			if (s->label_scope) {
				if (!is_in_scope(label_scope, s->label_scope))
					warn_label_usage(stmt->pos, s->label_pos, s->ident);
			}
			s->stmt = stmt;
			if (match_op(token, '}')) {
				warning(token->pos, "statement expected after label");
				stmt->label_statement = alloc_statement(token->pos, STMT_NONE);
				return token;
			}
			return statement(token, &stmt->label_statement);
		}
	}

	if (match_op(token, '{')) {
		token = compound_statement(token->next, stmt);
		return expect(token, '}', "at end of compound statement");
	}
			
	stmt->type = STMT_EXPRESSION;
	return expression_statement(token, &stmt->expression);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %r12
xorl %edi, %edi
callq 0x2fa58
movq %rax, %rbx
movl $0x0, (%rax)
movq %r12, 0x4(%rax)
movq %rax, (%r15)
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x3, %eax
jne 0x1ccd4
movq 0x10(%r14), %rdi
testb $0x4, 0x11(%rdi)
je 0x1cc2f
movl $0x100, %esi            # imm = 0x100
callq 0x2afd5
testq %rax, %rax
je 0x1cc2f
movq 0x40(%rax), %rax
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x1cc2f
movq %r14, %rdi
movq %rbx, %rsi
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmpq *%rax
movq 0x8(%r14), %rax
movl (%rax), %ecx
andl $0x3f, %ecx
cmpl $0x12, %ecx
jne 0x1ccd4
cmpl $0x3a, 0x10(%rax)
jne 0x1ccd4
movq %r14, %rdi
xorl %esi, %esi
callq 0x195dd
movq %rax, %r12
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
xorps %xmm0, %xmm0
movq %rsp, %r13
movaps %xmm0, 0x40(%r13)
movaps %xmm0, 0x30(%r13)
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
movq $0x0, 0x50(%r13)
movq %r13, %rsi
callq 0x1aed1
movq %rax, %r14
movq 0x8(%r13), %rax
movq %rax, 0x58(%r12)
cmpq $0x0, 0x90(%r12)
je 0x1cd53
movq 0x18(%r12), %rdi
callq 0x2de35
movq 0x4(%rbx), %rdi
leaq 0x26b3a(%rip), %rsi     # 0x437f9
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a80
movq %r14, %rdi
movq %r15, %rsi
jmp 0x1cddf
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1cd1d
cmpl $0x7b, 0x10(%r14)
jne 0x1cd1d
movq 0x8(%r14), %r14
movl $0x3, (%rbx)
callq 0x22d1f
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a248
movq %rax, %rbx
callq 0x22e36
leaq 0x26b1a(%rip), %rdx     # 0x4382d
movq %rbx, %rdi
movl $0x7d, %esi
jmp 0x1cd41
movl $0x2, (%rbx)
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x38dbd
leaq 0x26b11(%rip), %rdx     # 0x4384a
movq %rax, %rdi
movl $0x3b, %esi
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1950f
movl $0x9, (%rbx)
movq %r12, 0x10(%rbx)
leaq 0x4d734(%rip), %rax     # 0x6a498
movq (%rax), %rdi
movq %rdi, 0x18(%rbx)
movq 0x48(%r12), %rsi
testq %rsi, %rsi
je 0x1cd91
callq 0x22f4b
testl %eax, %eax
jne 0x1cd91
movq 0x4(%rbx), %rdi
movq 0x18(%r12), %rdx
movq 0x50(%r12), %rsi
callq 0x1a1bc
movq %rbx, 0x90(%r12)
movq (%r14), %rdi
movl %edi, %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1cdd5
cmpl $0x7d, 0x10(%r14)
jne 0x1cdd5
leaq 0x26a5a(%rip), %rsi     # 0x4380e
xorl %eax, %eax
callq 0x118fc
movq (%r14), %r15
xorl %edi, %edi
callq 0x2fa58
movl $0x0, (%rax)
movq %r15, 0x4(%rax)
movq %rax, 0x20(%rbx)
jmp 0x1cde7
addq $0x20, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1cbb8
movq %rax, %r14
movq %r14, %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq