// File: /workspace/github_c_makefile_star2_O0/Yamsman[P]scc/src/parse.c
// Function: parse_expr_cast
ast_n *parse_expr_cast(lexer *lx) {
	ast_n *node = parse_expr_unary(lx);
	
	ast_n *n_node;
	token t = lex_peek(lx);
	if (t.type == TOK_LPR) {
		lex_adv(lx);
		
		//Parse type
		token vname = BLANK_TOKEN;
		s_type *base_type = parse_decl_spec(lx);
		s_type *type = parse_decltr(lx, base_type, &vname);
		
		//Ensure the type didn't contain a variable name
		if (vname.type != -1)
			c_error(&vname.loc, "Unexpected identifier in cast expression\n");

		//Check for ')'
		token t = lex_peek(lx);
		if (t.type != TOK_RPR)
			c_error(&t.loc, "Missing ')' after parameter list\n");
		lex_adv(lx);

		//Parse following the type cast
		ast_n *n_node = astn_new(EXPR, EXPR_CAST, t);
		n_node->dat.expr.type = type;
		n_node->dat.expr.left = parse_expr_cast(lx);

		//Join to results of parse_expr_unary if needed
		//If the operation is a reference or inc/dec, flag an error
		if (node != NULL) {
			ast_expr *n_expr = &node->dat.expr;
			if (n_expr->kind == EXPR_INC_PRE)
				c_error(NULL, "lvalue required for pre-increment\n");
			if (n_expr->kind == EXPR_DEC_PRE)
				c_error(NULL, "lvalue required for pre-decrement\n");
			if (n_expr->kind == EXPR_REF)
				c_error(NULL, "lvalue required for reference operation\n");
			n_expr->left = n_node;
			return node;
		}
		return n_node;
	}
	
	return node; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xd000
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x9790
cmpl $0x7, -0x50(%rbp)
jne 0xcfe2
movq -0x10(%rbp), %rdi
callq 0x97e0
leaq -0x80(%rbp), %rdi
leaq 0xa611(%rip), %rsi      # 0x17468
movl $0x30, %edx
callq 0x3160
movq -0x10(%rbp), %rdi
callq 0xa6d0
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0xb660
movq %rax, -0x90(%rbp)
cmpl $-0x1, -0x80(%rbp)
je 0xcea8
leaq -0x80(%rbp), %rdi
addq $0x8, %rdi
leaq 0x612f(%rip), %rsi      # 0x12fd0
movb $0x0, %al
callq 0x3880
movq -0x10(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x9790
cmpl $0x8, -0xc0(%rbp)
je 0xceda
leaq -0xc0(%rbp), %rdi
addq $0x8, %rdi
leaq 0x6127(%rip), %rsi      # 0x12ffa
movb $0x0, %al
callq 0x3880
movq -0x10(%rbp), %rdi
callq 0x97e0
movups -0xc0(%rbp), %xmm0
movups -0xb0(%rbp), %xmm1
movups -0xa0(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movl $0x1, %edi
movl $0x15, %esi
callq 0x3350
movq %rax, -0xc8(%rbp)
movq -0x90(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0xce10
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpq $0x0, -0x18(%rbp)
je 0xcfd5
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpl $0x1c, (%rax)
jne 0xcf7d
xorl %eax, %eax
movl %eax, %edi
leaq 0x60a6(%rip), %rsi      # 0x1301c
movb $0x0, %al
callq 0x3880
movq -0xd0(%rbp), %rax
cmpl $0x1d, (%rax)
jne 0xcf9b
xorl %eax, %eax
movl %eax, %edi
leaq 0x60ab(%rip), %rsi      # 0x1303f
movb $0x0, %al
callq 0x3880
movq -0xd0(%rbp), %rax
cmpl $0x16, (%rax)
jne 0xcfb9
xorl %eax, %eax
movl %eax, %edi
leaq 0x60b0(%rip), %rsi      # 0x13062
movb $0x0, %al
callq 0x3880
movq -0xc8(%rbp), %rcx
movq -0xd0(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xcfea
movq -0xc8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xcfea
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw (%rax,%rax)