// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/linker.c
// Function: get_matching_lnksec
static struct LinkedSection *get_matching_lnksec(struct GlobalVars *gv,
                                                 struct Section *sec,
                                                 struct LinkedSection *myls)
/* find a LinkedSection node which fits the specified section,
   but which is different from 'myls' */
{
  struct LinkedSection *lsn = (struct LinkedSection *)gv->lnksec.first;
  struct LinkedSection *nextlsn;
  uint8_t f;
  int tl;

  while (nextlsn = (struct LinkedSection *)lsn->n.next) {
    if (lsn != myls && ((f = cmpsecflags(gv,lsn,sec->flags)) != 0xff)) {
      f &= ~SF_PORTABLE_MASK;

      if (!gv->dest_object) {
        /* target-specific linking */
        if ((tl = fff[gv->dest_format]->targetlink(gv,lsn,sec)) > 0) {
          /* target demands merge of sections */
          Dprintf("targetlink: %s(%s) -> %s\n",getobjname(sec->obj),
                  sec->name,lsn->name);
          merge_sec_attrs(lsn,sec,f);
          return (lsn);
        }
      }
      else
        tl = 0;

      if (tl == 0) {  /* target wants to use the default rules */

        if (!gv->dest_object) {
          /* for final executable only: */

          if (gv->small_code) {
            if (lsn->type==ST_CODE && sec->type==ST_CODE) {
              /* merge all code sections */
              Dprintf("smallcode: %s(%s) -> %s\n",getobjname(sec->obj),
                      sec->name,lsn->name);
              merge_sec_attrs(lsn,sec,f);
              return (lsn);
            }
          }

          if (gv->small_data) {
            if ((lsn->type==ST_DATA || lsn->type==ST_UDATA) &&
                (sec->type==ST_DATA || sec->type==ST_UDATA)) {
              /* merge all data and bss sections */
              Dprintf("smalldata: %s(%s) -> %s\n",getobjname(sec->obj),
                      sec->name,lsn->name);
              merge_sec_attrs(lsn,sec,f);
              return (lsn);
            }
          }

          if (checkrelrefs(lsn,sec)) {
            /* we must link them together, because there are rel. refs */
            if ((lsn->type==ST_CODE || sec->type==ST_CODE) &&
                lsn->type != sec->type)
              /* forces a maybe unwanted combination of code and data */
              error(58,sec_names[lsn->type],lsn->name,sec_names[sec->type],
                    sec->name,getobjname(sec->obj));
            Dprintf("relrefs: %s(%s) -> %s\n",getobjname(sec->obj),
                    sec->name,lsn->name);
            merge_sec_attrs(lsn,sec,f);
            return (lsn);
          }

          if (!gv->multibase && (lsn->flags & sec->flags & SF_SMALLDATA)) {
            Dprintf("sd-refs: %s(%s) -> %s\n",getobjname(sec->obj),
                    sec->name,lsn->name);
            merge_sec_attrs(lsn,sec,f);
            return (lsn);
          }
        }  /* final executable only */

        /* standard check, if sections could be merged */
        if (myls == NULL) {
          if (!strcmp(sec->name,lsn->name) || /* same name or no name */
              *(sec->name)==0) {
            if (lsn->type==sec->type) {   /* same type */
              Dprintf("name: %s(%s) -> %s\n",getobjname(sec->obj),
                      sec->name,lsn->name);
              merge_sec_attrs(lsn,sec,f);
              return (lsn);
            }
            else if (*(sec->name)==0 && sec->size==0) {
              /* no name and no contents - may contain abs symbols only */
              return (lsn);
            }
          }

          if (!gv->dest_object) {
            /* COMMON sections are merged with any BSS-type section */
            if (!strcmp(sec->name,gv->common_sec_name) ||
                !strcmp(sec->name,gv->scommon_sec_name)) {
              if (lsn->type==ST_UDATA && (lsn->flags & SF_UNINITIALIZED)) {
                Dprintf("common: %s(%s) -> %s\n",getobjname(sec->obj),
                        sec->name,lsn->name);
                merge_sec_attrs(lsn,sec,f);
                return (lsn);
              }
            }
          }
        }

      } /* default rules */
    }
    lsn = nextlsn;
  }
  return (NULL);
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x48(%rsp), %rax
movq 0x1c0(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0xc904
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0xc8f5
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x40(%rsp), %rax
movzbl 0x2d(%rax), %edx
callq 0xc030
movb %al, 0x27(%rsp)
movzbl %al, %eax
cmpl $0xff, %eax
je 0xc8f5
movzbl 0x27(%rsp), %eax
andl $-0x20, %eax
movb %al, 0x27(%rsp)
movq 0x48(%rsp), %rax
cmpl $0x0, 0x54(%rax)
jne 0xc5a5
movq 0x48(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x334d2(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x38(%rax), %rax
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq *%rax
movl %eax, 0x20(%rsp)
cmpl $0x0, %eax
jle 0xc5a3
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
jmp 0xc5ad
movl $0x0, 0x20(%rsp)
cmpl $0x0, 0x20(%rsp)
jne 0xc8f3
movq 0x48(%rsp), %rax
cmpl $0x0, 0x54(%rax)
jne 0xc7bd
movq 0x48(%rsp), %rax
cmpl $0x0, 0x70(%rax)
je 0xc613
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x1, %eax
jne 0xc611
movq 0x40(%rsp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
jne 0xc611
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
jmp 0xc613
movq 0x48(%rsp), %rax
cmpl $0x0, 0x74(%rax)
je 0xc67b
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x2, %eax
je 0xc63a
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x3, %eax
jne 0xc679
movq 0x40(%rsp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
je 0xc656
movq 0x40(%rsp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x3, %eax
jne 0xc679
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
jmp 0xc67b
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xf2d0
cmpl $0x0, %eax
je 0xc771
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x1, %eax
je 0xc6b3
movq 0x40(%rsp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
jne 0xc74e
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
movq 0x40(%rsp), %rcx
movzbl 0x2c(%rcx), %ecx
cmpl %ecx, %eax
je 0xc74e
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
movl %eax, %ecx
leaq 0x33321(%rip), %rax     # 0x3fa00
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rax
movzbl 0x2c(%rax), %eax
movl %eax, %ecx
leaq 0x332f9(%rip), %rax     # 0x3fa00
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x8f00
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r8
movq %rax, %r9
movl $0x3a, %edi
movb $0x0, %al
callq 0x8c00
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
movq 0x48(%rsp), %rax
cmpl $0x0, 0x78(%rax)
jne 0xc7bb
movq 0x30(%rsp), %rax
movzbl 0x21(%rax), %eax
movq 0x40(%rsp), %rcx
movzbl 0x2d(%rcx), %ecx
andl %ecx, %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xc7bb
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
jmp 0xc7bd
cmpq $0x0, 0x38(%rsp)
jne 0xc8f1
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
je 0xc7f6
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xc85f
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
movq 0x40(%rsp), %rcx
movzbl 0x2c(%rcx), %ecx
cmpl %ecx, %eax
jne 0xc82f
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xc85b
movq 0x40(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jne 0xc85b
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
jmp 0xc85d
jmp 0xc85f
movq 0x48(%rsp), %rax
cmpl $0x0, 0x54(%rax)
jne 0xc8ef
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x220(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
je 0xc8ac
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x228(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0xc8ed
movq 0x30(%rsp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x3, %eax
jne 0xc8eb
movq 0x30(%rsp), %rax
movzbl 0x21(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xc8eb
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movzbl 0x27(%rsp), %edx
callq 0xc100
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0xc90d
jmp 0xc8ed
jmp 0xc8ef
jmp 0xc8f1
jmp 0xc8f3
jmp 0xc8f5
movq 0x28(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0xc4e4
movq $0x0, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopw (%rax,%rax)