// File: /workspace/github_c_makefile_star2_O2/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), %rdi
xorl %esi, %esi
callq 0x17530
movq %rax, %rbx
movq %rax, (%r15)
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x3, %eax
jne 0x1a626
movq 0x10(%r14), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x18e4b
testq %rax, %rax
je 0x1a584
movq 0x40(%rax), %rax
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x1a584
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 0x1a626
cmpl $0x3a, 0x10(%rax)
jne 0x1a626
movq %r14, %rdi
xorl %esi, %esi
callq 0x1754e
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)
andq $0x0, 0x50(%r13)
movq %r13, %rsi
callq 0x18eca
movq %rax, %r14
movq 0x8(%r13), %rax
movq %rax, 0x58(%r12)
cmpq $0x0, 0x90(%r12)
je 0x1a685
movq 0x18(%r12), %rdi
callq 0x2936d
movq 0x4(%rbx), %rdi
leaq 0x22248(%rip), %rsi     # 0x3c859
movq %rax, %rdx
xorl %eax, %eax
callq 0x1120e
movq %r14, %rdi
movq %r15, %rsi
jmp 0x1a707
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1a663
cmpl $0x7b, 0x10(%r14)
jne 0x1a663
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x180ba
leaq 0x22242(%rip), %rdx     # 0x3c88d
pushq $0x7d
popq %rsi
movq %rax, %rdi
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x17480
movl $0x2, (%rbx)
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1a720
movl $0x9, (%rbx)
movq %r12, 0x10(%rbx)
leaq 0x49e02(%rip), %rax     # 0x64498
movq (%rax), %rdi
movq %rdi, 0x18(%rbx)
movq 0x48(%r12), %rsi
testq %rsi, %rsi
je 0x1a6c3
callq 0x201ba
testl %eax, %eax
jne 0x1a6c3
movq 0x4(%rbx), %rdi
movq 0x18(%r12), %rdx
movq 0x50(%r12), %rsi
callq 0x18065
movq %rbx, 0x90(%r12)
movq (%r14), %rdi
movl %edi, %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1a6fd
cmpl $0x7d, 0x10(%r14)
jne 0x1a6fd
leaq 0x22188(%rip), %rsi     # 0x3c86e
xorl %eax, %eax
callq 0x1108a
movq (%r14), %rdi
xorl %esi, %esi
callq 0x17530
movq %rax, 0x20(%rbx)
jmp 0x1a70f
addq $0x20, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a51d
movq %rax, %r14
movq %r14, %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq