// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/parse_expression.c
// Function: parse_unary_expression
static struct UntypedExpr
parse_unary_expression(const struct Token **ptr_tokvec)
{
	const struct Token *tokvec = *ptr_tokvec;

	if (tokvec[0].kind == OP_NOT || tokvec[0].kind == OP_TILDA ||
	    tokvec[0].kind == OP_PLUS || tokvec[0].kind == OP_MINUS ||
	    tokvec[0].kind == OP_ASTERISK || tokvec[0].kind == OP_AND) {
		enum TokenKind kind = tokvec[0].kind;
		++tokvec;

		const struct UntypedExpr expr = parse_cast_expression(&tokvec);

		const struct UntypedExpr new_expr = unary_op_untyped(&expr, kind);

		*ptr_tokvec = tokvec;
		return new_expr;
	} else if (tokvec[0].kind == RES_SIZEOF && tokvec[1].kind == LEFT_PAREN &&
	           can_start_a_type(tokvec + 2)) {
		tokvec += 2;
		struct Type type = parse_type_name(&tokvec);
		expect_and_consume(&tokvec, RIGHT_PAREN,
		                   "closing parenthesis of sizeof(typename)");

		struct UntypedExpr expr;
		expr.category = SIZEOF_TYPE;
		expr.operand_of_sizeof_or_alignof = type;
		*ptr_tokvec = tokvec;
		return expr;
	} else if (tokvec[0].kind == OP_PLUS_PLUS ||
	           tokvec[0].kind == OP_MINUS_MINUS ||
	           tokvec[0].kind == RES_SIZEOF) {
		enum TokenKind opkind = tokvec[0].kind;
		++tokvec;

		const struct UntypedExpr expr = parse_unary_expression(&tokvec);

		const struct UntypedExpr new_expr = unary_op_untyped(&expr, opkind);
		*ptr_tokvec = tokvec;
		return new_expr;
	} else if (tokvec[0].kind == RES_ALIGNOF && tokvec[1].kind == LEFT_PAREN) {
		tokvec += 2;
		if (!can_start_a_type(tokvec)) {
			fprintf(stderr, "_Alignof can only take type name\n");
			exit(EXIT_FAILURE);
		}
		struct Type type = parse_type_name(&tokvec);
		expect_and_consume(&tokvec, RIGHT_PAREN,
		                   "closing parenthesis of _Alignof(typename)");

		struct UntypedExpr expr;
		expr.category = ALIGNOF_TYPE;
		expr.operand_of_sizeof_or_alignof = type;
		*ptr_tokvec = tokvec;
		return expr;
	} else {

		struct UntypedExpr expr = parse_postfix_expression(&tokvec);
		*ptr_tokvec = tokvec;
		return expr;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %r14
movq %rsi, -0x38(%rbp)
movq (%rsi), %r15
movq %r15, -0x40(%rbp)
movl (%r15), %ebx
cmpq $0x3b, %rbx
ja 0x845e
movl $0x620023, %eax         # imm = 0x620023
btq %rbx, %rax
jae 0x83e6
addq $0x20, %r15
leaq -0x40(%rbp), %r12
movq %r15, (%r12)
leaq -0xf8(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x8338
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r13
movl $0xa0, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1100
movl $0x1, 0x4(%r14)
movl %ebx, (%r14)
movq %r13, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movq (%r12), %rax
movq -0x38(%rbp), %rcx
movq %rax, (%rcx)
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x3b, %rbx
jne 0x845e
movl $0x3b, %ebx
cmpl $0x6, 0x20(%r15)
jne 0x8372
leaq 0x40(%r15), %r12
movq %r12, %rdi
callq 0x9dc2
testl %eax, %eax
je 0x845b
leaq -0x40(%rbp), %r15
movq %r12, (%r15)
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x9eca
leaq 0x7c24(%rip), %rdx      # 0x10050
movq %r15, %rdi
movl $0x7, %esi
callq 0x9563
movl $0x9, 0x4(%r14)
addq $0x48, %r14
movl $0xa, %ecx
movq %r14, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq (%r15), %rax
jmp 0x83cd
movl (%r15), %ebx
leal -0x32(%rbx), %eax
cmpl $0x2, %eax
jb 0x8372
cmpl $0x42, %ebx
je 0x84de
cmpl $0x3b, %ebx
je 0x8372
cmpl $0x18, %ebx
jne 0x854a
cmpl $0x6, 0x20(%r15)
jne 0x857f
movq 0x8(%r15), %r12
addq $0x40, %r15
leaq -0x30(%rbp), %rdi
movq %r15, (%rdi)
callq 0x8bbc
movq %rax, %r15
movq %rdx, %r13
leaq 0x7c17(%rip), %rdi      # 0x100c4
movl $0x9, %edx
movq %r12, %rsi
callq 0x1030
testl %eax, %eax
movl $0xc, %eax
movl $0x6, %ecx
cmovel %eax, %ecx
movl %ecx, 0x4(%r14)
movq %r15, 0x38(%r14)
movq %r13, 0x40(%r14)
movq %r12, 0x28(%r14)
jmp 0x8608
cmpl $0x6, 0x20(%r15)
jne 0x88b6
addq $0x40, %r15
movq %r15, -0x40(%rbp)
movq %r15, %rdi
callq 0x9dc2
testl %eax, %eax
je 0x88c5
leaq -0xf8(%rbp), %r15
leaq -0x40(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x9eca
leaq 0x7b7c(%rip), %rdx      # 0x1009a
movq %r12, %rdi
movl $0x7, %esi
callq 0x9563
movl $0xa, 0x4(%r14)
addq $0x48, %r14
movl $0xa, %ecx
movq %r14, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
jmp 0x83c9
cmpl $0x39, %ebx
je 0x85d7
cmpl $0x6, %ebx
je 0x859e
cmpl $0x4, %ebx
jne 0x88b6
leaq 0x20(%r15), %rax
movq %rax, -0x30(%rbp)
movl 0x4(%r15), %eax
movl %eax, -0xd8(%rbp)
movl $0x4, -0xf4(%rbp)
jmp 0x85f4
leaq 0x20(%r15), %rax
movq %rax, -0x30(%rbp)
movl $0x3, -0xf4(%rbp)
movq 0x8(%r15), %rax
movq %rax, -0xd0(%rbp)
jmp 0x85f4
addq $0x20, %r15
leaq -0x58(%rbp), %r12
movq %r15, (%r12)
leaq -0xf8(%rbp), %rdi
movq %r12, %rsi
callq 0x8ae5
leaq 0x7b86(%rip), %rdx      # 0x10146
movq %r12, %rdi
movl $0x7, %esi
callq 0x9563
movq (%r12), %rax
movq %rax, -0x30(%rbp)
jmp 0x85f4
movl $0x8, -0xf4(%rbp)
movq 0x10(%r15), %rax
movq %rax, -0xc8(%rbp)
addq $0x20, %r15
movq %r15, -0x30(%rbp)
leaq -0xf8(%rbp), %rsi
movl $0xa0, %edx
movq %r14, %rdi
callq 0x1100
leaq 0x10(%r14), %rax
movq %rax, -0x48(%rbp)
leaq 0x7a09(%rip), %r15      # 0x10020
movq -0x30(%rbp), %rax
movl (%rax), %r12d
leal -0x32(%r12), %ecx
cmpl $0xb, %ecx
ja 0x866f
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
jmpq *%rcx
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %rbx
movl $0xa0, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1100
movl %r12d, (%r14)
movl $0x5, 0x4(%r14)
movq %rbx, 0x8(%r14)
jmp 0x88a7
cmpl $0x6, %r12d
jne 0x83cd
addq $0x20, %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x8bbc
movq %rax, %r13
movq %rdx, %r12
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %rbx
movl $0xa0, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1100
movl $0x7, 0x4(%r14)
movq %rbx, 0x8(%r14)
movq %r13, 0x38(%r14)
movq %r12, 0x40(%r14)
jmp 0x8617
addq $0x20, %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
movl $0x18, %esi
leaq 0x79fb(%rip), %rdx      # 0x100de
callq 0x9563
movq -0x30(%rbp), %rax
movq -0x18(%rax), %r12
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %rbx
movl $0xa0, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1100
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movl $0xb, 0x4(%rax)
movq %rbx, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %r12, 0x98(%rax)
movabsq $0x100000005, %rcx      # imm = 0x100000005
movq %rcx, (%r14)
jmp 0x87f0
addq $0x20, %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
movl $0x18, %esi
leaq 0x799a(%rip), %rdx      # 0x100fe
callq 0x9563
movq -0x30(%rbp), %rax
movq -0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %rbx
movl $0xa0, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1100
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r12
movabsq $0x100000005, %r13      # imm = 0x100000005
movq %r13, (%rax)
movq %rbx, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movl $0xb, 0x4(%rax)
movq %r12, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x98(%rax)
movq %r13, (%r14)
movq %rax, 0x8(%r14)
movq -0x48(%rbp), %rax
movups %xmm0, (%rax)
jmp 0x8617
addq $0x20, %rax
movq %rax, -0x30(%rbp)
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
leaq -0x30(%rbp), %rbx
movq %rbx, %rsi
callq 0x8ae5
movq %rbx, %rdi
movl $0x37, %esi
leaq 0x78a1(%rip), %rdx      # 0x100ce
callq 0x9563
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %r13
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
movq %rax, %rbx
movl $0xa0, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0x1100
movl $0xa0, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1100
movl $0x1, %edi
movl $0xa0, %esi
callq 0x10d0
xorl %ecx, %ecx
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movabsq $0x100000005, %rcx      # imm = 0x100000005
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
movq -0x48(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
jmp 0x8617
leaq 0x7895(%rip), %rsi      # 0x10152
movq %r15, %rdi
callq 0x9478
callq 0x1ce5