// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/targets.c
// Function: addsymbol
struct Symbol *addsymbol(struct GlobalVars *gv,struct Section *s,
                         const char *name,const char *iname,lword val,
                         uint8_t type,uint8_t flags,uint8_t info,uint8_t bind,
                         uint32_t size,bool chkdef)
/* Define a new symbol. If defined twice in the same object unit, then */
/* return a pointer to its first definition. Defining the symbol twice */
/* globally is only allowed in different object units of a library. */
{
  struct Symbol *sym;
  struct ObjectUnit *ou = s->obj;
  struct Symbol **chain = &ou->objsyms[elf_hash(name)%OBJSYMHTABSIZE];

  while (sym = *chain) {
    if (!strcmp(name,sym->name)) {
      if (chkdef)  /* do we have to warn about multiple def. ourselves? */
        error(56,ou->lnkfile->pathname,name,getobjname(ou));
      return sym;  /* return first definition to caller */
    }
    chain = &sym->obj_chain;
  }

  sym = alloczero(sizeof(struct Symbol));
  sym->name = name;
  sym->indir_name = iname;
  sym->value = val;
  sym->relsect = s;
  sym->type = type;
  sym->flags = flags;
  sym->info = info;
  sym->bind = bind;
  sym->size = size;

  if (type == SYM_COMMON) {
    /* alignment of .common section must suit the biggest common-alignment */
    uint8_t com_alignment = lshiftcnt(val);

    if (com_alignment > s->alignment)
      s->alignment = com_alignment;
  }

  if (check_protection(gv,name))
    sym->flags |= SYMF_PROTECTED;

  if (bind==SYMB_GLOBAL || bind==SYMB_WEAK) {
    uint16_t flags = ou->lnkfile->flags;

    if (flags & IFF_DELUNDERSCORE) {
      if (*name == '_')
        sym->name = name + 1;  /* delete preceding underscore, if present */
    }
    else if (flags & IFF_ADDUNDERSCORE) {
      char *new_name = alloc(strlen(name) + 2);
      
      *new_name = '_';
      strcpy(new_name+1,name);
      sym->name = new_name;
    }

    if (!addglobsym(gv,sym)) {
      free(sym);
      return NULL;
    }
  }

  *chain = sym;
  return NULL;  /* ok, symbol exists only once in this object */
}

// Assembly:
subq $0x78, %rsp
movb %r9b, %al
movl 0xa0(%rsp), %r9d
movl 0x98(%rsp), %r9d
movb 0x90(%rsp), %r9b
movb 0x88(%rsp), %r9b
movb 0x80(%rsp), %r9b
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movb %al, 0x47(%rsp)
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rdi
callq 0x8760
movq %rax, %rcx
movq 0x10(%rsp), %rax
andq $0x1f, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0xfe22
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0xfe0f
cmpl $0x0, 0xa0(%rsp)
je 0xfe00
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, (%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
callq 0x8f00
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rax, %rcx
movl $0x38, %edi
movb $0x0, %al
callq 0x8c00
movq 0x38(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0xfffe
movq 0x38(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x28(%rsp)
jmp 0xfd8a
movl $0x50, %edi
callq 0x7290
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x50(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x48(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x60(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x38(%rax)
movb 0x47(%rsp), %cl
movq 0x38(%rsp), %rax
movb %cl, 0x40(%rax)
movb 0x80(%rsp), %cl
movq 0x38(%rsp), %rax
movb %cl, 0x41(%rax)
movb 0x88(%rsp), %cl
movq 0x38(%rsp), %rax
movb %cl, 0x42(%rax)
movb 0x90(%rsp), %cl
movq 0x38(%rsp), %rax
movb %cl, 0x43(%rax)
movl 0x98(%rsp), %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x44(%rax)
movzbl 0x47(%rsp), %eax
cmpl $0x3, %eax
jne 0xfee9
movq 0x48(%rsp), %rdi
callq 0x88c0
movb %al, 0x27(%rsp)
movzbl 0x27(%rsp), %eax
movq 0x60(%rsp), %rcx
movzbl 0x2f(%rcx), %ecx
cmpl %ecx, %eax
jle 0xfee7
movb 0x27(%rsp), %cl
movq 0x60(%rsp), %rax
movb %cl, 0x2f(%rax)
jmp 0xfee9
movq 0x68(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0xf6e0
cmpl $0x0, %eax
je 0xff0c
movq 0x38(%rsp), %rax
movzbl 0x41(%rax), %ecx
orl $0x4, %ecx
movb %cl, 0x41(%rax)
movzbl 0x90(%rsp), %eax
cmpl $0x2, %eax
je 0xff2a
movzbl 0x90(%rsp), %eax
cmpl $0x3, %eax
jne 0xffe8
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movw 0x3a(%rax), %ax
movw %ax, 0x24(%rsp)
movzwl 0x24(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xff6a
movq 0x58(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0xff68
movq 0x58(%rsp), %rcx
addq $0x1, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x20(%rax)
jmp 0xffbd
movzwl 0x24(%rsp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xffbb
movq 0x58(%rsp), %rdi
callq 0x50c0
movq %rax, %rdi
addq $0x2, %rdi
callq 0x71f0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movb $0x5f, (%rax)
movq 0x18(%rsp), %rdi
addq $0x1, %rdi
movq 0x58(%rsp), %rsi
callq 0x5060
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x20(%rax)
jmp 0xffbd
movq 0x68(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0xf750
cmpl $0x0, %eax
jne 0xffe6
movq 0x38(%rsp), %rdi
callq 0x5030
movq $0x0, 0x70(%rsp)
jmp 0xfffe
jmp 0xffe8
movq 0x38(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nopl (%rax,%rax)