// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/t_aout.c
// Function: aoutstd_getrinfo
static uint32_t aoutstd_getrinfo(struct GlobalVars *gv,struct Reloc *rel,
                                bool xtern,const char *sname,uint32_t offs)
/* convert vlink relocation type in standard a.out relocations, */
/* as used by M68k and x86 targets,
/* return ~0 when this relocation has to be ignored */
{
  int be = fff[gv->dest_format]->endianess;
  struct RelocInsert *ri;
  uint32_t s=4,r=0;
  int b=0;

  if (be < 0)
    be = gv->endianess;

  if (ri = rel->insert) {
    switch (rel->rtype) {
      case R_NONE:
        return ~0;
      case R_ABS:
        b = -1;
        break;
      case R_PC:
        b = RSTDB_pcrel;
        break;
      case R_SD:
        b = RSTDB_baserel;
        break;
    }

    if (rel->rtype == R_AOUT_MOVEI) {
      /* Jaguar RISC MOVEI instruction's swapped words are indicated by a
         set RSTDB_copy bit. Reset reloc type to ABS and size to 32 bits. */
      b = RSTDB_copy;
      s = 2;
      rel->rtype = R_ABS;
      ri->bsiz = 32;
      ri->mask = -1;
    }
    else if (ri->bpos==0 && ri->next==NULL &&
             (ri->mask&makemask(ri->bsiz))==makemask(ri->bsiz)) {
      switch (ri->bsiz) {
        case 8: s=0; break;
        case 16: s=1; break;
        case 32: s=2; break;
      }
    }

    if (b && s<4) {
      if (b > 0)
        writebf32(be,&r,b,1,1);
      writebf32(be,&r,RSTDB_length,RSTDS_length,s);
      writebf32(be,&r,RSTDB_extern,RSTDS_extern,xtern?1:0);
    }
    else {
      /* unsupported relocation type */
      error(32,fff[gv->dest_format]->tname,reloc_name[rel->rtype],
            (int)ri->bpos,(int)ri->bsiz,ri->mask,sname,rel->offset);
    }
  }

  return readbf32(be,&r,RELB_reloc,RELS_reloc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %r10
movl %edx, %ebp
movq %rsi, %r11
movzbl 0x50(%rdi), %eax
leaq 0x136c2(%rip), %rcx     # 0x2f190
movq (%rcx,%rax,8), %rdx
movb 0xaa(%rdx), %al
andl $0x0, 0x4(%rsp)
testb %al, %al
jns 0x1bae7
movb 0x202(%rdi), %al
movsbl %al, %ebx
movq 0x30(%r11), %rdi
testq %rdi, %rdi
je 0x1bbec
movzbl 0x38(%r11), %r8d
pushq $-0x1
popq %rax
testl %r8d, %r8d
je 0x1bbfe
cmpl $0x1, %r8d
je 0x1bb24
cmpl $0x11, %r8d
je 0x1bb36
cmpl $0xa, %r8d
je 0x1bb2b
cmpl $0x2, %r8d
jne 0x1bb94
pushq $0x18
jmp 0x1bb2d
xorl %r9d, %r9d
xorl %esi, %esi
jmp 0x1bb9b
pushq $0x1c
popq %rax
movb $0x1, %sil
xorl %r9d, %r9d
jmp 0x1bb9b
movb $0x1, 0x38(%r11)
movw $0x20, 0xa(%rdi)
orq $-0x1, 0x10(%rdi)
pushq $0x1f
popq %rax
pushq $0x2
popq %r14
leaq 0x4(%rsp), %rsi
pushq $0x1
popq %rcx
movl %ebx, %edi
movl %eax, %edx
movl %ecx, %r8d
callq 0x6792
leaq 0x4(%rsp), %r15
pushq $0x19
popq %rdx
pushq $0x2
popq %rcx
movl %ebx, %edi
movq %r15, %rsi
movl %r14d, %r8d
callq 0x6792
xorl %r8d, %r8d
testl %ebp, %ebp
setne %r8b
pushq $0x1b
popq %rdx
pushq $0x1
popq %rcx
movl %ebx, %edi
movq %r15, %rsi
callq 0x6792
jmp 0x1bbec
xorl %esi, %esi
movb $0x1, %r9b
xorl %eax, %eax
movzwl 0x8(%rdi), %r15d
testl %r15d, %r15d
jne 0x1bbc0
cmpq $0x0, (%rdi)
jne 0x1bbc0
movzwl 0xa(%rdi), %ecx
pushq $-0x1
popq %r14
shlq %cl, %r14
orq 0x10(%rdi), %r14
cmpq $-0x1, %r14
je 0x1bc09
movq (%rdx), %rsi
leaq 0x13736(%rip), %rax     # 0x2f300
movq (%rax,%r8,8), %rdx
movzwl 0xa(%rdi), %r8d
movq 0x10(%rdi), %r9
pushq $0x20
popq %rdi
movl %r15d, %ecx
xorl %eax, %eax
pushq 0x20(%r11)
pushq %r10
callq 0x6c19
popq %rax
popq %rcx
leaq 0x4(%rsp), %rsi
pushq $0x18
popq %rdx
pushq $0x8
popq %rcx
movl %ebx, %edi
callq 0x673d
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x8, %ecx
je 0x1bc22
cmpl $0x20, %ecx
je 0x1bc1c
cmpl $0x10, %ecx
jne 0x1bbc0
pushq $0x1
jmp 0x1bc1e
pushq $0x2
popq %r14
jmp 0x1bc25
xorl %r14d, %r14d
testb %r9b, %r9b
jne 0x1bbc0
testb %sil, %sil
jne 0x1bb4d
jmp 0x1bb61