// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/ldscript.c
// Function: startofsecdef
static int startofsecdef(lword *s_addr,char *s_type,lword *s_lma)
/* Parse syntax of section definition until '{' and return VMA address,
   LMA address and type, when given.
   Returns bitfield. 0 when syntax is incorrect, 1 for correct,
   3 for s_addr set, 5 for s_lma set and 7 for both.
   Syntax: [addr-expr] [(type)] : [AT(lma)] { */
{
  int ret = 1;
  lword caddr = -2; /* this prevents expression evaluation during pre-parse */
  char *buf,c;

  if (current_ls)
    caddr = current_ls->relocmem->current;

  *s_type = 0;

  c = getchr();
  if (c != ':') {
    if (c != '(') {
      back(1);
      parse_expr(caddr,s_addr);
#if 0 /* @@@ not needed? address must be within memory region */
      if (current_ls) {
        if (current_ls->relocmem != defmem) {
          /* warning: address overrides specified VMA memory region */
          error(76,scriptname,getlineno(),'V');
          current_ls->relocmem = defmem;
        }
      }
#endif
      ret |= 2;
      c = getchr();
    }
    if (c == '(') {
      if (buf = getword()) {
        strcpy(s_type,buf);
        if (getchr() != ')') {
          error(66,scriptname,getlineno(),')');  /* ')' expected */
          back(1);
          ret = 0;
        }
        c = getchr();
      }
    }
  }

  if (c != ':') {
    error(66,scriptname,getlineno(),':');  /* ':' expected */
    back(1);
    return 0;
  }

  if (buf = getword()) {
    if (!strcmp(buf,"AT")) {
      if (getchr()=='(') {
        parse_expr(caddr,s_lma);
#if 0 /* @@@ not needed? address must be within memory region */
        if (current_ls) {
          if (current_ls->destmem != defmem) {
            if (current_ls->destmem != current_ls->relocmem) {
              /* warning: address overrides specified LMA memory region */
              error(76,scriptname,getlineno(),'L');
            }
            current_ls->destmem = atdefmem;
          }
        }
#endif
        if (ret)
          ret |= 4;
        if (getchr() != ')') {
          error(66,scriptname,getlineno(),')');  /* ')' expected */
          back(1);
          ret = 0;
        }
      }
      else {
        error(66,scriptname,getlineno(),'(');  /* '(' expected */
        back(1);
        ret = 0;
      }
    }
    else
      error(65,scriptname,getlineno(),buf);  /* unknown keyword ignored */
  }

  if (!startofblock('{'))
    ret = 0;

  return ret;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movl $0x1, 0x44(%rsp)
movq $-0x2, 0x38(%rsp)
cmpq $0x0, 0x2e1ec(%rip)     # 0x449d8
je 0x16802
movq 0x2e1e3(%rip), %rax     # 0x449d8
movq 0x30(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rax
movb $0x0, (%rax)
callq 0x18790
movb %al, 0x2f(%rsp)
movsbl 0x2f(%rsp), %eax
cmpl $0x3a, %eax
je 0x168d6
movsbl 0x2f(%rsp), %eax
cmpl $0x28, %eax
je 0x16858
movl $0x1, %edi
callq 0x18830
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x18a10
movl 0x44(%rsp), %eax
orl $0x2, %eax
movl %eax, 0x44(%rsp)
callq 0x18790
movb %al, 0x2f(%rsp)
movsbl 0x2f(%rsp), %eax
cmpl $0x28, %eax
jne 0x168d4
callq 0x167b0
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x168d2
movq 0x50(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x5060
callq 0x18790
movsbl %al, %eax
cmpl $0x29, %eax
je 0x168c9
movq 0x2e15b(%rip), %rax     # 0x449f0
movq %rax, 0x20(%rsp)
callq 0x18f50
movq 0x20(%rsp), %rsi
movl %eax, %edx
movl $0x42, %edi
movl $0x29, %ecx
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
callq 0x18830
movl $0x0, 0x44(%rsp)
callq 0x18790
movb %al, 0x2f(%rsp)
jmp 0x168d4
jmp 0x168d6
movsbl 0x2f(%rsp), %eax
cmpl $0x3a, %eax
je 0x16920
movq 0x2e109(%rip), %rax     # 0x449f0
movq %rax, 0x18(%rsp)
callq 0x18f50
movq 0x18(%rsp), %rsi
movl %eax, %edx
movl $0x42, %edi
movl $0x3a, %ecx
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
callq 0x18830
movl $0x0, 0x64(%rsp)
jmp 0x16a4b
callq 0x167b0
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x16a2c
movq 0x30(%rsp), %rdi
leaq 0x1ed6f(%rip), %rsi     # 0x356af
callq 0x5130
cmpl $0x0, %eax
jne 0x16a03
callq 0x18790
movsbl %al, %eax
cmpl $0x28, %eax
jne 0x169c6
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x18a10
cmpl $0x0, 0x44(%rsp)
je 0x1697c
movl 0x44(%rsp), %eax
orl $0x4, %eax
movl %eax, 0x44(%rsp)
callq 0x18790
movsbl %al, %eax
cmpl $0x29, %eax
je 0x169c4
movq 0x2e060(%rip), %rax     # 0x449f0
movq %rax, 0x10(%rsp)
callq 0x18f50
movq 0x10(%rsp), %rsi
movl %eax, %edx
movl $0x42, %edi
movl $0x29, %ecx
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
callq 0x18830
movl $0x0, 0x44(%rsp)
jmp 0x16a01
movq 0x2e023(%rip), %rax     # 0x449f0
movq %rax, 0x8(%rsp)
callq 0x18f50
movq 0x8(%rsp), %rsi
movl %eax, %edx
movl $0x42, %edi
movl $0x28, %ecx
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
callq 0x18830
movl $0x0, 0x44(%rsp)
jmp 0x16a2a
movq 0x2dfe6(%rip), %rax     # 0x449f0
movq %rax, (%rsp)
callq 0x18f50
movq (%rsp), %rsi
movl %eax, %edx
movq 0x30(%rsp), %rcx
movl $0x41, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x16a2c
movl $0x7b, %edi
callq 0x17e00
cmpl $0x0, %eax
jne 0x16a43
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)