// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_amigahunk.c
// Function: ext_defs
static void ext_defs(struct GlobalVars *gv,FILE *f,struct LinkedSection *sec,
                     uint8_t bind,uint8_t stype,uint32_t xdeftype)
{
  struct Symbol *nextsym,*sym=(struct Symbol *)sec->symbols.first;
  bool xdefs = FALSE;

  while (nextsym = (struct Symbol *)sym->n.next) {
    if (sym->type==stype && sym->bind==bind && sym->info<=SYMI_FUNC) {
      remnode(&sym->n);

      if (!discard_symbol(gv,sym)) {
        if (xdeftype != EXT_IGNORE) {
          if (!xdefs) {
            xdefs = TRUE;
            if (xdeftype == EXT_SYMB) {
              if (!symhunk) {
                symhunk = TRUE;
                fwrite32be(f,HUNK_SYMBOL);
              }
            }
            else {
              if (!exthunk) {
                exthunk = TRUE;
                fwrite32be(f,HUNK_EXT);
              }
            }
          }
          /* generate xdef or symbol table entry */
          if (xdeftype==EXT_SYMB && strlen(sym->name)>124) {
            /* LoadSeg<=V40 doesn't allow more than 31 longwords per symbol,
               and will respond with "bad loadfile hunk" otherwise -
               so just strip the rest! */
            fwrite32be(f,(xdeftype << 24) | 31);
            fwritex(f,sym->name,124);
          }
          else {
            fwrite32be(f,(xdeftype << 24) | strlen32(sym->name));
            hunk_name(f,sym->name);           /* write symbol's name */
          }
          fwrite32be(f,(uint32_t)sym->value);  /* ... and its value */
        }

        else { /* EXT_IGNORE */
          if (stype==SYM_COMMON && !(sym->flags & SYMF_REFERENCED))
            /* Warning: unreferenced common symbol will disappear! */
            error(93,fff_amigahunk.tname,sym->name);
        }
      }
    }
    sym = nextsym;
  }
}

// Assembly:
subq $0x48, %rsp
movb %r8b, %al
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movb %cl, 0x2f(%rsp)
movb %al, 0x2e(%rsp)
movl %r9d, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq 0xb0(%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x1edd3
movq 0x18(%rsp), %rax
movzbl 0x40(%rax), %eax
movzbl 0x2e(%rsp), %ecx
cmpl %ecx, %eax
jne 0x1edc4
movq 0x18(%rsp), %rax
movzbl 0x43(%rax), %eax
movzbl 0x2f(%rsp), %ecx
cmpl %ecx, %eax
jne 0x1edc4
movq 0x18(%rsp), %rax
movzbl 0x42(%rax), %eax
cmpl $0x2, %eax
jg 0x1edc4
movq 0x18(%rsp), %rdi
callq 0x7530
movq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x13660
cmpl $0x0, %eax
jne 0x1edc2
cmpl $0x100, 0x28(%rsp)      # imm = 0x100
je 0x1ed87
cmpl $0x0, 0x14(%rsp)
jne 0x1ece1
movl $0x1, 0x14(%rsp)
cmpl $0x0, 0x28(%rsp)
jne 0x1ecbb
cmpl $0x0, 0x25fea(%rip)     # 0x44c88
jne 0x1ecb9
movl $0x1, 0x25fde(%rip)     # 0x44c88
movq 0x38(%rsp), %rdi
movl $0x3f0, %esi            # imm = 0x3F0
callq 0x84d0
jmp 0x1ecdf
cmpl $0x0, 0x25fca(%rip)     # 0x44c8c
jne 0x1ecdd
movl $0x1, 0x25fbe(%rip)     # 0x44c8c
movq 0x38(%rsp), %rdi
movl $0x3ef, %esi            # imm = 0x3EF
callq 0x84d0
jmp 0x1ecdf
jmp 0x1ece1
cmpl $0x0, 0x28(%rsp)
jne 0x1ed2a
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x50c0
cmpq $0x7c, %rax
jbe 0x1ed2a
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %esi
shll $0x18, %esi
orl $0x1f, %esi
callq 0x84d0
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
movl $0x7c, %edx
callq 0x8470
jmp 0x1ed70
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x28(%rsp), %eax
shll $0x18, %eax
movl %eax, 0x4(%rsp)
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x1f010
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdi
orl %eax, %esi
callq 0x84d0
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x1f050
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rax
movl %eax, %esi
callq 0x84d0
jmp 0x1edc0
movzbl 0x2e(%rsp), %eax
cmpl $0x3, %eax
jne 0x1edbe
movq 0x18(%rsp), %rax
movzbl 0x41(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x1edbe
movq 0x21227(%rip), %rsi     # 0x3ffd0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rdx
movl $0x5d, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x1edc0
jmp 0x1edc2
jmp 0x1edc4
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x1ebfc
addq $0x48, %rsp
retq
nopl (%rax,%rax)