// File: /workspace/github_c_makefile_star2_O3/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, %r14
movq %rdi, 0x18(%rsp)
movl $0x200, %edi            # imm = 0x200
callq 0x6638
movq %rax, 0x10(%rsp)
movl $0x7b, %edi
movl $0x7d, %esi
callq 0xf9cc
leaq 0x145e0(%rip), %rbx     # 0x22a70
xorl %r15d, %r15d
movl $0x0, 0xc(%rsp)
callq 0xfeed
movl %eax, %r12d
movzbl %al, %eax
leal -0x3a(%rax), %ecx
cmpl $0x7, %ecx
ja 0xe6fa
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xe517
movq %rax, %r13
leaq 0x251ac(%rip), %rbp     # 0x33680
movq (%rbp), %rbp
testq %rbp, %rbp
je 0xe613
movq 0x8(%rbp), %rdi
movq %r13, %rsi
callq 0x5160
testl %eax, %eax
jne 0xe4d4
cmpb $0x3e, %r12b
jne 0xe679
testq %r14, %r14
je 0xe49b
movq %rbp, 0x30(%r14)
movq %rbp, 0x2512d(%rip)     # 0x33638
cmpq $0x0, 0x28(%r14)
jne 0xe49b
jmp 0xe682
movq 0x25102(%rip), %r12     # 0x33620
callq 0x103d5
movl $0x4e, %edi
jmp 0xe6a3
movq $-0x1, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1004a
testl %eax, %eax
je 0xe692
movzwl 0x20(%rsp), %eax
movq 0x18(%rsp), %rcx
movw %ax, 0x200(%rcx)
jmp 0xe49b
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xe6ba
movq %rax, %r12
movq 0x18(%rsp), %rax
movq 0x1f8(%rax), %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe73f
testq %rax, %rax
je 0xe6dc
movl 0xc(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0xc(%rsp)
movq 0x10(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
cmpl $0x3f, %ecx
jl 0xe49b
leaq 0x146f4(%rip), %rdi     # 0x22cad
leaq 0x146dd(%rip), %rsi     # 0x22c9d
xorl %eax, %eax
callq 0x52b0
jmp 0xe49b
callq 0xfeed
cmpb $0x54, %al
jne 0xe63e
callq 0xfeed
cmpb $0x3e, %al
je 0xe4bb
movl $0x1, %edi
callq 0xff51
movq 0x2502d(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x42, %edi
movq %r13, %rsi
movl %eax, %edx
movl $0x3e, %ecx
xorl %eax, %eax
callq 0x6f14
jmp 0xe4bb
movq 0x25006(%rip), %r12     # 0x33620
callq 0x103d5
movl $0x46, %edi
movq %r12, %rsi
movl %eax, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %r15d
jmp 0xe49b
movl $0x1, %edi
callq 0xff51
movq 0x24fd1(%rip), %r13     # 0x33620
callq 0x103d5
movl %eax, %ebp
movl $0x1, %edi
callq 0xff64
movl $0x41, %edi
movq %r13, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6f14
jmp 0xe4bb
testq %r14, %r14
je 0xe49b
movq %rbp, 0x28(%r14)
movq %rbp, 0x24fb3(%rip)     # 0x33640
jmp 0xe49b
movq 0x24f87(%rip), %r12     # 0x33620
callq 0x103d5
movl $0x43, %edi
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %r15d
jmp 0xe49b
movq 0x24f5f(%rip), %r12     # 0x33620
callq 0x103d5
movl $0x4e, %edi
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
jmp 0xe49b
movq 0x24f3d(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x6f, %edi
movq %r13, %rsi
movl %eax, %edx
movq %r12, %rcx
jmp 0xe62c
testl %eax, %eax
je 0xe708
movl $0x1, %edi
callq 0xff51
testl %r15d, %r15d
je 0xe71b
movq 0x10(%rsp), %rdi
callq 0x5040
xorl %eax, %eax
jmp 0xe730
movslq 0xc(%rsp), %rax
movq 0x10(%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