// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_ataritos.c
// Function: tos_symboltable
static void tos_symboltable(struct GlobalVars *gv,FILE *f,
                            struct LinkedSection **sections)
{
  struct Symbol *sym;
  struct Reloc *xref;
  int i;

  for (i=0; i<3; i++) {
    if (sections[i]) {
      for (sym=(struct Symbol *)sections[i]->symbols.first;
           sym->n.next!=NULL; sym=(struct Symbol *)sym->n.next) {
        if (!discard_symbol(gv,sym)) {
          uint16_t t;

          if (sym->type == SYM_ABS) {
            t = STYP_EQUATED;  /* @@@ correct? */
          }
          else if (sym->type != SYM_COMMON) {
            switch (i) {
              case 0: t = STYP_TEXT; break;
              case 1: t = STYP_DATA; break;
              case 2: t = STYP_BSS; break;
            }
          }
          else
            ierror("tos_symboltable(): Common symbol <%s> not supported",
                   sym->name);

          t |= STYP_DEFINED;
          if (sym->bind > SYMB_LOCAL)
            t |= STYP_GLOBAL;

          write_dri_sym(f,sym->name,t,sym->value);
        }
      }

      if (gv->dest_object) {
        /* @@@ test - objects are not really supported for now... */
        for (xref=(struct Reloc *)sections[i]->xrefs.first;
             xref->n.next!=NULL; xref=(struct Reloc *)xref->n.next) {
          /* @@@ no idea if this is correct - what about ref.type??? */
          write_dri_sym(f,xref->xrefname,STYP_EXTERNAL,
                        sections[i]->base + xref->offset);
        }
      }
    }
  }
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
cmpl $0x3, 0xc(%rsp)
jge 0x306b7
movq 0x20(%rsp), %rax
movslq 0xc(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x306a5
movq 0x20(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0xb0(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq $0x0, (%rax)
je 0x3062d
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x13660
cmpl $0x0, %eax
jne 0x30619
movq 0x18(%rsp), %rax
movzbl 0x40(%rax), %eax
cmpl $0x1, %eax
jne 0x30563
movw $0x4000, 0xa(%rsp)      # imm = 0x4000
jmp 0x305c9
movq 0x18(%rsp), %rax
movzbl 0x40(%rax), %eax
cmpl $0x3, %eax
je 0x305b0
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x30595
jmp 0x3057f
movl 0x4(%rsp), %eax
subl $0x1, %eax
je 0x3059e
jmp 0x3058a
movl 0x4(%rsp), %eax
subl $0x2, %eax
je 0x305a7
jmp 0x305ae
movw $0x200, 0xa(%rsp)       # imm = 0x200
jmp 0x305ae
movw $0x400, 0xa(%rsp)       # imm = 0x400
jmp 0x305ae
movw $0x100, 0xa(%rsp)       # imm = 0x100
jmp 0x305c7
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
leaq 0x784e(%rip), %rdi      # 0x37e0e
movb $0x0, %al
callq 0x8ae0
jmp 0x305c9
movzwl 0xa(%rsp), %eax
orl $0x8000, %eax           # imm = 0x8000
movw %ax, 0xa(%rsp)
movq 0x18(%rsp), %rax
movzbl 0x43(%rax), %eax
cmpl $0x1, %eax
jle 0x305f5
movzwl 0xa(%rsp), %eax
orl $0x2000, %eax           # imm = 0x2000
movw %ax, 0xa(%rsp)
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
movw 0xa(%rsp), %ax
movq 0x18(%rsp), %rcx
movq 0x30(%rcx), %rcx
movzwl %ax, %edx
callq 0x306c0
jmp 0x3061b
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0x30525
movq 0x30(%rsp), %rax
cmpl $0x0, 0x54(%rax)
je 0x306a3
movq 0x20(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x98(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq $0x0, (%rax)
je 0x306a1
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x20(%rsp), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x40(%rax), %rax
movq 0x10(%rsp), %rcx
addq 0x20(%rcx), %rax
movl %eax, %ecx
movl $0x800, %edx            # imm = 0x800
callq 0x306c0
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x30652
jmp 0x306a3
jmp 0x306a5
jmp 0x306a7
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x304eb
addq $0x38, %rsp
retq
nopl (%rax)