// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_putdynreloc
static size_t elf32_putdynreloc(struct GlobalVars *gv,struct LinkedSection *ls,
                                struct Reloc *rel,void *dst,
                                uint8_t (*reloc_vlink2elf)(struct Reloc *),
                                bool rela,bool be)
{
  const char *fn = "elf32_putdynreloc()";
  struct Elf32_Rela *rp = (struct Elf32_Rela *)dst;
  uint32_t symidx;
  uint8_t rtype;

  if (rel->xrefname) {
    struct SymbolNode *sn;

    sn = elf32_findSymNode(&elf32dsymlist,rel->xrefname);
    if (sn == NULL)
      ierror("%s no symbol <%s> in dyn.table",fn,rel->xrefname);
    symidx = sn->index;
  }
  else
    ierror("%s no symbol base",fn);

  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("%s Reloc without insert-field",fn);
  }

  write32(be,rp->r_offset,(uint32_t)(ls->base + rel->offset));
  write32(be,rp->r_info,ELF32_R_INFO(symidx,(uint32_t)rtype));

  if (rela) {
    write32(be,rp->r_addend,(uint32_t)rel->addend);
    writesection(gv,ls->data+rel->offset,rel,0);
    return sizeof(struct Elf32_Rela);
  }
  writesection(gv,ls->data+rel->offset,rel,rel->addend);
  return sizeof(struct Elf32_Rel);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, 0xc(%rsp)
movq %r8, %r13
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, 0x10(%rsp)
movq 0x10(%rdx), %r14
testq %r14, %r14
movq %rdi, (%rsp)
je 0x18fd3
movq 0x167d1(%rip), %rbp     # 0x2f768
movq %r14, %rdi
callq 0x6e09
xorl %edx, %edx
divq 0x167c8(%rip)           # 0x2f770
xorl %r15d, %r15d
movq (%rbp,%rdx,8), %rbp
testq %rbp, %rbp
je 0x18fef
xorl %r15d, %r15d
movq 0x18(%rbp), %rsi
movq %r14, %rdi
callq 0x5160
testl %eax, %eax
je 0x18fec
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
jne 0x18fb8
jmp 0x18fef
leaq 0xaa9e(%rip), %rdi      # 0x23a78
leaq 0xaa64(%rip), %rsi      # 0x23a45
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x52b0
jmp 0x19014
movq %rbp, %r15
testq %r15, %r15
jne 0x1900d
movq 0x10(%rbx), %rdx
leaq 0xaa5a(%rip), %rdi      # 0x23a59
leaq 0xaa3f(%rip), %rsi      # 0x23a45
xorl %eax, %eax
callq 0x52b0
movl 0x30(%r15), %ebp
shll $0x8, %ebp
movl 0x50(%rsp), %r15d
movq %rbx, %rdi
callq *%r13
movl %eax, %r13d
testb %al, %al
jne 0x19094
movq 0x30(%rbx), %rax
testq %rax, %rax
movq 0x10(%rsp), %r10
je 0x1907f
movq (%rsp), %rcx
movzbl 0x50(%rcx), %ecx
leaq 0x1613d(%rip), %rdx     # 0x2f180
movq (%rdx,%rcx,8), %rcx
movq (%rcx), %rsi
movzbl 0x38(%rbx), %ecx
leaq 0x1629b(%rip), %rdx     # 0x2f2f0
movq (%rdx,%rcx,8), %rdx
movzwl 0x8(%rax), %ecx
movzwl 0xa(%rax), %r8d
movq 0x10(%rax), %r9
movl $0x20, %edi
xorl %eax, %eax
pushq 0x20(%rbx)
pushq 0x18(%r10)
callq 0x6f84
addq $0x10, %rsp
jmp 0x19094
leaq 0xaa04(%rip), %rdi      # 0x23a8a
leaq 0xa9b8(%rip), %rsi      # 0x23a45
xorl %eax, %eax
callq 0x52b0
movl 0x20(%rbx), %edx
movq 0x10(%rsp), %r14
addl 0x40(%r14), %edx
movl %r15d, %edi
movq %r12, %rsi
callq 0x6a19
leaq 0x4(%r12), %rsi
movzbl %r13b, %eax
orl %eax, %ebp
movl %r15d, %edi
movl %ebp, %edx
callq 0x6a19
cmpl $0x0, 0xc(%rsp)
je 0x190f6
addq $0x8, %r12
movl 0x28(%rbx), %edx
movl %r15d, %edi
movq %r12, %rsi
callq 0x6a19
movq 0x78(%r14), %rsi
addq 0x20(%rbx), %rsi
movq (%rsp), %rdi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0xb5b0
movl $0xc, %eax
jmp 0x19113
movq 0x78(%r14), %rsi
addq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq (%rsp), %rdi
movq %rbx, %rdx
callq 0xb5b0
movl $0x8, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop