// File: /workspace/github_c_makefile_star2_O3/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 0x11e02(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rdx
movb 0xaa(%rdx), %al
movl $0x0, 0x4(%rsp)
testb %al, %al
jns 0x1d39a
movb 0x202(%rdi), %al
movsbl %al, %ebx
movq 0x30(%r11), %rdi
testq %rdi, %rdi
je 0x1d4d9
movzbl 0x38(%r11), %r8d
cmpl $0x1, %r8d
jle 0x1d3d9
cmpl $0x11, %r8d
je 0x1d3fb
cmpl $0xa, %r8d
je 0x1d46d
cmpl $0x2, %r8d
jne 0x1d47a
movl $0x18, %eax
jmp 0x1d472
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %r8d, %r8d
je 0x1d4ef
cmpl $0x1, %r8d
jne 0x1d47a
xorl %r9d, %r9d
xorl %esi, %esi
jmp 0x1d481
movb $0x1, 0x38(%r11)
movw $0x20, 0xa(%rdi)
movq $-0x1, 0x10(%rdi)
movl $0x1f, %eax
movl $0x2, %r14d
leaq 0x4(%rsp), %rsi
movl %ebx, %edi
movl %eax, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x6b40
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movq %r15, %rsi
movl $0x19, %edx
movl $0x2, %ecx
movl %r14d, %r8d
callq 0x6b40
xorl %r8d, %r8d
testl %ebp, %ebp
setne %r8b
movl %ebx, %edi
movq %r15, %rsi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x6b40
jmp 0x1d4d9
movl $0x1c, %eax
movb $0x1, %sil
xorl %r9d, %r9d
jmp 0x1d481
xorl %esi, %esi
movb $0x1, %r9b
xorl %eax, %eax
movzwl 0x8(%rdi), %r15d
testl %r15d, %r15d
jne 0x1d4a9
cmpq $0x0, (%rdi)
jne 0x1d4a9
movzwl 0xa(%rdi), %ecx
movq $-0x1, %r14
shlq %cl, %r14
orq 0x10(%rdi), %r14
cmpq $-0x1, %r14
je 0x1d4fa
movq (%rdx), %rsi
leaq 0x11e3d(%rip), %rax     # 0x2f2f0
movq (%rax,%r8,8), %rdx
movzwl 0xa(%rdi), %r8d
movq 0x10(%rdi), %r9
movl $0x20, %edi
movl %r15d, %ecx
xorl %eax, %eax
pushq 0x20(%r11)
pushq %r10
callq 0x6f14
addq $0x10, %rsp
leaq 0x4(%rsp), %rsi
movl %ebx, %edi
movl $0x18, %edx
movl $0x8, %ecx
callq 0x6af6
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x8, %ecx
je 0x1d519
cmpl $0x20, %ecx
je 0x1d511
cmpl $0x10, %ecx
jne 0x1d4a9
movl $0x1, %r14d
jmp 0x1d51c
movl $0x2, %r14d
jmp 0x1d51c
xorl %r14d, %r14d
testb %r9b, %r9b
jne 0x1d4a9
testb %sil, %sil
jne 0x1d419
jmp 0x1d432