// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/targets.c
// Function: make_constructors
void make_constructors(struct GlobalVars *gv)
/* Create an artificial object for constructor/destructor lists
   and fill them will entries from the PriPointer list. */
{
  if (!gv->dest_object && (gv->ctor_symbol || gv->dtor_symbol)) {
    int nctors=0,ndtors=0;
    bool ctors=FALSE,dtors=FALSE;
    const char *csecname=NULL,*dsecname=NULL;
    unsigned long clen,dlen;
    struct PriPointer *pp;
    uint8_t *data;
    struct ObjectUnit *ou;

    /* check if constructors or destructors are needed (referenced) */
    if (gv->ctor_symbol) {
      if (gv->ctor_symbol->flags & SYMF_REFERENCED) {
        ctors = TRUE;
        for (pp=(struct PriPointer *)gv->pripointers.first;
             pp->n.next!=NULL; pp=(struct PriPointer *)pp->n.next) {
          if (!strcmp(pp->listname,gv->ctor_symbol->name)) {
            if (csecname) {
              if (strcmp(csecname,pp->secname))
                error(125);  /* CTORS/DTORS spread over multiple sections */
            }
            else
              csecname = pp->secname;
          }
        }
        if (!csecname)
          csecname = xtors_secname(gv,ctors_name);
      }
    }
    if (gv->dtor_symbol) {
      if (gv->dtor_symbol->flags & SYMF_REFERENCED) {
        dtors = TRUE;
        for (pp=(struct PriPointer *)gv->pripointers.first;
             pp->n.next!=NULL; pp=(struct PriPointer *)pp->n.next) {
          if (!strcmp(pp->listname,gv->dtor_symbol->name)) {
            if (dsecname) {
              if (strcmp(dsecname,pp->secname))
                error(125);  /* CTORS/DTORS spread over multiple sections */
            }
            else
              dsecname = pp->secname;
          }
        }
        if (!dsecname)
          dsecname = xtors_secname(gv,dtors_name);
      }
    }
    if (!ctors && !dtors)
      return;

    /* count number of constructor and destructor pointers */
    for (pp=(struct PriPointer *)gv->pripointers.first;
         pp->n.next!=NULL; pp=(struct PriPointer *)pp->n.next) {
      if (ctors) {
        if (!strcmp(pp->listname,gv->ctor_symbol->name))
          nctors++;
      }
      if (dtors) {
        if (!strcmp(pp->listname,gv->dtor_symbol->name))
          ndtors++;
      }
    }

    /* create artificial object */
    clen = (unsigned long)(fff[gv->dest_format]->addr_bits / 8) *
            (ctors ? nctors+2 : 0);
    dlen = (unsigned long)(fff[gv->dest_format]->addr_bits / 8) *
            (dtors ? ndtors+2 : 0);
    data = alloczero(clen + dlen);
    ou = art_objunit(gv,"INITEXIT",data,clen+dlen);

    /* write constructors/destructors */
    if (ctors)
      write_constructors(gv,ou,gv->ctor_symbol,nctors,0,csecname);
    if (dtors)
      write_constructors(gv,ou,gv->dtor_symbol,ndtors,clen,dsecname);

    /* enqueue artificial object unit into linking process */
    ou->lnkfile->type = ID_OBJECT;
    add_objunit(gv,ou,FALSE);
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x12fe0
movq 0x70(%rsp), %rax
cmpq $0x0, 0x210(%rax)
jne 0x12bba
movq 0x70(%rsp), %rax
cmpq $0x0, 0x218(%rax)
je 0x12fe0
movl $0x0, 0x6c(%rsp)
movl $0x0, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x70(%rsp), %rax
cmpq $0x0, 0x210(%rax)
je 0x12cd3
movq 0x70(%rsp), %rax
movq 0x210(%rax), %rax
movzbl 0x41(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12cd1
movl $0x1, 0x64(%rsp)
movq 0x70(%rsp), %rax
movq 0x1a8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, (%rax)
je 0x12cb1
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x210(%rax), %rax
movq 0x20(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x12ca0
cmpq $0x0, 0x58(%rsp)
je 0x12c90
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
je 0x12c8e
movl $0x7d, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x12c9e
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x58(%rsp)
jmp 0x12ca0
jmp 0x12ca2
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x12c34
cmpq $0x0, 0x58(%rsp)
jne 0x12ccf
movq 0x70(%rsp), %rdi
leaq 0x22908(%rip), %rsi     # 0x355cd
callq 0x11be0
movq %rax, 0x58(%rsp)
jmp 0x12cd1
jmp 0x12cd3
movq 0x70(%rsp), %rax
cmpq $0x0, 0x218(%rax)
je 0x12dba
movq 0x70(%rsp), %rax
movq 0x218(%rax), %rax
movzbl 0x41(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12db8
movl $0x1, 0x60(%rsp)
movq 0x70(%rsp), %rax
movq 0x1a8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, (%rax)
je 0x12d98
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x218(%rax), %rax
movq 0x20(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x12d87
cmpq $0x0, 0x50(%rsp)
je 0x12d77
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
je 0x12d75
movl $0x7d, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x12d85
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0x12d87
jmp 0x12d89
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x12d1b
cmpq $0x0, 0x50(%rsp)
jne 0x12db6
movq 0x70(%rsp), %rdi
leaq 0x22828(%rip), %rsi     # 0x355d4
callq 0x11be0
movq %rax, 0x50(%rsp)
jmp 0x12db8
jmp 0x12dba
cmpl $0x0, 0x64(%rsp)
jne 0x12dcd
cmpl $0x0, 0x60(%rsp)
jne 0x12dcd
jmp 0x12fe0
movq 0x70(%rsp), %rax
movq 0x1a8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, (%rax)
je 0x12e6f
cmpl $0x0, 0x64(%rsp)
je 0x12e24
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x210(%rax), %rax
movq 0x20(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x12e22
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x12e24
cmpl $0x0, 0x60(%rsp)
je 0x12e5b
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x218(%rax), %rax
movq 0x20(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x12e59
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x12e5b
jmp 0x12e5d
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x12dde
movq 0x70(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x2cbaf(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movsbl 0xab(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cltq
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x12eaf
movl 0x6c(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x1c(%rsp)
jmp 0x12eb7
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
jmp 0x12eb7
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x70(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x2cb52(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movsbl 0xab(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cltq
movq %rax, 0x10(%rsp)
cmpl $0x0, 0x60(%rsp)
je 0x12f0c
movl 0x68(%rsp), %eax
addl $0x2, %eax
movl %eax, 0xc(%rsp)
jmp 0x12f14
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x12f14
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
addq 0x40(%rsp), %rdi
callq 0x7290
movq %rax, 0x30(%rsp)
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rdx
movq 0x48(%rsp), %rcx
addq 0x40(%rsp), %rcx
leaq 0x22995(%rip), %rsi     # 0x358ed
callq 0x12350
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x12f92
movq 0x70(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x70(%rsp), %rax
movq 0x210(%rax), %rdx
movl 0x6c(%rsp), %ecx
movq 0x58(%rsp), %r9
xorl %eax, %eax
movl %eax, %r8d
callq 0x12ff0
cmpl $0x0, 0x60(%rsp)
je 0x12fc2
movq 0x70(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x70(%rsp), %rax
movq 0x218(%rax), %rdx
movl 0x68(%rsp), %ecx
movq 0x48(%rsp), %r8
movq 0x50(%rsp), %r9
callq 0x12ff0
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movb $0x1, 0x39(%rax)
movq 0x70(%rsp), %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x123e0
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)