// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_amigahunk.c
// Function: ehf_lnksym
static struct Symbol *ehf_lnksym(struct GlobalVars *gv,struct Section *sec,
                                 struct Reloc *xref)
/* Checks if undefined symbol is an EHF-linker symbol */
{
  if (!gv->dest_object) {

    if (!strncmp(ehf_addrsym,xref->xrefname,sizeof(ehf_addrsym)-1)) {
      const char *symname = xref->xrefname + (sizeof(ehf_addrsym) - 1);

      if (find_any_symbol(gv,sec,symname)) {
        /* Reference to an unknown symbol, which starts with "@_". */
        /* The symbol without "@_" has to exist. */
        char *objname = alloc(strlen(symname)+3);
        uint8_t *dat = alloczero(sizeof(uint32_t)); /* space for a 32-bit ptr */
        struct ObjectUnit *ou;
        struct Section *s;
        struct Symbol *sym;
        struct Reloc *r;

        /* create an artificial object with a ".tocd" data section */
        sprintf(objname,"%s.o",symname);
        ou = art_objunit(gv,objname,dat,sizeof(uint32_t));
        s = add_section(ou,".tocd",dat,sizeof(uint32_t),ST_DATA,
                        SF_ALLOC,SP_READ|SP_WRITE,2,FALSE);

        /* "@__name" contains a 32-bit reloc pointer, which has an */
        /* external reference to the symbol "_name". */
        r = newreloc(gv,s,symname,NULL,0,0,R_ABS,0);
        addreloc(s,r,0,32,-1);

        /* make "@__name" visible for the further linking process: */
        if (addsymbol(gv,s,xref->xrefname,NULL,0,SYM_RELOC,0,SYMI_OBJECT,
                      SYMB_GLOBAL,sizeof(uint32_t),FALSE))
          ierror("ehf_lnksym(): %s was assumed to be undefined, but "
                 "in reality it *is* defined",xref->xrefname);

        if (!(sym = findsymbol(gv,sec,xref->xrefname)))
          ierror("ehf_lnksym(): The just defined symbol %s has "
                 "disappeared",xref->xrefname);
        return (sym);
      }
    }
  }

  return (ados_lnksym(gv,sec,xref));
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x78(%rsp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x1c917
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x23aab(%rip), %rdi     # 0x401d0
movl $0x2, %edx
callq 0x5050
cmpl $0x0, %eax
jne 0x1c915
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x2, %rax
movq %rax, 0x60(%rsp)
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x60(%rsp), %rdx
callq 0x105c0
cmpq $0x0, %rax
je 0x1c913
movq 0x60(%rsp), %rdi
callq 0x50c0
movq %rax, %rdi
addq $0x3, %rdi
callq 0x71f0
movq %rax, 0x58(%rsp)
movl $0x4, %edi
callq 0x7290
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rdx
leaq 0x1989b(%rip), %rsi     # 0x3603e
movb $0x0, %al
callq 0x5230
movq 0x78(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdx
movl $0x4, %ecx
callq 0x12350
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rdx
leaq 0x1986a(%rip), %rsi     # 0x36043
movl $0x4, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
xorl %eax, %eax
movl $0x3, (%rsp)
movl $0x2, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x12660
movq %rax, 0x40(%rsp)
movq 0x78(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x60(%rsp), %rdx
xorl %eax, %eax
movl %eax, %r9d
xorl %r8d, %r8d
movq %r9, %rcx
movl $0x1, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x10850
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
movl $0x20, %ecx
movq $-0x1, %r8
callq 0x109b0
movq 0x78(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rdx
xorl %eax, %eax
movl %eax, %r8d
movl $0x2, %r9d
xorl %eax, %eax
movq %r8, %rcx
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
movl $0x2, 0x10(%rsp)
movl $0x4, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
callq 0xfd00
cmpq $0x0, %rax
je 0x1c8ca
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x19786(%rip), %rdi     # 0x36049
movb $0x0, %al
callq 0x8ae0
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rdx
callq 0xf580
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
jne 0x1c904
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x19799(%rip), %rdi     # 0x36096
movb $0x0, %al
callq 0x8ae0
movq 0x38(%rsp), %rax
movq %rax, 0x80(%rsp)
jmp 0x1c933
jmp 0x1c915
jmp 0x1c917
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x68(%rsp), %rdx
callq 0x1bcb0
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)