// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/ldscript.c
// Function: endofsecdef
static struct Phdr **endofsecdef(struct GlobalVars *gv,
                                 struct LinkedSection *ls)
/* Parses syntax of everything which follows the '}' of a section
   definition. Memory-region pointers and fill-value will be initialized
   when the section-pointer 'ls' is given.
   On success the function returns a list of pointers to Phdr structures
   which were defined (terminated by a NULL pointer). This list must
   be deallocated by the caller!
   Syntax: } [>memregion] [AT>lma-region] [:phdr ...] [=fill] */
{
  const char *fn = "endofsecdef(): ";
  struct Phdr **pp = alloc(64 * sizeof(struct Phdr *));  /* it's ugly! */
  struct Phdr *phdr;
  struct MemoryDescr *md;
  int phdrcnt=0,done=0,err=0;
  char c,*buf;
  lword val;

  endofblock('{','}');

  while (!done) {
    switch (c = getchr()) {
      case '>':
      case '@':
      case 'A':
        if (c == 'A') {
          if (getchr() == 'T') {
            if (getchr() != '>') {
              back(1);
              error(66,scriptname,getlineno(),'>');  /* '>' expected */
            }
          }
          else {
            back(1);
            error(65,scriptname,getlineno(),getword());
          }
        }
        if (buf = getword()) {
          if (md = find_memblock(buf)) {
            if (c == '>') {
              if (ls) {
                ls->relocmem = md;
                vdefmem = md;
                if (ls->destmem == NULL) {
                  ls->destmem = md;
                  ldefmem = md;
                }
              }
            }
            else if (ls) {
              ls->destmem = md;
              ldefmem = md;
            }
          }
          else {
            error(70,scriptname,getlineno(),buf);  /* Unknown memory region */
            err = 1;
          }
        }
        else {
          error(78,scriptname,getlineno());   /* missing argument */
          err = 1;
        }
        break;

      case ':':
        if (buf = getword()) {
          if (phdr = find_phdr(gv,buf,NULL,NULL)) {
            pp[phdrcnt++] = phdr;
            if (phdrcnt >= 64)
              ierror("%sphdrcnt overrun",fn);
          }
          else {
            error(111,scriptname,getlineno(),buf);  /* unknown PHDR */
            err = 1;
          }
        }
        else
          error(78,scriptname,getlineno());
        break;

      case '=':
        if (parse_expr(-1,&val)) {
          gv->filldata = (uint16_t)(val & 0xffff);
        }
        else {
          error(67,scriptname,getlineno());  /* Absolute number expected */
          err = 1;
        }
        break;

      case '\0':
        done = 1;
        break;

      default:
        done = 1;
        back(1);
        break;
    }
  }

  if (err) {
    free(pp);
    pp = NULL;
  }
  else
    pp[phdrcnt] = NULL;

  return pp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
movl $0x200, %edi            # imm = 0x200
callq 0x6340
movq %rax, 0x10(%rsp)
pushq $0x7b
popq %rdi
pushq $0x7d
popq %rsi
callq 0xefde
movb $0x1, %al
leaq 0x12e24(%rip), %r15     # 0x20a80
xorl %r14d, %r14d
xorl %ebp, %ebp
movslq %r14d, %rbx
testb $0x1, %al
je 0xdebd
callq 0xf457
movl %eax, %r13d
movzbl %al, %ecx
leal -0x3a(%rcx), %eax
cmpl $0x7, %eax
ja 0xdcee
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0xe109
testq %rax, %rax
je 0xdd07
movq %rax, %r12
leaq 0x25dd4(%rip), %rbx     # 0x33a70
movq (%rbx), %rbx
testq %rbx, %rbx
je 0xddeb
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
jne 0xdc9c
movb $0x1, %al
cmpb $0x3e, %r13b
jne 0xde40
cmpq $0x0, 0x8(%rsp)
je 0xdc61
movq 0x8(%rsp), %rax
movq %rbx, 0x30(%rax)
movq %rbx, 0x25d4c(%rip)     # 0x33a28
cmpq $0x0, 0x28(%rax)
movb $0x1, %al
jne 0xdc61
jmp 0xde4c
xorl %eax, %eax
testl %ecx, %ecx
je 0xdc61
pushq $0x1
popq %rdi
callq 0xf4ac
xorl %eax, %eax
jmp 0xdc61
movq 0x25d02(%rip), %rbx     # 0x33a10
callq 0xf90a
pushq $0x4e
jmp 0xde93
callq 0xe109
testq %rax, %rax
je 0xde63
movq %rax, %r12
movq 0x18(%rsp), %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xdee8
testq %rax, %rax
je 0xdeaa
leal 0x1(%rbx), %r14d
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movb $0x1, %al
cmpl $0x3f, %ebx
jl 0xdc61
leaq 0x12f59(%rip), %rdi     # 0x20cbd
leaq 0x12f42(%rip), %rsi     # 0x20cad
xorl %eax, %eax
callq 0x6b2c
movb $0x1, %al
jmp 0xdc61
callq 0xf457
cmpb $0x54, %al
jne 0xde0e
callq 0xf457
cmpb $0x3e, %al
je 0xdc88
pushq $0x1
popq %rdi
callq 0xf4ac
movq 0x25c6e(%rip), %r12     # 0x33a10
callq 0xf90a
pushq $0x42
popq %rdi
movq %r12, %rsi
movl %eax, %edx
pushq $0x3e
popq %rcx
xorl %eax, %eax
callq 0x6c19
jmp 0xdc88
pushq $-0x1
popq %rdi
leaq 0x20(%rsp), %rsi
callq 0xf5a5
testl %eax, %eax
je 0xde85
movzwl 0x20(%rsp), %eax
movq 0x18(%rsp), %rcx
movw %ax, 0x200(%rcx)
movb $0x1, %al
jmp 0xdc61
movq 0x25c1e(%rip), %rbx     # 0x33a10
callq 0xf90a
pushq $0x46
popq %rdi
movq %rbx, %rsi
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6c19
jmp 0xdea0
pushq $0x1
popq %rdi
callq 0xf4ac
movq 0x25bf3(%rip), %r12     # 0x33a10
callq 0xf90a
movl %eax, %ebx
callq 0xe109
pushq $0x41
popq %rdi
movq %r12, %rsi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6c19
jmp 0xdc88
cmpq $0x0, 0x8(%rsp)
je 0xdc61
movq 0x8(%rsp), %rax
movq %rbx, 0x28(%rax)
movq %rbx, 0x25bd4(%rip)     # 0x33a30
movb $0x1, %al
jmp 0xdc61
movq 0x25ba6(%rip), %rbx     # 0x33a10
callq 0xf90a
pushq $0x4e
popq %rdi
movq %rbx, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6c19
movb $0x1, %al
jmp 0xdc61
movq 0x25b84(%rip), %rbx     # 0x33a10
callq 0xf90a
pushq $0x43
popq %rdi
movq %rbx, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6c19
movb $0x1, %al
pushq $0x1
popq %rbp
jmp 0xdc61
movq 0x25b5f(%rip), %rbx     # 0x33a10
callq 0xf90a
pushq $0x6f
jmp 0xddf9
testl %ebp, %ebp
je 0xdecf
movq 0x10(%rsp), %rdi
callq 0x5040
xorl %eax, %eax
jmp 0xded9
movq 0x10(%rsp), %rax
andq $0x0, (%rax,%rbx,8)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq