// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_stabs
static void elf32_stabs(struct GlobalVars *gv,struct LinkFile *lf,
                        struct Elf32_Ehdr *ehdr,struct ObjectUnit *ou)
/* find .stabstr belonging to .stab, convert everything (including
   .rela.stab) into internal format and delete *.stab* afterwards. */
{
  static const char *fn = "elf32_stabs";
  static const char *stabname = "stab";
  bool be = (ehdr->e_ident[EI_DATA] == ELFDATA2MSB);
  struct Section *stabsec;

  if (stabsec = find_sect_name(ou,".stab")) {
    char *strtab = elf32_strtab(lf,ehdr,stabsec->link);
    struct nlist32 *nlst = (struct nlist32 *)stabsec->data;
    long nlstlen = (long)stabsec->size;

    while (nlstlen >= sizeof(struct nlist32)) {
      /* next compilation unit: */
      /* read number of nlist records and size of string table */
      int cnt = (int)read16(be,&nlst->n_desc);
      uint32_t strtabsize = read32(be,&nlst->n_value);
      uint32_t funstart = 0;  /* start address of last function definition */
      struct Section *funsec = NULL;

      nlst++;
      nlstlen -= sizeof(struct nlist32);

      while (cnt--) {
        struct Reloc *r;
        struct Section *relsec;
        char *name;
        uint32_t val;

        if (nlstlen < sizeof(struct nlist32))
          error(118,lf->pathname,stabname,lf->objname);  /* malformatted */

        if (nlst->n_strx)
          name = strtab + read32(be,&nlst->n_strx);
        else
          name = NULL;

        switch (nlst->n_type & N_TYPE) {
          case N_TEXT:
          case N_DATA:
          case N_BSS:
            if (r = findreloc(stabsec,
                              (uint8_t *)&nlst->n_value - stabsec->data)) {
              if (r->rtype!=R_ABS || r->insert->bsiz!=32)
                ierror("%s: Bad .stab relocation",fn);
              relsec = r->relocsect.ptr;
              val = (uint32_t)r->addend;
              break;
            }
          default:
            relsec = NULL;
            val = read32(be,&nlst->n_value);
            break;
        }

        switch (nlst->n_type) {
          case N_FUN:
            if (nlst->n_strx) {
              if (relsec) {  /* function start is always relocatable */
                funsec = relsec;
                funstart = val;
              }
              else
                ierror("%s: N_FUN without relocatable address",fn);
            }
            else {  /* no name marks function end, still relative */
              relsec = funsec;
              val += funstart;
            }
            break;
          case N_SLINE:
            if (relsec == NULL) {
              relsec = funsec;
              val += funstart;
            }
            break;
        }

        addstabs(ou,relsec,name,nlst->n_type,nlst->n_other,
                 (int16_t)read16(be,&nlst->n_desc),val);
        nlst++;
        nlstlen -= sizeof(struct nlist32);
      }

      strtab += strtabsize;
    }
    if (nlstlen)
      error(118,lf->pathname,stabname,lf->objname);  /* ignoring junk */

    /* remove .stab from this object unit - will be recreated later */
    remnode(&stabsec->n);
  }
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
movq 0xa0(%rsp), %rax
movzbl 0x5(%rax), %eax
cmpl $0x2, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x94(%rsp)
movq 0x98(%rsp), %rdi
leaq 0x14fa2(%rip), %rsi     # 0x366e6
callq 0x12040
movq %rax, 0x88(%rsp)
cmpq $0x0, %rax
je 0x21b0e
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0x88(%rsp), %rax
movl 0x90(%rax), %edx
callq 0x1f960
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x88(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x70(%rsp)
cmpq $0xc, 0x70(%rsp)
jb 0x21ace
movl 0x94(%rsp), %edi
movq 0x78(%rsp), %rsi
addq $0x6, %rsi
callq 0x8010
movzwl %ax, %eax
movl %eax, 0x6c(%rsp)
movl 0x94(%rsp), %edi
movq 0x78(%rsp), %rsi
addq $0x8, %rsi
callq 0x8060
movl %eax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movq $0x0, 0x58(%rsp)
movq 0x78(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x78(%rsp)
movq 0x70(%rsp), %rax
subq $0xc, %rax
movq %rax, 0x70(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x6c(%rsp)
cmpl $0x0, %eax
je 0x21ab0
cmpq $0xc, 0x70(%rsp)
jae 0x2185f
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x1eb49(%rip), %rdx     # 0x40390
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x76, %edi
movb $0x0, %al
callq 0x8c00
movq 0x78(%rsp), %rax
cmpl $0x0, (%rax)
je 0x2189a
movq 0x80(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x94(%rsp), %edi
movq 0x78(%rsp), %rsi
callq 0x8060
movl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
jmp 0x218a3
movq $0x0, 0x40(%rsp)
movq 0x78(%rsp), %rax
movzbl 0x4(%rax), %eax
andl $0x1e, %eax
movl %eax, 0x2c(%rsp)
subl $0x4, %eax
je 0x218d4
jmp 0x218ba
movl 0x2c(%rsp), %eax
subl $0x6, %eax
je 0x218d4
jmp 0x218c5
movl 0x2c(%rsp), %eax
subl $0x8, %eax
jne 0x21958
jmp 0x218d4
movq 0x88(%rsp), %rdi
movq 0x78(%rsp), %rsi
addq $0x8, %rsi
movq 0x88(%rsp), %rax
movq 0x40(%rax), %rax
subq %rax, %rsi
callq 0x10b50
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x21956
movq 0x50(%rsp), %rax
movzbl 0x38(%rax), %eax
cmpl $0x1, %eax
jne 0x21924
movq 0x50(%rsp), %rax
movq 0x30(%rax), %rax
movzwl 0xa(%rax), %eax
cmpl $0x20, %eax
je 0x21939
movq 0x1ea5d(%rip), %rsi     # 0x40388
leaq 0x14e46(%rip), %rdi     # 0x36778
movb $0x0, %al
callq 0x8ae0
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq 0x28(%rax), %rax
movl %eax, 0x3c(%rsp)
jmp 0x2197a
jmp 0x21958
movq $0x0, 0x48(%rsp)
movl 0x94(%rsp), %edi
movq 0x78(%rsp), %rsi
addq $0x8, %rsi
callq 0x8060
movl %eax, 0x3c(%rsp)
movq 0x78(%rsp), %rax
movzbl 0x4(%rax), %eax
movl %eax, 0x28(%rsp)
subl $0x24, %eax
je 0x21999
jmp 0x2198e
movl 0x28(%rsp), %eax
subl $0x44, %eax
je 0x219ee
jmp 0x21a0e
movq 0x78(%rsp), %rax
cmpl $0x0, (%rax)
je 0x219d6
cmpq $0x0, 0x48(%rsp)
je 0x219bf
movq 0x48(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x64(%rsp)
jmp 0x219d4
movq 0x1e9c2(%rip), %rsi     # 0x40388
leaq 0x14dc4(%rip), %rdi     # 0x36791
movb $0x0, %al
callq 0x8ae0
jmp 0x219ec
movq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0x64(%rsp), %eax
addl 0x3c(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x21a0e
cmpq $0x0, 0x48(%rsp)
jne 0x21a0c
movq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0x64(%rsp), %eax
addl 0x3c(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x21a0e
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x78(%rsp), %rax
movb 0x4(%rax), %al
movb %al, 0x26(%rsp)
movq 0x78(%rsp), %rax
movb 0x5(%rax), %al
movb %al, 0x27(%rsp)
movl 0x94(%rsp), %edi
movq 0x78(%rsp), %rsi
addq $0x6, %rsi
callq 0x8010
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movb 0x26(%rsp), %cl
movb 0x27(%rsp), %r8b
movw %ax, %r9w
movl 0x3c(%rsp), %eax
movzbl %cl, %ecx
movsbl %r8b, %r8d
movswl %r9w, %r9d
movl %eax, (%rsp)
callq 0x10bc0
movq 0x78(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x78(%rsp)
movq 0x70(%rsp), %rax
subq $0xc, %rax
movq %rax, 0x70(%rsp)
jmp 0x21816
movl 0x68(%rsp), %ecx
movq 0x80(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x80(%rsp)
jmp 0x217a8
cmpq $0x0, 0x70(%rsp)
je 0x21b01
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x1e8a7(%rip), %rdx     # 0x40390
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x76, %edi
movb $0x0, %al
callq 0x8c00
movq 0x88(%rsp), %rdi
callq 0x7530
addq $0xb8, %rsp
retq
nopw %cs:(%rax,%rax)