// File: /workspace/github_c_makefile_star2_O0/ryvnf[P]czc/sym.c
// Function: sym_res
struct sym *sym_res(struct sym *sym)
{
    if (sym == NULL)
        return NULL;

    if (sym->tag != UNRES_SYM)
        return sym;

    switch (sym->loc->tag) {
        case DECL: {
            sym->tag = DECL_SYM;
            struct decl_sym *decl_sym = (struct decl_sym *)sym;
            decl_sym->type = NULL;
            decl_sym->type = type_from_ast(ast_ast(sym->loc, 1));
            decl_sym->c_name = strdup(ast_s(ast_ast(sym->loc, 0)));

            add_global_decl(decl_sym);
            return sym;
        }
        case TYPE_DEF: {
            sym->tag = TYPE_SYM;
            struct type_sym *type_sym = (struct type_sym *)sym;
            type_sym->type = new_selfref_type(type_sym);

            struct ast *ast = ast_ast(sym->loc, 1);

            if (ast == NULL) {
                type_sym->type = new_extern_type();
            } else {
                type_sym->type = type_from_ast(ast);
                if (!resolve_selfref(&type_sym->type, false))
                    fatal(sym->loc->loc, "type cannot reference itself in "
                            "this context");
                add_type_decl(type_sym->type);
            }

            return sym;
        }
        case ALIAS_DEF: {
            sym->tag = ALIAS_SYM;
            struct alias_sym *alias_sym = (struct alias_sym *)sym;
            alias_sym->ast = ast_ast(sym->loc, 1);
            return sym;
        }
        default:
            unreachable();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xfa60
movq $0x0, -0x8(%rbp)
jmp 0xfc3b
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0xfa76
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xfc3b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
subl $0x4000, %eax           # imm = 0x4000
je 0xfaaf
jmp 0xfa8c
movl -0x34(%rbp), %eax
subl $0x4002, %eax           # imm = 0x4002
je 0xfb34
jmp 0xfa9c
movl -0x34(%rbp), %eax
subl $0x4003, %eax           # imm = 0x4003
je 0xfbe1
jmp 0xfc1a
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2a40
movq %rax, %rdi
callq 0x10600
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2a40
movq %rax, %rdi
callq 0x27f0
movq %rax, %rdi
callq 0x2210
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rdi
callq 0x52a0
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xfc3b
movq -0x10(%rbp), %rax
movl $0x3, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x10180
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2a40
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xfb89
callq 0x103d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xfbd7
movq -0x28(%rbp), %rdi
callq 0x10600
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x111f0
testb $0x1, %al
jne 0xfbca
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x4ad4(%rip), %rsi      # 0x14697
movb $0x0, %al
callq 0x6610
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x53b0
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xfc3b
movq -0x10(%rbp), %rax
movl $0x2, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x2a40
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xfc3b
leaq 0x356f(%rip), %rdi      # 0x13190
leaq 0x4a9c(%rip), %rsi      # 0x146c4
movl $0x45, %edx
leaq 0x4a96(%rip), %rcx      # 0x146ca
movb $0x0, %al
callq 0x6510
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)