// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x23020
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
andq $0x3f, %rax
cmpl $0x3, %eax
jne 0x26e26
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x244c0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x26cac
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
cmpq $0x0, 0x30(%rax)
je 0x26cac
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
movq %rax, -0x8(%rbp)
jmp 0x26e88
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x3a, %esi
callq 0x22f80
cmpl $0x0, %eax
je 0x26e24
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x23060
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x26ea0
movq %rax, -0x10(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x26d41
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x44150
movq %rax, %rdx
movq -0x38(%rbp), %rax
movq 0x4(%rax), %rdi
leaq 0x3e43e(%rip), %rsi     # 0x65162
movb $0x0, %al
callq 0x16f90
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x26c20
movq %rax, -0x8(%rbp)
jmp 0x26e88
movq -0x20(%rbp), %rax
movl $0x9, (%rax)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0x69b1a(%rip), %rax     # 0x90878
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x26daf
leaq 0x69afd(%rip), %rax     # 0x90878
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rsi
callq 0x32220
cmpl $0x0, %eax
jne 0x26dad
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq -0x30(%rbp), %rdx
movq 0x18(%rdx), %rdx
movq 0x4(%rcx), %rdi
movq 0x50(%rax), %rsi
callq 0x23770
jmp 0x26daf
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x10(%rbp), %rdi
movl $0x7d, %esi
callq 0x22f80
cmpl $0x0, %eax
je 0x26e09
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x3e398(%rip), %rsi     # 0x65177
movb $0x0, %al
callq 0x16d80
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x23020
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x26e88
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x10, %rsi
addq $0x10, %rsi
callq 0x26c20
movq %rax, -0x8(%rbp)
jmp 0x26e88
jmp 0x26e26
movq -0x10(%rbp), %rdi
movl $0x7b, %esi
callq 0x22f80
cmpl $0x0, %eax
je 0x26e69
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x237e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x7d, %esi
leaq 0x3e338(%rip), %rdx     # 0x65196
callq 0x22eb0
movq %rax, -0x8(%rbp)
jmp 0x26e88
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x10, %rsi
callq 0x26ef0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)