// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/expression.c
// Function: primary_expression
struct token *primary_expression(struct token *token, struct expression **tree)
{
	struct expression *expr = NULL;

	switch (token_type(token)) {
	case TOKEN_CHAR ... TOKEN_WIDE_CHAR_EMBEDDED_3:
		expr = alloc_expression(token->pos, EXPR_VALUE);
		expr->flags = CEF_SET_CHAR;
		get_char_constant(token, &expr->value);

		// TODO: handle 'u8', 'u' & 'U' prefixes.
		if (token_type(token) < TOKEN_WIDE_CHAR) {
			expr->ctype = &char_ctype;
			cast_value(expr, &int_ctype, expr);
		} else {
			expr->ctype = wchar_ctype;
		}
		token = token->next;
		break;

	case TOKEN_NUMBER:
		expr = alloc_expression(token->pos, EXPR_VALUE);
		get_number_value(expr, token); /* will see if it's an integer */
		token = token->next;
		break;

	case TOKEN_ZERO_IDENT: {
		expr = alloc_expression(token->pos, EXPR_SYMBOL);
		expr->flags = CEF_SET_INT;
		expr->ctype = &int_ctype;
		expr->symbol = &zero_int;
		expr->symbol_name = token->ident;
		token = token->next;
		break;
	}

	case TOKEN_IDENT: {
		struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL | NS_TYPEDEF);
		struct token *next = token->next;

		if (!sym) {
			sym = handle_func(token);
			if (token->ident == &__builtin_types_compatible_p_ident) {
				token = builtin_types_compatible_p_expr(token, &expr);
				break;
			}
			if (token->ident == &__builtin_offsetof_ident) {
				token = builtin_offsetof_expr(token, &expr);
				break;
			}
			if (token->ident == &_Generic_ident) {
				token = generic_selection(token->next, &expr);
				break;
			}
		} else if (sym->enum_member) {
			expr = alloc_expression(token->pos, EXPR_VALUE);
			*expr = *sym->initializer;
			/* we want the right position reported, thus the copy */
			expr->pos = token->pos;
			expr->flags = CEF_SET_ENUM;
			token = next;
			break;
		}

		expr = alloc_expression(token->pos, EXPR_SYMBOL);

		/*
		 * We support types as real first-class citizens, with type
		 * comparisons etc:
		 *
		 *	if (typeof(a) == int) ..
		 */
		if (sym && sym->namespace == NS_TYPEDEF) {
			sparse_error(token->pos, "typename in expression");
			sym = NULL;
		}
		expr->symbol_name = token->ident;
		expr->symbol = sym;

		/*
		 * A pointer to an lvalue designating a static storage
		 * duration object is an address constant [6.6(9)].
		 */
		if (sym && (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_STATIC)))
			expr->flags = CEF_ADDR;

		token = next;
		break;
	}

	case TOKEN_STRING:
	case TOKEN_WIDE_STRING:
		expr = alloc_expression(token->pos, EXPR_STRING);
		token = get_string_constant(token, expr);
		break;

	case TOKEN_SPECIAL:
		if (token->special == '(') {
			expr = alloc_expression(token->pos, EXPR_PREOP);
			expr->op = '(';
			token = parens_expression(token, &expr->unop, "in expression");
			break;
		}
		if (token->special == '[' && lookup_type(token->next)) {
			expr = alloc_expression(token->pos, EXPR_TYPE);
			token = typename(token->next, &expr->symbol, NULL);
			token = expect(token, ']', "in type expression");
			break;
		}
			
	default:
		;
	}
	*tree = expr;
	return token;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq $0x0, 0x8(%rsp)
movq (%rdi), %r12
movl %r12d, %eax
andl $0x3f, %eax
addl $-0x3, %eax
cmpl $0xf, %eax
ja 0x3927d
leaq 0x11c94(%rip), %rcx     # 0x4aae0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r15
movzwl 0x2(%rax), %eax
shll $0x10, %eax
movq %r12, 0x8(%r15)
movq %r15, 0x8(%rsp)
orl $0x3801, %eax           # imm = 0x3801
movl %eax, (%r15)
leaq 0x20(%r15), %rsi
movq %r14, %rdi
callq 0x3ef84
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0xa, %eax
ja 0x38ead
leaq 0x31b83(%rip), %rax     # 0x6aa18
movq %rax, 0x10(%r15)
leaq 0x32898(%rip), %rsi     # 0x6b738
movq %r15, %rdi
movq %r15, %rdx
callq 0xea9c
jmp 0x38ebb
leaq 0x2b7ac(%rip), %rax     # 0x64660
movq (%rax), %rax
movq %rax, 0x10(%r15)
movq 0x8(%r14), %r15
movq 0x8(%rsp), %rax
movq %rax, (%rbx)
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x2f9f5
movq %r12, 0x8(%rax)
movw $0x2, (%rax)
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x3f24e
movq %rax, %r15
jmp 0x38ebf
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r15
movq %r12, 0x8(%rax)
movw $0x1, (%rax)
movq %rax, 0x8(%rsp)
movq 0x10(%r14), %r13
callq 0xe070
movq %rax, %rbp
movl $0x0, (%rax)
cmpb $0x30, (%r13)
jne 0x3905f
callq 0xe2f0
movq (%rax), %rax
movzbl 0x1(%r13), %ecx
cmpl $0x62, (%rax,%rcx,4)
jne 0x3905f
leaq 0x2(%r13), %rdi
leaq 0x10(%rsp), %rsi
movl $0x2, %edx
jmp 0x39069
movq 0x10(%r14), %rdi
movl $0x12, %esi
callq 0x2afd5
movq 0x8(%r14), %r15
testq %rax, %rax
je 0x390a5
movq %rax, %r12
testb $0x10, 0x2(%rax)
je 0x392af
movq (%r14), %r13
xorl %edi, %edi
callq 0x2f9f5
movq %r13, 0x8(%rax)
movw $0x1, (%rax)
movq %rax, 0x8(%rsp)
movq 0xb0(%r12), %rcx
movaps (%rcx), %xmm0
movaps 0x10(%rcx), %xmm1
movaps 0x20(%rcx), %xmm2
movaps 0x30(%rcx), %xmm3
movaps %xmm0, (%rax)
movaps %xmm1, 0x10(%rax)
movaps %xmm2, 0x20(%rax)
movaps %xmm3, 0x30(%rax)
movq (%r14), %rcx
movq %rcx, 0x8(%rax)
movb $0x34, 0x1(%rax)
jmp 0x38ebf
xorl %edi, %edi
callq 0x2f9f5
movzwl 0x2(%rax), %ecx
shll $0x10, %ecx
movq %r12, 0x8(%rax)
movq %rax, 0x8(%rsp)
orl $0x3103, %ecx           # imm = 0x3103
movl %ecx, (%rax)
leaq 0x3273f(%rip), %rcx     # 0x6b738
movq %rcx, 0x10(%rax)
leaq 0x34e94(%rip), %rcx     # 0x6de98
movq %rcx, 0x20(%rax)
movq 0x10(%r14), %rcx
movq %rcx, 0x28(%rax)
jmp 0x38ebb
movl 0x10(%r14), %eax
cmpl $0x5b, %eax
je 0x39230
cmpl $0x28, %eax
jne 0x3927d
xorl %edi, %edi
callq 0x2f9f5
movq %r12, 0x8(%rax)
movw $0x9, (%rax)
movq %rax, 0x8(%rsp)
movl $0x28, 0x4(%rax)
leaq 0x20(%rax), %rsi
leaq 0x11b66(%rip), %rdx     # 0x4abb8
movq %r14, %rdi
callq 0x38cf5
jmp 0x38ef9
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0xe1a0
movq %rax, %r12
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x393b8
cmpq $-0x1, %r12
je 0x39310
leaq 0x1(%rdi), %rdx
movq %rdx, 0x10(%rsp)
movb (%rdi), %r8b
movb $0x1, %cl
testb %r8b, %r8b
jne 0x3932e
jmp 0x39475
movq 0x10(%r14), %rbp
cmpq 0x26e80(%rip), %rbp     # 0x5ff30
je 0x390c8
cmpq 0x26e3f(%rip), %rbp     # 0x5fef8
je 0x390c8
cmpq 0x26e1e(%rip), %rbp     # 0x5fee0
jne 0x39285
leaq 0x56ea1(%rip), %rax     # 0x8ff70
movq (%rax), %rax
testq %rax, %rax
je 0x39285
cmpq $0x0, 0x18(%rax)
je 0x39285
movq (%r14), %rdi
movl $0x6, %esi
callq 0x2b00b
movq %rax, %r13
leaq 0x3191b(%rip), %rcx     # 0x6aa18
movq %rcx, 0x60(%rax)
movl $0x1, %ecx
movq %rcx, 0x70(%rax)
movq (%r14), %rcx
movq %rcx, 0xc(%rax)
movq %rax, 0x20(%rsp)
movq (%r14), %rdi
movl $0x3, %esi
callq 0x2b00b
movq %rax, %r12
movq %r13, 0x60(%rax)
movl $0x1, %eax
movq %rax, 0x70(%r12)
movq $0x4, 0x68(%r12)
movq (%r14), %rax
movq %rax, 0xc(%r12)
leaq 0x2ac44(%rip), %rax     # 0x63d90
movq (%rax), %rcx
movq %r12, %rdi
movq %rbp, %rsi
movl $0x10, %edx
callq 0x2bd4a
leaq 0x56e0a(%rip), %rax     # 0x8ff70
movq (%rax), %rax
movq 0x18(%rax), %rax
movzbl 0x10(%rax), %r13d
leaq 0x1(%r13), %rdi
movq %rdi, 0x18(%rsp)
callq 0x2fabb
movq %rax, %rbp
leaq 0x4(%rax), %rdi
leaq 0x56de2(%rip), %rax     # 0x8ff70
movq (%rax), %rax
movq 0x18(%rax), %rsi
addq $0x12, %rsi
movq %r13, %rdx
callq 0xe1e0
movb $0x0, 0x4(%rbp,%r13)
movl $0x80000000, %eax       # imm = 0x80000000
andl (%rbp), %eax
addl 0x18(%rsp), %eax
movl %eax, (%rbp)
movq (%r14), %r13
xorl %edi, %edi
callq 0x2f9f5
movq %r13, 0x8(%rax)
movw $0x2, (%rax)
movq %rax, 0xb0(%r12)
movq %rbp, 0x28(%rax)
movq 0xb0(%r12), %rax
movq %r12, 0x10(%rax)
movq (%r14), %r13
xorl %edi, %edi
callq 0x2f9f5
movq %r13, 0x8(%rax)
movq 0x18(%rsp), %rdx
movq %rdx, 0x20(%rax)
leaq 0x32539(%rip), %rcx     # 0x6b738
movq %rcx, 0x10(%rax)
movw $0x3101, (%rax)         # imm = 0x3101
movq %rax, 0x58(%r12)
movq 0x20(%rsp), %rcx
movq %rax, 0x58(%rcx)
leaq 0x2b4e3(%rip), %rax     # 0x64700
movl (%rax), %eax
imull %edx, %eax
movl %eax, 0x50(%rcx)
movl %eax, 0x50(%r12)
movq 0x10(%r14), %rbp
jmp 0x39288
movq 0x8(%r14), %rdi
callq 0x39b20
testl %eax, %eax
je 0x3927d
movq (%r14), %r15
xorl %edi, %edi
callq 0x2f9f5
movq %r15, 0x8(%rax)
movw $0x4, (%rax)
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rdi
leaq 0x20(%rax), %rsi
xorl %edx, %edx
callq 0x1965e
leaq 0x1195b(%rip), %rdx     # 0x4abc6
movq %rax, %rdi
movl $0x5d, %esi
callq 0x1950f
jmp 0x38ef9
movq %r14, %r15
jmp 0x38ebf
xorl %r12d, %r12d
cmpq 0x26cd9(%rip), %rbp     # 0x5ff68
je 0x3941b
cmpq 0x26c9c(%rip), %rbp     # 0x5ff38
je 0x39574
cmpq 0x26d37(%rip), %rbp     # 0x5ffe0
je 0x395ad
movq (%r14), %rbp
xorl %edi, %edi
callq 0x2f9f5
movq %rax, %r13
movzwl 0x2(%rax), %eax
movq %rbp, 0x8(%r13)
movw $0x3, (%r13)
movq %r13, 0x8(%rsp)
testq %r12, %r12
je 0x392fb
movl $0x1ff00, %ecx          # imm = 0x1FF00
andl (%r12), %ecx
cmpl $0x200, %ecx            # imm = 0x200
jne 0x3942d
movq (%r14), %rdi
leaq 0x118bb(%rip), %rsi     # 0x4abaf
xorl %eax, %eax
callq 0x11a80
movq 0x10(%r14), %rax
movq %rax, 0x28(%r13)
movq $0x0, 0x20(%r13)
jmp 0x38ebf
movl (%rbp), %eax
cmpl $0x22, %eax
setne %cl
leaq 0x1(%rdi), %rdx
movq %rdx, 0x10(%rsp)
movb (%rdi), %r8b
testb %r8b, %r8b
je 0x3946c
xorl %esi, %esi
xorl %eax, %eax
movl %r8d, %r9d
andb $-0x21, %r9b
cmpb $0x4c, %r9b
je 0x39356
movzbl %r9b, %edi
cmpl $0x55, %edi
jne 0x393b8
testl %eax, %eax
movl $0x1, %eax
je 0x39375
jmp 0x393e6
testl %esi, %esi
jne 0x393e6
xorl %esi, %esi
cmpb %r8b, (%rdx)
sete %r8b
jne 0x39370
addq $0x2, %rdi
movq %rdi, %rdx
movb %r8b, %sil
incl %esi
movq %rdx, %rdi
incq %rdx
movq %rdx, 0x10(%rsp)
movb (%rdi), %r8b
testb %r8b, %r8b
jne 0x39332
testb %cl, %cl
je 0x39689
cmpb $0x30, (%r13)
sete %cl
testl %eax, %eax
setne %dl
orb %cl, %dl
testl %esi, %esi
je 0x3947f
xorl %r13d, %r13d
cmpl $0x1, %esi
jle 0x394c0
jmp 0x394e0
leaq 0x10(%rsp), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x30d6a
fstpt 0x20(%r15)
movq (%r12), %rcx
cmpq %rcx, %r13
je 0x393e6
movzbl (%rcx), %eax
testl %eax, %eax
je 0x39456
cmpb $0x0, 0x1(%rcx)
je 0x39586
movq %r14, %rdi
callq 0x2df90
movq 0x8(%r15), %rdi
leaq 0x11936(%rip), %rsi     # 0x4ad2f
movq %rax, %rdx
xorl %eax, %eax
callq 0x11a80
movb $0x1, (%r15)
movq $0x0, 0x20(%r15)
leaq 0x32322(%rip), %rax     # 0x6b738
jmp 0x38eb7
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x396a6
jmp 0x38ef9
movq 0x10(%r14), %rcx
movq %rcx, 0x28(%r13)
movq %r12, 0x20(%r13)
testb $0x14, 0x68(%r12)
je 0x38ebf
shll $0x10, %eax
orl $0x4003, %eax           # imm = 0x4003
movl %eax, (%r13)
jmp 0x38ebf
leaq 0x32e3b(%rip), %rcx     # 0x6c298
movq %rcx, 0x10(%r15)
movw $0x221c, (%r15)         # imm = 0x221C
jmp 0x38ebb
cmpl $0x22, %eax
je 0x39689
cmpb $0x30, (%r13)
sete %dl
xorl %eax, %eax
leaq 0x2b282(%rip), %rcx     # 0x64708
movl (%rcx), %ecx
decl %ecx
movq %r12, %rsi
shrq %cl, %rsi
movl $0x1, %r13d
testq $-0x2, %rsi
jne 0x394c0
btq %rcx, %r12
setae %cl
movl $0x1, %ebp
cmovael %eax, %ebp
orb %dl, %cl
xorl %edx, %edx
movl $0x0, %edi
testb $0x1, %cl
jne 0x39651
leaq 0x2b245(%rip), %rcx     # 0x6470c
movl (%rcx), %ecx
decl %ecx
movq %r12, %rsi
shrq %cl, %rsi
testq $-0x2, %rsi
je 0x3954c
movl $0x1, %r13d
leaq 0x2b229(%rip), %rcx     # 0x64710
movl (%rcx), %ecx
decl %ecx
movq %r12, %rsi
shrq %cl, %rsi
testq $-0x2, %rsi
jne 0x39689
movl $0x2, %edi
leaq 0xd459(%rip), %rsi      # 0x46963
btq %rcx, %r12
jae 0x395c5
movl $0x1, %ebp
testb %dl, %dl
jne 0x395c7
movq %r14, %rdi
callq 0x2df90
movq 0x8(%r15), %rdi
leaq 0x116ce(%rip), %rsi     # 0x4ac02
movq %rax, %rdx
xorl %eax, %eax
callq 0x118fc
leaq 0xd41e(%rip), %rsi      # 0x46963
movl $0x2, %edi
jmp 0x395c7
leaq 0x737a(%rip), %rsi      # 0x408cd
btq %rcx, %r12
jae 0x395c0
movl $0x1, %ebp
movl $0x1, %edi
testb %dl, %dl
jne 0x395c7
movl $0x3, %r13d
xorl %edx, %edx
jmp 0x394e0
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x39770
jmp 0x38ef9
leaq 0x32c2b(%rip), %rcx     # 0x6c1b8
cmpl $0x65, %eax
jg 0x3966b
cmpl $0x46, %eax
je 0x3945d
cmpl $0x4c, %eax
je 0x3967d
jmp 0x393e6
movq 0x8(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3997d
jmp 0x38ef9
movl $0x1, %edi
movl %eax, %ebp
testl %r13d, %r13d
je 0x39628
leaq 0x2d81d(%rip), %rax     # 0x66df0
cmpl $0x0, (%rax)
je 0x39628
movl %r13d, 0x18(%rsp)
movl %edi, 0x20(%rsp)
movq %r14, %rdi
movq %rsi, %r13
callq 0x2df90
testl %ebp, %ebp
leaq 0x72d8(%rip), %rdx      # 0x408cd
leaq 0x11655(%rip), %rcx     # 0x4ac51
cmoveq %rdx, %rcx
movq 0x8(%r15), %rdi
leaq 0x11624(%rip), %rsi     # 0x4ac2f
leaq 0xd351(%rip), %r8       # 0x46963
movq %rax, %rdx
movq %r13, %r9
xorl %eax, %eax
callq 0x118fc
movl 0x20(%rsp), %edi
movl 0x18(%rsp), %r13d
testb $0x2, %r13b
je 0x39651
movl %edi, %r13d
movq %r14, %rdi
callq 0x2df90
movq 0x8(%r15), %rdi
leaq 0x11617(%rip), %rsi     # 0x4ac5b
movq %rax, %rdx
xorl %eax, %eax
callq 0x118fc
movl %r13d, %edi
movw $0x3101, (%r15)         # imm = 0x3101
movl %ebp, %esi
callq 0x19641
movq %rax, 0x10(%r15)
movq %r12, 0x20(%r15)
jmp 0x38ebb
cmpl $0x66, %eax
je 0x3945d
cmpl $0x6c, %eax
jne 0x393e6
leaq 0x32cf4(%rip), %rcx     # 0x6c378
jmp 0x3945d
movq %r14, %rdi
callq 0x2df90
movq 0x8(%r15), %rdi
leaq 0x11660(%rip), %rsi     # 0x4acfc
movq %rax, %rdx
xorl %eax, %eax
callq 0x11b9c