// File: /workspace/github_c_makefile_star2_O2/ryvnf[P]czc/parse.c
// Function: parse_type
static struct ast *parse_type(struct parse *parse)
{
    struct loc *line = get_linenr(parse);
    switch (peek_tok(parse)->type) {
        case '^': {
            parse->pos++;

	    struct ast *type = parse_type(parse);
            if (type == NULL)
                return type;

            return ast_new_ast(line, PTR_EXPR, 1, type);
        }
        case '[': {
            struct ast *expr = parse_enclosed(parse, '[', parse_expr, ']', false);
            if (expr == NULL)
                return NULL;

            struct ast *type = parse_type(parse);
            if (type == NULL) {
                ast_unref(expr);
                return type;
            }

            return ast_new_ast(line, ARRAY_EXPR, 2, type, expr);
        }
        case '(': {
            struct ast *param_list = parse_enclosed(parse, '(',
                    parse_param_list, ')', false);

            struct ast *type = parse_type(parse);
            if (type == NULL) {
                ast_unref(param_list);
                return NULL;
            }

            return ast_new_ast(line, FUNC_EXPR, 2, param_list, type);
        }
        case IDENT_TOK: {
            char *s = parse->tokens[parse->pos++].val.u.s;
            return ast_new_s(line, NAME, s);
        }
        case '{': {
            struct ast *field_list = parse_enclosed(parse, '{',
                    parse_decl_list, '}', false);
            return field_list;
        }
    }

    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movq (%rdi), %rcx
movslq 0x14(%rdi), %rax
movq %rax, %rdx
shlq $0x5, %rdx
movq 0x8(%rcx,%rdx), %rbx
movl (%rcx,%rdx), %esi
cmpl $0x28, %esi
je 0x8dc6
cmpl $0x5b, %esi
je 0x8d44
cmpl $0x120, %esi            # imm = 0x120
je 0x8da9
cmpl $0x7b, %esi
je 0x8d8c
cmpl $0x5e, %esi
jne 0x8e13
incl %eax
movl %eax, 0x14(%r14)
movq %r14, %rdi
callq 0x8cc9
testq %rax, %rax
je 0x8e13
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl $0x4300, %esi           # imm = 0x4300
movq %rax, %rcx
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x2458
leaq 0x1a9(%rip), %rdx       # 0x8ef4
pushq $0x5b
popq %rsi
pushq $0x5d
popq %rcx
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x8e8b
testq %rax, %rax
je 0x8e13
movq %rax, %r15
movq %r14, %rdi
callq 0x8cc9
testq %rax, %rax
je 0x8e0b
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl $0x4301, %esi           # imm = 0x4301
movq %rax, %rcx
movq %r15, %r8
jmp 0x8dff
leaq 0x2bf(%rip), %rdx       # 0x9052
pushq $0x7b
popq %rsi
pushq $0x7d
popq %rcx
movq %r14, %rdi
xorl %r8d, %r8d
popq %rbx
popq %r14
popq %r15
jmp 0x8e8b
incl %eax
movl %eax, 0x14(%r14)
movq 0x10(%rcx,%rdx), %rdx
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
popq %rbx
popq %r14
popq %r15
jmp 0x238b
leaq 0x12e(%rip), %rdx       # 0x8efb
pushq $0x28
popq %rsi
pushq $0x29
popq %rcx
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x8e8b
movq %rax, %r15
movq %r14, %rdi
callq 0x8cc9
testq %rax, %rax
je 0x8e0b
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl $0x4302, %esi           # imm = 0x4302
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x2458
movq %r15, %rdi
callq 0x25d9
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq