// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_addrela
static int elf32_addrela(struct GlobalVars *gv,struct LinkedSection *ls,
                         struct Reloc *rel,bool be,
                         uint8_t (*reloc_vlink2elf)(struct Reloc *))
{
  struct RelaNode *rn = alloc(sizeof(struct RelaNode));
  uint32_t symidx;
  uint8_t rtype;

  if (rel->flags & RELF_INTERNAL)
    return 0;  /* internal relocations will never be exported */

  if (rel->xrefname) {
    symidx = elf32_symidx(&elf32symlist,&elf32stringlist,rel->xrefname,be);
  }
  else {
    if (rel->relocsect.lnk == NULL) {
      if (!(rel->flags & RELF_DYNLINK))
        return 0;  /* ignore, because it was resolved by a shared object */
      else
        ierror("elf32_addrela: Reloc type %d (%s) at %s+0x%lx (addend 0x%llx)"
               " is missing a relocsect.lnk",(int)rel->rtype,
               reloc_name[rel->rtype],ls->name,rel->offset,rel->addend);
    }
    symidx = (uint32_t)(rel->relocsect.lnk->index + secsyms);
  }

  if (!(rtype = reloc_vlink2elf(rel))) {
    struct RelocInsert *ri;

    if (ri = rel->insert)
      error(32,fff[gv->dest_format]->tname,reloc_name[rel->rtype],
            (int)ri->bpos,(int)ri->bsiz,ri->mask,ls->name,rel->offset);
    else
      ierror("elf32_addrela(): Reloc without insert-field");
  }

  write32(be,rn->r.r_offset,(uint32_t)(ls->base + rel->offset));
  write32(be,rn->r.r_addend,(uint32_t)rel->addend);
  write32(be,rn->r.r_info,ELF32_R_INFO(symidx,(uint32_t)rtype));
  addtail(&relalist,&rn->n);

  if (gv->reloctab_format != RTAB_ADDEND) {
    writesection(gv,ls->data+rel->offset,rel,rel->addend);
    return sizeof(struct Elf32_Rel);
  }
  writesection(gv,ls->data+rel->offset,rel,0);
  return sizeof(struct Elf32_Rela);
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movl %ecx, 0x34(%rsp)
movq %r8, 0x28(%rsp)
movl $0x20, %edi
callq 0x71f0
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movzbl 0x39(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x257c9
movl $0x0, 0x54(%rsp)
jmp 0x25a28
movq 0x38(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x257fe
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rdx
movl 0x34(%rsp), %ecx
leaq 0x1a9f7(%rip), %rdi     # 0x401e0
leaq 0x1aa50(%rip), %rsi     # 0x40240
callq 0x273c0
movl %eax, 0x1c(%rsp)
jmp 0x2588a
movq 0x38(%rsp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x25874
movq 0x38(%rsp), %rax
movzbl 0x39(%rax), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
jne 0x2582a
movl $0x0, 0x54(%rsp)
jmp 0x25a28
movq 0x38(%rsp), %rax
movzbl 0x38(%rax), %esi
movq 0x38(%rsp), %rax
movzbl 0x38(%rax), %eax
movl %eax, %ecx
leaq 0x1a35b(%rip), %rax     # 0x3fba0
movq (%rax,%rcx,8), %rdx
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x38(%rsp), %rax
movq 0x20(%rax), %r8
movq 0x38(%rsp), %rax
movq 0x28(%rax), %r9
leaq 0x10f95(%rip), %rdi     # 0x36800
movb $0x0, %al
callq 0x8ae0
jmp 0x25874
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x10(%rax), %eax
addl 0x1f46e(%rip), %eax     # 0x44cf4
movl %eax, 0x1c(%rsp)
movq 0x28(%rsp), %rax
movq 0x38(%rsp), %rdi
callq *%rax
movb %al, 0x1b(%rsp)
cmpb $0x0, %al
jne 0x2593a
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x2592a
movq 0x48(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x1a168(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
movq 0x38(%rsp), %rax
movzbl 0x38(%rax), %eax
movl %eax, %ecx
leaq 0x1a2bf(%rip), %rax     # 0x3fba0
movq (%rax,%rcx,8), %rdx
movq 0x10(%rsp), %rax
movzwl 0x8(%rax), %ecx
movq 0x10(%rsp), %rax
movzwl 0xa(%rax), %r8d
movq 0x10(%rsp), %rax
movq 0x10(%rax), %r9
movq 0x40(%rsp), %rax
movq 0x18(%rax), %r10
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
movl $0x20, %edi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x8c00
jmp 0x25938
leaq 0x10f28(%rip), %rdi     # 0x36859
movb $0x0, %al
callq 0x8ae0
jmp 0x2593a
movl 0x34(%rsp), %edi
movq 0x20(%rsp), %rsi
addq $0x10, %rsi
movq 0x40(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x38(%rsp), %rcx
addq 0x20(%rcx), %rax
movl %eax, %edx
callq 0x8130
movl 0x34(%rsp), %edi
movq 0x20(%rsp), %rsi
addq $0x10, %rsi
addq $0x8, %rsi
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
callq 0x8130
movl 0x34(%rsp), %edi
movq 0x20(%rsp), %rsi
addq $0x10, %rsi
addq $0x4, %rsi
movl 0x1c(%rsp), %edx
shll $0x8, %edx
movzbl 0x1b(%rsp), %eax
movzbl %al, %eax
addl %eax, %edx
callq 0x8130
movq 0x20(%rsp), %rsi
leaq 0x1f39c(%rip), %rdi     # 0x44d50
callq 0x7470
movq 0x48(%rsp), %rax
movzbl 0x6e(%rax), %eax
cmpl $0x2, %eax
je 0x259fb
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x78(%rax), %rsi
movq 0x38(%rsp), %rax
addq 0x20(%rax), %rsi
movq 0x38(%rsp), %rdx
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rcx
callq 0x110c0
movl $0x8, 0x54(%rsp)
jmp 0x25a28
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x78(%rax), %rsi
movq 0x38(%rsp), %rax
addq 0x20(%rax), %rsi
movq 0x38(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x110c0
movl $0xc, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)