// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movl $0x200, %edi            # imm = 0x200
callq 0x6668
movq %rax, 0x8(%rsp)
movl $0x7b, %edi
movl $0x7d, %esi
callq 0xfb48
leaq 0x144e7(%rip), %r15     # 0x22a8c
xorl %r14d, %r14d
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
callq 0x1006f
movl %eax, %r12d
movzbl %al, %eax
leal -0x3a(%rax), %ecx
cmpl $0x7, %ecx
ja 0xe609
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movl $0x1, %edi
callq 0x100e6
testq %rax, %rax
je 0xe62b
movq %rax, %r13
leaq 0x25099(%rip), %rbp     # 0x33680
movq (%rbp), %rbp
testq %rbp, %rbp
je 0xe724
movq 0x8(%rbp), %rdi
movq %r13, %rsi
callq 0x5160
testl %eax, %eax
jne 0xe5e7
jmp 0xe726
testl %eax, %eax
jne 0xe617
movl $0x1, %ebx
jmp 0xe832
movl $0x1, %ebx
movl $0x1, %edi
callq 0x100d3
jmp 0xe832
movq 0x24fee(%rip), %r12     # 0x33620
callq 0x10563
movl $0x4e, %edi
jmp 0xe7fe
movl $0x1, %edi
callq 0x100e6
testq %rax, %rax
je 0xe7ce
movq %rax, %r12
movq 0x18(%rsp), %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe871
testq %rax, %rax
je 0xe80c
movl 0x4(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x4(%rsp)
movq 0x8(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
cmpl $0x3f, %ecx
jl 0xe832
leaq 0x14635(%rip), %rdi     # 0x22ccc
leaq 0x1461e(%rip), %rsi     # 0x22cbc
xorl %eax, %eax
callq 0x52b0
jmp 0xe832
callq 0x1006f
cmpb $0x54, %al
jne 0xe793
callq 0x1006f
cmpb $0x3e, %al
je 0xe5ce
movl $0x1, %edi
callq 0x100d3
movq 0x24f4b(%rip), %r13     # 0x33620
callq 0x10563
movl $0x42, %edi
movq %r13, %rsi
movl %eax, %edx
movl $0x3e, %ecx
xorl %eax, %eax
callq 0x6f84
jmp 0xe5ce
movq $-0x1, %rdi
leaq 0x20(%rsp), %rsi
callq 0x101d8
testl %eax, %eax
je 0xe7ed
movzwl 0x20(%rsp), %eax
movq 0x18(%rsp), %rcx
movw %ax, 0x200(%rcx)
jmp 0xe832
xorl %ebp, %ebp
testq %rbp, %rbp
je 0xe757
cmpb $0x3e, %r12b
jne 0xe775
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0xe832
movq %rbp, 0x30(%rax)
movq %rbp, 0x24eee(%rip)     # 0x33638
cmpq $0x0, 0x28(%rax)
jne 0xe832
jmp 0xe783
movq 0x24ec2(%rip), %r12     # 0x33620
callq 0x10563
movl $0x46, %edi
movq %r12, %rsi
movl %eax, %edx
movq %r13, %rcx
jmp 0xe825
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0xe832
movq %rbp, 0x28(%rax)
movq %rbp, 0x24eb2(%rip)     # 0x33640
jmp 0xe832
movl $0x1, %edi
callq 0x100d3
movq 0x24e7c(%rip), %r13     # 0x33620
callq 0x10563
movl %eax, %ebp
movl $0x1, %edi
callq 0x100e6
movl $0x41, %edi
movq %r13, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6f84
jmp 0xe5ce
movq 0x24e4b(%rip), %r12     # 0x33620
callq 0x10563
movl $0x4e, %edi
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f84
jmp 0xe832
movq 0x24e2c(%rip), %r12     # 0x33620
callq 0x10563
movl $0x43, %edi
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f84
jmp 0xe82c
movq 0x24e0d(%rip), %r13     # 0x33620
callq 0x10563
movl $0x6f, %edi
movq %r13, %rsi
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6f84
movl $0x1, %r14d
testl %ebx, %ebx
je 0xe5b2
testl %r14d, %r14d
je 0xe84d
movq 0x8(%rsp), %rdi
callq 0x5040
xorl %eax, %eax
jmp 0xe862
movslq 0x4(%rsp), %rax
movq 0x8(%rsp), %rcx
movq $0x0, (%rcx,%rax,8)
movq %rcx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq