// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/t_aout.c
// Function: aoutstd_relocs
void aoutstd_relocs(struct GlobalVars *gv,struct ObjectUnit *ou,
                    struct aout_hdr *hdr,int be,
                    struct relocation_info *reloc,uint32_t rsize,
                    struct Section *sec,uint32_t saddr)
/* reads all relocations in standard format for a section */
{
  static uint16_t bsize[4] = { 8,16,32,64 };
  struct LinkFile *lf = ou->lnkfile;
  uint32_t mid = GETMID(hdr);

  if (sec) {
    int i;

    if (((uint8_t *)reloc < lf->data) ||
        (((uint8_t *)reloc)+rsize > lf->data + lf->length))
      error(85,lf->pathname,"stdreloc",lf->objname);  /* illegal offset */

    if (rsize % sizeof(struct relocation_info) != 0)  /* reloc sanity check */
      error(86,lf->pathname,"stdreloc",lf->objname,
            sizeof(struct relocation_info));

    for (i=0; i<(rsize/sizeof(struct relocation_info)); i++,reloc++) {
      uint32_t *info = &reloc->r_info;
      uint32_t symnum = readbf32(be,info,RELB_symbolnum,RELS_symbolnum);
      int size = readbf32(be,info,RSTDB_length,RSTDS_length);
      int pcrel = readbf32(be,info,RSTDB_pcrel,RSTDS_pcrel);
      int baserel = readbf32(be,info,RSTDB_baserel,RSTDS_baserel);
      int jmptable = readbf32(be,info,RSTDB_jmptable,RSTDS_jmptable);
      int relative = readbf32(be,info,RSTDB_relative,RSTDS_relative);
      int copy = readbf32(be,info,RSTDB_copy,RSTDS_copy);
      int xtern = readbf32(be,info,RSTDB_extern,RSTDS_extern);
      uint8_t rtype;

      if (!pcrel && !baserel && !jmptable && !relative && !copy) {
        rtype = R_ABS;
      }
      else if (pcrel && !baserel && !jmptable && !relative && !copy) {
        rtype = R_PC;
      }
      else if (baserel && !pcrel && !jmptable && !relative && !copy) {
        rtype = R_SD;
      }
      else if (!mid && !pcrel && !baserel && !jmptable && !relative &&
               copy && size==2) {
        /* MID 0 and 32-bit COPY reloc may indicate a Jaguar GPU
           MOVEI RISC-instruction, which has swapped 16-bit words */
        rtype = R_AOUT_MOVEI;
        if (gv->endianess < 0)
          gv->endianess = _BIG_ENDIAN_;  /* Jaguar is big-endian */
      }
      else
        ierror("aoutstd_relocs(): %s (%s): Reloc type "
               "<pcrel=%d len=%d extern=%d baserel=%d jmptab=%d "
               "rel=%d copy=%d> in %s is currently not supported",
               lf->pathname,lf->objname,pcrel,bsize[size],xtern,baserel,
               jmptable,relative,copy,sec->name);

      if (rtype) {
        /* create a.out relocation */
        aout_newreloc(gv,hdr,sec,saddr,symnum,xtern!=0,rtype,bsize[size],
                      read32(be,&reloc->r_address),be);
      }
      else {
        /* illegal a.out relocation */
        error(90,lf->pathname,sec->name,lf->objname,
              (uint32_t)read32(be,&reloc->r_address),pcrel,size,xtern,
              baserel,jmptable,relative,copy);
      }
    }
  }

  else if (rsize) {
    /* no section for these relocations! */
    error(89,lf->pathname,lf->objname);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r9d, %ebx
movq %r8, %r14
movl %ecx, 0xc(%rsp)
movq %rdi, 0x10(%rsp)
movl 0xc8(%rsp), %ebp
movq 0xc0(%rsp), %r12
movq 0x10(%rsi), %r15
movq %rdx, 0x60(%rsp)
movq %rdx, %rdi
callq 0x6929
movl %eax, 0x38(%rsp)
movq %r12, 0x18(%rsp)
testq %r12, %r12
movq %r15, 0x50(%rsp)
je 0x1b92d
movq 0x28(%r15), %rax
movl %ebx, %r12d
cmpq %r14, %rax
ja 0x1b27a
leaq (%r14,%r12), %rcx
addq 0x30(%r15), %rax
cmpq %rax, %rcx
jbe 0x1b295
movq 0x10(%r15), %rsi
movq 0x20(%r15), %rcx
leaq 0x9675(%rip), %rdx      # 0x248fe
movl $0x55, %edi
xorl %eax, %eax
callq 0x6f14
testb $0x7, %r12b
je 0x1b2bc
movq 0x10(%r15), %rsi
movq 0x20(%r15), %rcx
leaq 0x9654(%rip), %rdx      # 0x248fe
movl $0x8, %r8d
movl $0x56, %edi
xorl %eax, %eax
callq 0x6f14
cmpl $0x8, %ebx
jb 0x1b95b
shrl $0x3, %r12d
andl $0x3ff0000, 0x38(%rsp)  # imm = 0x3FF0000
movq 0x60(%rsp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, 0x78(%rsp)
movl %ebp, %ecx
movq %rcx, 0x70(%rsp)
leaq 0x4(%rax), %rcx
movq %rcx, 0x58(%rsp)
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq %r12, 0x80(%rsp)
movb %bpl, 0x20(%rsp)
movq %r14, 0x48(%rsp)
leaq 0x4(%r14), %r15
movl 0xc(%rsp), %ebx
movl %ebx, %edi
movq %r15, %rsi
xorl %edx, %edx
movl $0x18, %ecx
callq 0x6af6
movl %eax, (%rsp)
movl %ebx, %edi
movq %r15, %rsi
movl $0x19, %edx
movl $0x2, %ecx
callq 0x6af6
movl %eax, 0x30(%rsp)
movl %ebx, %edi
movq %r15, %rsi
movl $0x18, %edx
movl $0x1, %ecx
callq 0x6af6
movl %eax, 0x28(%rsp)
movl %ebx, %edi
movq %r15, %rsi
movl $0x1c, %edx
movl $0x1, %ecx
callq 0x6af6
movl %eax, %ebp
movl %ebx, %edi
movq %r15, %rsi
movl $0x1d, %edx
movl $0x1, %ecx
callq 0x6af6
movl %eax, %r12d
movl %ebx, %edi
movq %r15, %rsi
movl $0x1e, %edx
movl $0x1, %ecx
callq 0x6af6
movl %eax, %r14d
movl %ebx, %edi
movq %r15, %rsi
movl $0x1f, %edx
movl $0x1, %ecx
callq 0x6af6
movl %eax, %r13d
movl %ebx, %edi
movq %r15, %rsi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x6af6
movl 0x30(%rsp), %edi
movl 0x28(%rsp), %ecx
movq %rbp, %r11
movl %eax, %ebx
movl %ecx, %eax
orl %r11d, %eax
movl %r12d, %edx
orl %r14d, %edx
orl %eax, %edx
movb $0x1, %bpl
orl %r13d, %edx
movslq %edi, %r15
je 0x1b4bc
movl %r11d, %eax
orl %r12d, %eax
testl %ecx, %ecx
sete %sil
movl %eax, %edx
orl %r14d, %edx
orl %r13d, %edx
setne %dl
orb %sil, %dl
movb $0x2, %bpl
cmpb $0x1, %dl
jne 0x1b4bc
movl %ecx, %esi
orl %r12d, %esi
testl %r11d, %r11d
sete %dl
orl %r14d, %esi
orl %r13d, %esi
setne %sil
orb %dl, %sil
movb $0xa, %bpl
cmpb $0x1, %sil
jne 0x1b4bc
testl %r13d, %r13d
setne %sil
movl %ecx, %edx
orl 0x38(%rsp), %edx
orl %eax, %edx
orl %r14d, %edx
xorl $0x2, %edi
orl %edx, %edi
sete %al
andb %sil, %al
cmpb $0x1, %al
jne 0x1b474
movq 0x10(%rsp), %rax
cmpb $0x0, 0x202(%rax)
jns 0x1b46f
movb $0x1, 0x202(%rax)
movb $0x11, %bpl
jmp 0x1b4bc
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x20(%rax), %rdx
leaq 0x946e(%rip), %rax      # 0x248f6
movzwl (%rax,%r15,2), %r8d
subq $0x8, %rsp
leaq 0x946f(%rip), %rdi      # 0x24907
movl %ebx, %r9d
xorl %eax, %eax
movq 0x20(%rsp), %r10
pushq 0x20(%r10)
pushq %r13
pushq %r14
pushq %r12
pushq %r11
callq 0x52b0
addq $0x30, %rsp
movb 0x20(%rsp), %bpl
leaq 0x9433(%rip), %rax      # 0x248f6
movzwl (%rax,%r15,2), %r12d
movl 0xc(%rsp), %edi
movq 0x48(%rsp), %r14
movq %r14, %rsi
callq 0x696f
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %r15
movq 0x10(%r15), %rdx
movq %rdx, 0x28(%rsp)
movl %eax, %eax
movq 0x40(%rcx), %rdx
movq %rax, 0x30(%rsp)
addq %rax, %rdx
movzwl %r12w, %r8d
movzbl %bpl, %r12d
movq 0x10(%rsp), %rdi
movl %r12d, %esi
xorl %ecx, %ecx
movl %r8d, 0x3c(%rsp)
movq $-0x1, %r9
callq 0xb3fc
movq %rax, %r13
movq %r12, 0x20(%rsp)
cmpb $0x11, %r12b
jne 0x1b53e
roll $0x10, %r13d
movq %r13, %rdi
movl $0x20, %esi
callq 0x6ea5
movq %rax, %r13
testl %ebx, %ebx
je 0x1b655
movq %r13, 0x40(%rsp)
movl %ebp, %r13d
movq 0x60(%rsp), %rbp
movq %rbp, %rdi
movl 0xc(%rsp), %r12d
movl %r12d, %esi
callq 0x1d74e
movl %eax, %ebx
movl %r12d, %edi
movq 0x78(%rsp), %rsi
callq 0x696f
movl %eax, %r14d
addl %ebx, %r14d
addq %rbp, %r14
movq %rbp, %rdi
movl %r12d, %esi
callq 0x1d74e
movl %eax, %eax
addq %rbp, %rax
movl (%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,4), %rbp
movl %r12d, %edi
movq %rbp, %rsi
callq 0x696f
movl %eax, %ebx
addq %r14, %rbx
movq 0x70(%rsp), %rax
movq 0x30(%rsp), %r9
addq %r9, %rax
cmpb $0x2, %r13b
movl $0x0, %ecx
cmovneq %rcx, %rax
cmpb $0x1, 0x4(%rbp)
jne 0x1b6d7
cmpb $0x11, %r13b
movq 0x48(%rsp), %r14
movq 0x10(%rsp), %r15
movl %r13d, %ebp
jne 0x1b705
movq %r15, %rdi
movq 0x18(%rsp), %r12
movq %r12, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r9, %r13
pushq 0x40(%rsp)
movl $0x1, %eax
pushq %rax
callq 0xb13c
addq $0x10, %rsp
movl $0xffff, %r8d           # imm = 0xFFFF
movq %r12, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x10, %ecx
callq 0xb1f1
leal 0x2(%r13), %r9d
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
pushq 0x40(%rsp)
movl $0x1, %eax
pushq %rax
callq 0xb13c
addq $0x10, %rsp
movl $0xffff0000, %r8d       # imm = 0xFFFF0000
movq %r12, %rdi
jmp 0x1b8ce
movl (%rsp), %r12d
testl $0xffffffe1, %r12d      # imm = 0xFFFFFFE1
je 0x1b68c
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x20(%rax), %r8
movl $0x5c, %edi
movl %r12d, %edx
movq 0x30(%rsp), %r9
xorl %eax, %eax
callq 0x6f14
andl $0x1e, %r12d
cmpl $0x8, %r12d
je 0x1b784
cmpl $0x6, %r12d
je 0x1b737
cmpl $0x4, %r12d
movq 0x20(%rsp), %rbx
jne 0x1b7ea
movq %r15, %rdi
movl $0x1, %esi
movl $0x5, %edx
callq 0xbd7f
testq %rax, %rax
je 0x1b80c
movq %rax, (%rsp)
jmp 0x1b829
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x5b, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6f14
movq 0x48(%rsp), %r14
movl %r13d, %ebp
jmp 0x1b916
movq 0x40(%rsp), %r10
addq %rax, %r10
movq %r15, %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
pushq %r10
pushq 0x28(%rsp)
callq 0xb13c
addq $0x10, %rsp
movq %r15, %rdi
jmp 0x1b901
movq %r15, %rdi
movl $0x2, %esi
movl $0x3, %edx
callq 0xbd7f
movq %rax, (%rsp)
testq %rax, %rax
movq 0x20(%rsp), %r15
jne 0x1b76c
leaq 0x92e5(%rip), %rdi      # 0x24a43
leaq 0x92b1(%rip), %rsi      # 0x24a16
xorl %eax, %eax
callq 0x52b0
movl 0xc(%rsp), %edi
movq 0x58(%rsp), %rsi
callq 0x696f
movq 0x10(%rsp), %r12
jmp 0x1b833
movb %bpl, 0x28(%rsp)
movq %r15, %rdi
movl $0x3, %esi
movl $0x3, %edx
callq 0xbd7f
movq %rax, (%rsp)
testq %rax, %rax
jne 0x1b7b9
leaq 0x92b3(%rip), %rdi      # 0x24a5e
leaq 0x9264(%rip), %rsi      # 0x24a16
xorl %eax, %eax
callq 0x52b0
movl 0xc(%rsp), %ebp
movl %ebp, %edi
movq 0x58(%rsp), %rsi
callq 0x696f
movl %eax, %ebx
movl %ebp, %edi
movq 0x68(%rsp), %rsi
callq 0x696f
addl %ebx, %eax
movq 0x10(%rsp), %r12
movb 0x28(%rsp), %bpl
movq 0x20(%rsp), %r15
jmp 0x1b833
movq $0x0, (%rsp)
leaq 0x927f(%rip), %rdi      # 0x24a78
leaq 0x9216(%rip), %rsi      # 0x24a16
movl %r12d, %edx
xorl %eax, %eax
callq 0x52b0
jmp 0x1b829
movq $0x0, (%rsp)
leaq 0x920d(%rip), %rdi      # 0x24a28
leaq 0x91f4(%rip), %rsi      # 0x24a16
xorl %eax, %eax
callq 0x52b0
xorl %eax, %eax
movq 0x10(%rsp), %r12
movq %rbx, %r15
cmpb $0x11, %bpl
movq 0x30(%rsp), %r9
je 0x1b84e
cmpl $0x2, %r15d
je 0x1b8da
cmpl $0x1, %r15d
jne 0x1b853
movl %eax, %eax
subq %rax, %r13
cmpb $0x11, %bpl
jne 0x1b8dd
movq %r12, %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
movq (%rsp), %rcx
movq %rcx, (%rsp)
xorl %r8d, %r8d
movq %r9, %r15
pushq %r13
movl $0x1, %eax
pushq %rax
callq 0xb13c
addq $0x10, %rsp
movl $0xffff, %r8d           # imm = 0xFFFF
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x10, %ecx
callq 0xb1f1
leal 0x2(%r15), %r9d
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq (%rsp), %rcx
xorl %r8d, %r8d
pushq %r13
movl $0x1, %eax
pushq %rax
callq 0xb13c
addq $0x10, %rsp
movl $0xffff0000, %r8d       # imm = 0xFFFF0000
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x10, %ecx
jmp 0x1b911
addq %r9, %r13
movq %r12, %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
movq (%rsp), %rcx
xorl %r8d, %r8d
pushq %r13
pushq %r15
callq 0xb13c
addq $0x10, %rsp
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl 0x3c(%rsp), %ecx
movq $-0x1, %r8
callq 0xb1f1
addq $0x8, %r14
movq 0x80(%rsp), %r12
decq %r12
jne 0x1b2f8
jmp 0x1b95b
testl %ebx, %ebx
je 0x1b95b
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x20(%rax), %rdx
movl $0x59, %edi
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6f14
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq