// File: /workspace/github_c_makefile_star2_O1/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 0x11c46(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rax
movb 0xaa(%rax), %cl
movl $0x0, 0x4(%rsp)
testb %cl, %cl
jns 0x1d556
movb 0x202(%rdi), %cl
movsbl %cl, %ebx
movq 0x30(%r11), %rdi
testq %rdi, %rdi
je 0x1d696
movb 0x38(%r11), %cl
movzbl %cl, %esi
xorl %edx, %edx
cmpl $0x1, %esi
jg 0x1d584
testl %esi, %esi
je 0x1d595
cmpl $0x1, %esi
jne 0x1d5a4
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x1d5a4
cmpl $0x2, %esi
je 0x1d59f
cmpl $0xa, %esi
jne 0x1d5a4
movl $0x1c, %edx
jmp 0x1d5a4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1d6ac
movl $0x18, %edx
cmpb $0x11, %cl
jne 0x1d5cb
movb $0x1, 0x38(%r11)
movw $0x20, 0xa(%rdi)
movq $-0x1, 0x10(%rdi)
movl $0x1f, %edx
movl $0x2, %r14d
movb $0x1, %cl
jmp 0x1d5fc
movl $0x4, %r14d
cmpw $0x0, 0x8(%rdi)
jne 0x1d5fa
cmpq $0x0, (%rdi)
jne 0x1d5fa
movzwl 0xa(%rdi), %ecx
movq $-0x1, %rsi
shlq %cl, %rsi
orq 0x10(%rdi), %rsi
cmpq $-0x1, %rsi
je 0x1d6b7
xorl %ecx, %ecx
testl %edx, %edx
sete %sil
xorb $0x1, %cl
orb %sil, %cl
jne 0x1d660
testl %edx, %edx
jle 0x1d625
leaq 0x4(%rsp), %rsi
movl %ebx, %edi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x6bb5
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movq %r15, %rsi
movl $0x19, %edx
movl $0x2, %ecx
movl %r14d, %r8d
callq 0x6bb5
xorl %r8d, %r8d
testl %ebp, %ebp
setne %r8b
movl %ebx, %edi
movq %r15, %rsi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x6bb5
jmp 0x1d696
movq (%rax), %rsi
movzbl 0x38(%r11), %eax
leaq 0x11c81(%rip), %rcx     # 0x2f2f0
movq (%rcx,%rax,8), %rdx
movzwl 0x8(%rdi), %ecx
movzwl 0xa(%rdi), %r8d
movq 0x10(%rdi), %r9
movl $0x20, %edi
xorl %eax, %eax
pushq 0x20(%r11)
pushq %r10
callq 0x6f84
addq $0x10, %rsp
leaq 0x4(%rsp), %rsi
movl %ebx, %edi
movl $0x18, %edx
movl $0x8, %ecx
callq 0x6b38
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x20, %ecx
je 0x1d5c1
cmpl $0x10, %ecx
je 0x1d6d6
cmpl $0x8, %ecx
jne 0x1d5fa
xorl %r14d, %r14d
jmp 0x1d5c7
movl $0x1, %r14d
jmp 0x1d5c7