// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/targets.c
// Function: write_constructors
static void write_constructors(struct GlobalVars *gv,struct ObjectUnit *ou,
                               struct Symbol *labelsym,int cnt,
                               lword offset,const char *secname)
{
  uint8_t *data = ou->lnkfile->data + offset;
  unsigned long asize = (unsigned long)fff[gv->dest_format]->addr_bits / 8;
  struct Section *sec;
  struct PriPointer *pp;

  /* create a new section, if required */
  for (sec=(struct Section *)ou->sections.first;
       sec->n.next!=NULL; sec=(struct Section *)sec->n.next) {
    if (!strcmp(secname,sec->name))
      break;
  }
  if (sec->n.next == NULL) {
    sec = add_xtor_section(gv,ou,secname,ou->lnkfile->data+offset,2*asize);
    offset = 0;
  }
  else
    sec->size += 2*asize;

  /* assign constructor/destructor label symbol to start of list */
  unlink_lnksymbol(gv,labelsym);
  labelsym->relsect = sec;
  labelsym->type = SYM_RELOC;
  labelsym->value = offset;
  labelsym->size = 2 * asize;
  add_objsymbol(ou,labelsym);
  addglobsym(gv,labelsym);  /* make it globally visible */
  data += writetaddr(gv,data,(lword)cnt);
  offset += asize;

  /* write con-/destructor pointers */
  for (pp=(struct PriPointer *)gv->pripointers.first;
       pp->n.next!=NULL; pp=(struct PriPointer *)pp->n.next) {
    if (!strcmp(pp->listname,labelsym->name)) {
      struct Reloc *r;

      data += writetaddr(gv,data,pp->addend);
      if (pp->xrefname) {
        r = newreloc(gv,sec,pp->xrefname,NULL,0,(unsigned long)offset,
                     R_ABS,pp->addend);
        addreloc(sec,r,0,asize<<3,-1);
      }
      sec->size += asize;
      labelsym->size += asize;
      offset += asize;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbp
movl %ecx, 0x24(%rsp)
movq %rdx, %rbx
movq 0x10(%rsi), %rax
movq 0x20(%rsi), %r15
movq 0x28(%rax), %r14
movq %r8, %r12
addq %r8, %r14
movq %rdi, 0x18(%rsp)
movzbl 0x50(%rdi), %eax
leaq 0x22a07(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rax
movsbq 0xab(%rax), %rax
movq %rax, 0x30(%rsp)
shrq $0x3, %rax
movq %rax, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
leaq 0x20(%rsi), %rax
movq %rax, 0x28(%rsp)
movq %r15, %r13
movq (%r15), %r15
testq %r15, %r15
je 0xc7cd
movq 0x20(%r13), %rsi
movq %rbp, %rdi
callq 0x5160
testl %eax, %eax
jne 0xc7a1
movq 0x8(%rsp), %rax
addq %rax, %rax
addq %rax, 0x48(%r13)
movq %r14, %rbp
jmp 0xc81f
movq 0x8(%rsp), %rax
leaq (%rax,%rax), %rcx
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rbp
movq %r14, %rdx
callq 0xc0a9
movq %rax, %r13
movw $0x102, 0x2c(%rax)      # imm = 0x102
movb $0x3, 0x2e(%rax)
movzbl 0x82(%r15), %eax
cmpb $0x3, %al
movl $0x2, %ecx
cmovael %eax, %ecx
movb %cl, 0x2f(%r13)
movq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x6729
xorl %r12d, %r12d
movq 0x18(%rsp), %rax
movq 0x188(%rax), %r15
testq %r15, %r15
je 0xc86d
movq 0x20(%rbx), %rdi
callq 0x6d94
andl $0xf, %eax
leaq (%r15,%rax,8), %rdx
movq %rdx, %rax
movq (%rdx), %rcx
testq %rcx, %rcx
je 0xc854
leaq 0x18(%rcx), %rdx
cmpq %rbx, %rcx
jne 0xc840
testq %rcx, %rcx
movq %r12, %r15
je 0xc887
movq 0x18(%rbx), %rcx
movq %rcx, (%rax)
movq $0x0, 0x18(%rbx)
jmp 0xc8a0
leaq 0x1614b(%rip), %rdi     # 0x229bf
leaq 0x16100(%rip), %rsi     # 0x2297b
xorl %eax, %eax
callq 0x52b0
movq %r12, %r15
jmp 0xc8a0
movq 0x20(%rbx), %rdx
leaq 0x160fe(%rip), %rdi     # 0x22990
leaq 0x160e2(%rip), %rsi     # 0x2297b
xorl %eax, %eax
callq 0x52b0
movq %r13, 0x38(%rbx)
movb $0x2, 0x40(%rbx)
movq %r15, 0x30(%rbx)
movq 0x8(%rsp), %rax
addl %eax, %eax
movl %eax, 0x44(%rbx)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rdi
movq %rbx, %rsi
callq 0xcdb6
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa82b
movslq 0x24(%rsp), %rdx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x6a4f
movq 0x1a8(%r15), %r15
movq (%r15), %rbp
testq %rbp, %rbp
je 0xc9a3
addq 0x8(%rsp), %r12
cltq
addq %rax, %r14
movswl 0x30(%rsp), %eax
andl $0xfff8, %eax           # imm = 0xFFF8
movzwl %ax, %eax
movl %eax, 0x10(%rsp)
movq 0x18(%r15), %rdi
movq 0x20(%rbx), %rsi
callq 0x5160
testl %eax, %eax
jne 0xc993
movq 0x30(%r15), %rdx
movq 0x18(%rsp), %rdi
movq %r14, %rbp
movq %r14, %rsi
callq 0x6a4f
movl %eax, %r14d
movq 0x28(%r15), %rdx
testq %rdx, %rdx
je 0xc978
movq %r13, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
pushq 0x30(%r15)
pushq $0x1
callq 0xb13c
addq $0x10, %rsp
movq %r13, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl 0x10(%rsp), %ecx
movq $-0x1, %r8
callq 0xb1f1
movq 0x8(%rsp), %rcx
addq %rcx, 0x48(%r13)
addl %ecx, 0x44(%rbx)
movslq %r14d, %rax
addq %rax, %rbp
movq %rbp, %r14
addq %rcx, %r12
movq (%r15), %rbp
movq %rbp, %r15
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0xc915
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq