// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
movq (%rdx), %rax
testq %rax, %rax
je 0x13b7f
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, %r15
movq %rdi, %r12
movl 0x4(%rsp), %ecx
shll $0x18, %ecx
movl %ecx, 0x14(%rsp)
xorl %ebx, %ebx
movq %r15, %r13
movq %rax, %r15
cmpb %bpl, 0x40(%r13)
jne 0x13b73
cmpb %r14b, 0x43(%r13)
jne 0x13b73
cmpb $0x2, 0x42(%r13)
ja 0x13b73
movq %r13, %rdi
callq 0x6759
movq %r12, %rdi
movq %r13, %rsi
callq 0xcb79
testl %eax, %eax
jne 0x13b73
cmpl $0x100, 0x4(%rsp)       # imm = 0x100
jne 0x13aa8
cmpb $0x3, %bpl
jne 0x13b73
testb $0x2, 0x41(%r13)
jne 0x13b73
movq 0x1bb25(%rip), %rsi     # 0x2f5b8
movq 0x20(%r13), %rdx
movl $0x5d, %edi
xorl %eax, %eax
callq 0x6f14
jmp 0x13b73
testl %ebx, %ebx
je 0x13ab5
cmpl $0x0, 0x4(%rsp)
jne 0x13adb
jmp 0x13b00
cmpl $0x0, 0x4(%rsp)
je 0x13ae1
cmpb $0x0, 0x1fdf9(%rip)     # 0x338bc
jne 0x13adb
movb $0x1, 0x1fdf0(%rip)     # 0x338bc
movq 0x8(%rsp), %rdi
movl $0x3ef, %esi            # imm = 0x3EF
callq 0x6be8
movq 0x20(%r13), %rbx
jmp 0x13b37
cmpb $0x0, 0x1fdd0(%rip)     # 0x338b8
jne 0x13b00
movb $0x1, 0x1fdc7(%rip)     # 0x338b8
movq 0x8(%rsp), %rdi
movl $0x3f0, %esi            # imm = 0x3F0
callq 0x6be8
movq 0x20(%r13), %rbx
movq %rbx, %rdi
callq 0x50e0
cmpq $0x7d, %rax
jb 0x13b37
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x1f, %esi
callq 0x6be8
movq 0x20(%r13), %rsi
movl $0x7c, %edx
movq %rbx, %rdi
callq 0x6ba5
jmp 0x13b62
movq %rbx, %rdi
callq 0x50e0
leal 0x3(%rax), %esi
sarl $0x2, %esi
orl 0x14(%rsp), %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6be8
movq 0x20(%r13), %rsi
movq %rbx, %rdi
callq 0x13d0a
movl 0x30(%r13), %esi
movq %rbx, %rdi
callq 0x6be8
movl $0x1, %ebx
movq (%r15), %rax
testq %rax, %rax
jne 0x13a2d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq