// File: /workspace/github_c_makefile_star2_O0/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 %r14
pushq %rbx
subq $0xe0, %rsp
movl 0x108(%rsp), %eax
movq 0x100(%rsp), %rax
movq %rdi, 0xd8(%rsp)
movq %rsi, 0xd0(%rsp)
movq %rdx, 0xc8(%rsp)
movl %ecx, 0xc4(%rsp)
movq %r8, 0xb8(%rsp)
movl %r9d, 0xb4(%rsp)
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x7a00
shrl $0x10, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0xa4(%rsp)
cmpq $0x0, 0x100(%rsp)
je 0x2b5ec
movq 0xb8(%rsp), %rax
movq 0xa8(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x2b0cd
movq 0xb8(%rsp), %rax
movl 0xb4(%rsp), %ecx
addq %rcx, %rax
movq 0xa8(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq 0xa8(%rsp), %rdx
addq 0x30(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x2b0f8
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x55, %edi
leaq 0xbe2f(%rip), %rdx      # 0x36f20
movb $0x0, %al
callq 0x8c00
movl 0xb4(%rsp), %eax
andq $0x7, %rax
cmpq $0x0, %rax
je 0x2b13a
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x56, %edi
leaq 0xbdf3(%rip), %rdx      # 0x36f20
movl $0x8, %r8d
movb $0x0, %al
callq 0x8c00
movl $0x0, 0xa0(%rsp)
movslq 0xa0(%rsp), %rax
movl 0xb4(%rsp), %ecx
shrq $0x3, %rcx
cmpq %rcx, %rax
jae 0x2b5ea
movq 0xb8(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x98(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
xorl %edx, %edx
movl $0x18, %ecx
callq 0x82c0
movl %eax, 0x94(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x19, %edx
movl $0x2, %ecx
callq 0x82c0
movl %eax, 0x90(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x18, %edx
movl $0x1, %ecx
callq 0x82c0
movl %eax, 0x8c(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x1c, %edx
movl $0x1, %ecx
callq 0x82c0
movl %eax, 0x88(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x1d, %edx
movl $0x1, %ecx
callq 0x82c0
movl %eax, 0x84(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x1e, %edx
movl $0x1, %ecx
callq 0x82c0
movl %eax, 0x80(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x1f, %edx
movl $0x1, %ecx
callq 0x82c0
movl %eax, 0x7c(%rsp)
movl 0xc4(%rsp), %edi
movq 0x98(%rsp), %rsi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x82c0
movl %eax, 0x78(%rsp)
cmpl $0x0, 0x8c(%rsp)
jne 0x2b2cd
cmpl $0x0, 0x88(%rsp)
jne 0x2b2cd
cmpl $0x0, 0x84(%rsp)
jne 0x2b2cd
cmpl $0x0, 0x80(%rsp)
jne 0x2b2cd
cmpl $0x0, 0x7c(%rsp)
jne 0x2b2cd
movb $0x1, 0x77(%rsp)
jmp 0x2b438
cmpl $0x0, 0x8c(%rsp)
je 0x2b306
cmpl $0x0, 0x88(%rsp)
jne 0x2b306
cmpl $0x0, 0x84(%rsp)
jne 0x2b306
cmpl $0x0, 0x80(%rsp)
jne 0x2b306
cmpl $0x0, 0x7c(%rsp)
jne 0x2b306
movb $0x2, 0x77(%rsp)
jmp 0x2b436
cmpl $0x0, 0x88(%rsp)
je 0x2b33f
cmpl $0x0, 0x8c(%rsp)
jne 0x2b33f
cmpl $0x0, 0x84(%rsp)
jne 0x2b33f
cmpl $0x0, 0x80(%rsp)
jne 0x2b33f
cmpl $0x0, 0x7c(%rsp)
jne 0x2b33f
movb $0xa, 0x77(%rsp)
jmp 0x2b434
cmpl $0x0, 0xa4(%rsp)
jne 0x2b3af
cmpl $0x0, 0x8c(%rsp)
jne 0x2b3af
cmpl $0x0, 0x88(%rsp)
jne 0x2b3af
cmpl $0x0, 0x84(%rsp)
jne 0x2b3af
cmpl $0x0, 0x80(%rsp)
jne 0x2b3af
cmpl $0x0, 0x7c(%rsp)
je 0x2b3af
cmpl $0x2, 0x90(%rsp)
jne 0x2b3af
movb $0x11, 0x77(%rsp)
movq 0xd8(%rsp), %rax
movsbl 0x202(%rax), %eax
cmpl $0x0, %eax
jge 0x2b3aa
movq 0xd8(%rsp), %rax
movb $0x1, 0x202(%rax)
jmp 0x2b432
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rdx
movl 0x8c(%rsp), %ecx
movslq 0x90(%rsp), %rdi
leaq 0x15e4b(%rip), %rax     # 0x41228
movzwl (%rax,%rdi,2), %r8d
movl 0x78(%rsp), %r9d
movl 0x88(%rsp), %ebp
movl 0x84(%rsp), %ebx
movl 0x80(%rsp), %r11d
movl 0x7c(%rsp), %r10d
movq 0x100(%rsp), %rax
movq 0x20(%rax), %rax
leaq 0xbb14(%rip), %rdi      # 0x36f29
movl %ebp, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0x8ae0
jmp 0x2b434
jmp 0x2b436
jmp 0x2b438
cmpb $0x0, 0x77(%rsp)
je 0x2b510
movq 0xd8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0x108(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x78(%rsp)
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x70(%rsp)
movb 0x77(%rsp), %bl
movslq 0x90(%rsp), %rcx
leaq 0x15d84(%rip), %rax     # 0x41228
movw (%rax,%rcx,2), %ax
movw %ax, 0x74(%rsp)
movl 0xc4(%rsp), %edi
movq 0xb8(%rsp), %rsi
callq 0x8060
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movl 0x68(%rsp), %ecx
movl 0x6c(%rsp), %r8d
movl 0x70(%rsp), %r9d
movw 0x74(%rsp), %r11w
movl %eax, %r10d
movl 0xc4(%rsp), %eax
movzbl %bl, %ebx
movl %ebx, (%rsp)
movzwl %r11w, %r11d
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x2b630
jmp 0x2b5be
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x100(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x48(%rsp)
movl 0xc4(%rsp), %edi
movq 0xb8(%rsp), %rsi
callq 0x8060
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
movl %eax, %r8d
movl 0x8c(%rsp), %r9d
movl 0x90(%rsp), %r14d
movl 0x78(%rsp), %ebp
movl 0x88(%rsp), %ebx
movl 0x84(%rsp), %r11d
movl 0x80(%rsp), %r10d
movl 0x7c(%rsp), %eax
movl $0x5a, %edi
movl %r14d, (%rsp)
movl %ebp, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movb $0x0, %al
callq 0x8c00
jmp 0x2b5c0
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
movq 0xb8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xb8(%rsp)
jmp 0x2b145
jmp 0x2b61c
cmpl $0x0, 0xb4(%rsp)
je 0x2b61a
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rdx
movl $0x59, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x2b61c
addq $0xe0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax,%rax)