// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %r12
xorl %edi, %edi
callq 0x3008c
movq %rax, %rbx
movl $0x0, (%rax)
movq %r12, 0x4(%rax)
movq %rax, (%r15)
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x3, %eax
jne 0x1cbe5
movq 0x10(%r14), %rdi
testb $0x4, 0x11(%rdi)
jne 0x1cb09
xorl %eax, %eax
jmp 0x1cb13
movl $0x100, %esi            # imm = 0x100
callq 0x2b511
testq %rax, %rax
je 0x1cb34
movq 0x40(%rax), %rax
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x1cb34
movq %r14, %rdi
movq %rbx, %rsi
callq *%rax
xorl %ebp, %ebp
jmp 0x1cbe0
movq 0x8(%r14), %rax
movl (%rax), %ecx
andl $0x3f, %ecx
movb $0x1, %bpl
cmpl $0x12, %ecx
jne 0x1cbe0
cmpl $0x3a, 0x10(%rax)
jne 0x1cbe0
movq %r14, %rdi
xorl %esi, %esi
callq 0x196a5
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 0x1afe1
movq %rax, %r14
movq 0x8(%r13), %rax
movq %rax, 0x58(%r12)
cmpq $0x0, 0x90(%r12)
je 0x1cc66
movq 0x18(%r12), %rdi
callq 0x2e465
movq 0x4(%rbx), %rdi
leaq 0x27c72(%rip), %rsi     # 0x44839
xorl %ebp, %ebp
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a38
movq %r14, %rdi
movq %r15, %rsi
callq 0x1cabe
jmp 0x1cbe0
testb %bpl, %bpl
je 0x1cc57
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1cc2e
cmpl $0x7b, 0x10(%r14)
jne 0x1cc2e
movq 0x8(%r14), %r14
movl $0x3, (%rbx)
callq 0x22dc3
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a2fd
movq %rax, %rbx
callq 0x22ed4
leaq 0x27c49(%rip), %rdx     # 0x4486d
movq %rbx, %rdi
movl $0x7d, %esi
jmp 0x1cc52
movl $0x2, (%rbx)
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3993b
leaq 0x27c40(%rip), %rdx     # 0x4488a
movq %rax, %rdi
movl $0x3b, %esi
callq 0x195d7
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x9, (%rbx)
movq %r12, 0x10(%rbx)
leaq 0x4e821(%rip), %rax     # 0x6b498
movq (%rax), %rdi
movq %rdi, 0x18(%rbx)
movq 0x48(%r12), %rsi
testq %rsi, %rsi
je 0x1cca4
callq 0x22fe4
testl %eax, %eax
jne 0x1cca4
movq 0x4(%rbx), %rdi
movq 0x18(%r12), %rdx
movq 0x50(%r12), %rsi
callq 0x1a271
movq %rbx, 0x90(%r12)
movq (%r14), %rdi
movl %edi, %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1ccf0
cmpl $0x7d, 0x10(%r14)
jne 0x1ccf0
leaq 0x27b87(%rip), %rsi     # 0x4484e
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x118b4
movq (%r14), %r15
xorl %edi, %edi
callq 0x3008c
movl $0x0, (%rax)
movq %r15, 0x4(%rax)
movq %rax, 0x20(%rbx)
movq %r14, %rax
jmp 0x1cbe0
leaq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x1cabe
jmp 0x1cb2d