// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movl %edx, 0x4c(%rsp)
movq %rcx, 0x40(%rsp)
movl %r8d, 0x3c(%rsp)
movq 0x58(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x110e2(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movsbl 0xaa(%rax), %eax
movl %eax, 0x38(%rsp)
movl $0x4, 0x2c(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x0, 0x38(%rsp)
jge 0x2e98c
movq 0x58(%rsp), %rax
movsbl 0x202(%rax), %eax
movl %eax, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x2ebd4
movq 0x50(%rsp), %rax
movzbl 0x38(%rax), %eax
movq %rax, 0x18(%rsp)
subq $0xa, %rax
ja 0x2e9f6
movq 0x18(%rsp), %rax
leaq 0x8530(%rip), %rcx      # 0x36ef4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x2ebf0
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x2e9f6
movl $0x18, 0x24(%rsp)
jmp 0x2e9f6
movl $0x1c, 0x24(%rsp)
movq 0x50(%rsp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x11, %eax
jne 0x2ea3a
movl $0x1f, 0x24(%rsp)
movl $0x2, 0x2c(%rsp)
movq 0x50(%rsp), %rax
movb $0x1, 0x38(%rax)
movq 0x30(%rsp), %rax
movw $0x20, 0xa(%rax)
movq 0x30(%rsp), %rax
movq $-0x1, 0x10(%rax)
jmp 0x2eaea
movq 0x30(%rsp), %rax
movzwl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0x2eae8
movq 0x30(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x2eae8
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
movzwl 0xa(%rcx), %ecx
movl %ecx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq 0x30(%rsp), %rcx
movzwl 0xa(%rcx), %ecx
movl %ecx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x2eae8
movq 0x30(%rsp), %rax
movzwl 0xa(%rax), %eax
movl %eax, 0x14(%rsp)
subl $0x8, %eax
je 0x2eaca
jmp 0x2eab4
movl 0x14(%rsp), %eax
subl $0x10, %eax
je 0x2ead4
jmp 0x2eabf
movl 0x14(%rsp), %eax
subl $0x20, %eax
je 0x2eade
jmp 0x2eae6
movl $0x0, 0x2c(%rsp)
jmp 0x2eae6
movl $0x1, 0x2c(%rsp)
jmp 0x2eae6
movl $0x2, 0x2c(%rsp)
jmp 0x2eae8
jmp 0x2eaea
cmpl $0x0, 0x24(%rsp)
je 0x2eb64
cmpl $0x4, 0x2c(%rsp)
jae 0x2eb64
cmpl $0x0, 0x24(%rsp)
jle 0x2eb1a
movl 0x38(%rsp), %edi
movl 0x24(%rsp), %edx
leaq 0x28(%rsp), %rsi
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x8370
movl 0x38(%rsp), %edi
movl 0x2c(%rsp), %r8d
leaq 0x28(%rsp), %rsi
movl $0x19, %edx
movl $0x2, %ecx
callq 0x8370
movl 0x38(%rsp), %edi
movl 0x4c(%rsp), %ecx
xorl %r8d, %r8d
movl $0x1, %eax
cmpl $0x0, %ecx
cmovnel %eax, %r8d
leaq 0x28(%rsp), %rsi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x8370
jmp 0x2ebd2
movq 0x58(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x10eba(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
movq 0x50(%rsp), %rax
movzbl 0x38(%rax), %eax
movl %eax, %ecx
leaq 0x11011(%rip), %rax     # 0x3fba0
movq (%rax,%rcx,8), %rdx
movq 0x30(%rsp), %rax
movzwl 0x8(%rax), %ecx
movq 0x30(%rsp), %rax
movzwl 0xa(%rax), %r8d
movq 0x30(%rsp), %rax
movq 0x10(%rax), %r9
movq 0x40(%rsp), %r10
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
movl $0x20, %edi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x8c00
jmp 0x2ebd4
movl 0x38(%rsp), %edi
leaq 0x28(%rsp), %rsi
movl $0x18, %edx
movl $0x8, %ecx
callq 0x82c0
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopl (%rax)