// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/ldscript.c
// Function: predefine_sections
static void predefine_sections(struct GlobalVars *gv)
/* Syntax: */
/* <secname> [addr] [(type)] : [AT(lma)] { ... } */
/*           [>region] [AT>lma-region] [:PHDR ...] [=FillExp] */
{
  char *keyword;
  struct Phdr **defplist = NULL;

  if (!startofblock('{'))
    return;
  skip();
  secblkbase = gettxtptr();
  secblkline = getlineno();

  do {
    while (keyword = getword()) {
      if (check_command(gv,keyword,SCMDF_GLOBAL|SCMDF_IGNORE)) {
        continue;
      }
      else if (getchr() == '=') {
        symbol_assignment(gv,keyword,0);
      }

      else {
        /* check for section definition */
        struct LinkedSection *ls;
        struct Section *dummy_sec;
        struct Phdr **plist;
        const char *s_name;
        char c,s_type[MAXLEN];
        lword s_addr,s_lma;
        int fl;

        back(1);
        s_name = allocstring(keyword);

        if (fl = startofsecdef(&s_addr,s_type,&s_lma)) {
          dummy_sec = NULL;
          ls = create_lnksect(gv,s_name,ST_UNDEFINED,0,0,0);
          if (!strcmp(s_type,"NOLOAD"))
            ls->ld_flags |= LSF_NOLOAD;
          if (fl & 4)
            ls->destmem = atdefmem;  /* AT(addr) in section definition */

          new_ls_name = ls->name;
          level = 2;
          do {
            while (keyword = getpattern()) {
              if (check_command(gv,keyword,SCMDF_GLOBAL|SCMDF_IGNORE)) {
                continue;
              }
              else {
                c = getchr();
                if (c == '=') {
                  symbol_assignment(gv,keyword,0);
                }
                else if (c == '(') {
                  /* skip section pattern */
                  #if DUMMY_SEC_FROM_PATTERN
                  if (!dummy_sec)
                    dummy_sec = make_dummy_sec_from_pattern(gv);
                  #else
                  if (!dummy_sec) {
                    dummy_sec = create_section(script_obj,s_name,NULL,0);
                    dummy_sec->lnksec = ls;  /* assign to ls */
                    addtail(&script_obj->sections,&dummy_sec->n);
                  }
                  #endif
                  skipblock(1,'(',')');
                }
                else {
                  /* unknown keyword ignored */
                  error(65,scriptname,getlineno(),keyword);
                  back(1);
                }
              }
            }
          }
          while (getchr() == ';');
          back(1);
          level = 1;
          new_ls_name = NULL;

          if (plist = endofsecdef(gv,ls)) {
            /* check segment assignments */
            struct Phdr *p;

            /* set default memory region when needed */
            if (ls->relocmem == NULL)
              ls->relocmem = vdefmem;
            if (ls->destmem == NULL)
              ls->destmem = ldefmem;

            if (*plist==NULL && defplist!=NULL) {
              /* use last PHDR assignments, when none given */
              free(plist);
              plist = defplist;
            }
            if (*plist!=NULL && plist!=defplist) {
              if (defplist)
                free(defplist);
              defplist = plist;
            }

            if (*plist) {
              while (p = *plist++) {
                if (p->type != PT_NULL)
                  p->flags |= PHDR_USED;
              }
            }
            else {
              /* no PHDR assignment - select segment by memory region */
              const char *pname;
              uint32_t type;

              if (ls->relocmem==defmem && ls->destmem==defmem) {
                use_segment(gv,deftxt,PT_LOAD,defmem,defmem);
                use_segment(gv,defdat,PT_LOAD,defmem,defmem);
              }
              else
                use_segment(gv,defload,PT_LOAD,ls->relocmem,ls->destmem);

              /* check other segments (interp, dynamic, note) */
              if (type = guess_special_segment(s_name,&pname))
                use_segment(gv,pname,type,ls->relocmem,ls->destmem);
            }
          }
        }
        else {
          free((void *)s_name);
          error(65,scriptname,getlineno(),s_name); /* unknown keyword ignored */
        }
      }
    }
  }
  while (getchr() == ';');
  back(1);

  if (defplist)
    free(defplist);
  endofblock('{','}');
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x180(%rsp)
movq $0x0, 0x170(%rsp)
movl $0x7b, %edi
callq 0x17e00
cmpl $0x0, %eax
jne 0x1787f
jmp 0x17df6
callq 0x18610
callq 0x18860
movq %rax, 0x2d188(%rip)     # 0x44a18
callq 0x18f50
movl %eax, 0x2d185(%rip)     # 0x44a20
jmp 0x1789d
callq 0x167b0
movq %rax, 0x178(%rsp)
cmpq $0x0, %rax
je 0x17db2
movq 0x180(%rsp), %rdi
movq 0x178(%rsp), %rsi
movl $0x8002, %edx           # imm = 0x8002
callq 0x14dd0
cmpl $0x0, %eax
je 0x178d5
jmp 0x1789d
callq 0x18790
movsbl %al, %eax
cmpl $0x3d, %eax
jne 0x178fe
movq 0x180(%rsp), %rdi
movq 0x178(%rsp), %rsi
xorl %edx, %edx
callq 0x15a10
jmp 0x17dab
movl $0x1, %edi
callq 0x18830
movq 0x178(%rsp), %rdi
callq 0x72d0
movq %rax, 0x150(%rsp)
leaq 0x40(%rsp), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x167c0
movl %eax, 0x2c(%rsp)
cmpl $0x0, %eax
je 0x17d72
movq $0x0, 0x160(%rsp)
movq 0x180(%rsp), %rdi
movq 0x150(%rsp), %rsi
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x12a60
movq %rax, 0x168(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x1e3bd(%rip), %rsi     # 0x35d3c
callq 0x5130
cmpl $0x0, %eax
jne 0x1799c
movq 0x168(%rsp), %rax
movzwl 0x24(%rax), %ecx
orl $0x1, %ecx
movw %cx, 0x24(%rax)
movl 0x2c(%rsp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x179bb
movq 0x2d089(%rip), %rcx     # 0x44a38
movq 0x168(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x168(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x2d07a(%rip)     # 0x44a48
movl $0x2, 0x2d014(%rip)     # 0x449ec
jmp 0x179da
callq 0x14dc0
movq %rax, 0x178(%rsp)
cmpq $0x0, %rax
je 0x17b03
movq 0x180(%rsp), %rdi
movq 0x178(%rsp), %rsi
movl $0x8002, %edx           # imm = 0x8002
callq 0x14dd0
cmpl $0x0, %eax
je 0x17a12
jmp 0x179da
callq 0x18790
movb %al, 0x14f(%rsp)
movsbl 0x14f(%rsp), %eax
cmpl $0x3d, %eax
jne 0x17a47
movq 0x180(%rsp), %rdi
movq 0x178(%rsp), %rsi
xorl %edx, %edx
callq 0x15a10
jmp 0x17afc
movsbl 0x14f(%rsp), %eax
cmpl $0x28, %eax
jne 0x17ac4
cmpq $0x0, 0x160(%rsp)
jne 0x17aae
movq 0x2cfda(%rip), %rdi     # 0x44a40
movq 0x150(%rsp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x125b0
movq %rax, 0x160(%rsp)
movq 0x168(%rsp), %rcx
movq 0x160(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x2cfa3(%rip), %rdi     # 0x44a40
addq $0x20, %rdi
movq 0x160(%rsp), %rsi
callq 0x7470
movl $0x1, %edi
movl $0x28, %esi
movl $0x29, %edx
callq 0x187c0
jmp 0x17afa
movq 0x2cf25(%rip), %rax     # 0x449f0
movq %rax, 0x8(%rsp)
callq 0x18f50
movq 0x8(%rsp), %rsi
movl %eax, %edx
movq 0x178(%rsp), %rcx
movl $0x41, %edi
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
callq 0x18830
jmp 0x17afc
jmp 0x17afe
jmp 0x179da
jmp 0x17b05
callq 0x18790
movsbl %al, %eax
cmpl $0x3b, %eax
je 0x179d8
movl $0x1, %edi
callq 0x18830
movl $0x1, 0x2cec2(%rip)     # 0x449ec
movq $0x0, 0x2cf13(%rip) # 0x44a48
movq 0x180(%rsp), %rdi
movq 0x168(%rsp), %rsi
callq 0x15d20
movq %rax, 0x158(%rsp)
cmpq $0x0, %rax
je 0x17d70
movq 0x168(%rsp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x17b7e
movq 0x2ce96(%rip), %rcx     # 0x44a08
movq 0x168(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x168(%rsp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x17ba0
movq 0x2ce7c(%rip), %rcx     # 0x44a10
movq 0x168(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x158(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x17bd6
cmpq $0x0, 0x170(%rsp)
je 0x17bd6
movq 0x158(%rsp), %rdi
callq 0x5030
movq 0x170(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rax
cmpq $0x0, (%rax)
je 0x17c1e
movq 0x158(%rsp), %rax
cmpq 0x170(%rsp), %rax
je 0x17c1e
cmpq $0x0, 0x170(%rsp)
je 0x17c0e
movq 0x170(%rsp), %rdi
callq 0x5030
movq 0x158(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x158(%rsp), %rax
cmpq $0x0, (%rax)
je 0x17c75
jmp 0x17c2e
movq 0x158(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x158(%rsp)
movq (%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x17c70
movq 0x20(%rsp), %rax
cmpl $0x0, 0x20(%rax)
je 0x17c6e
movq 0x20(%rsp), %rax
movzwl 0x24(%rax), %ecx
orl $0x10, %ecx
movw %cx, 0x24(%rax)
jmp 0x17c2e
jmp 0x17d6e
movq 0x168(%rsp), %rax
movq 0x30(%rax), %rax
cmpq 0x2cd78(%rip), %rax     # 0x44a00
jne 0x17cef
movq 0x168(%rsp), %rax
movq 0x28(%rax), %rax
cmpq 0x2cd63(%rip), %rax     # 0x44a00
jne 0x17cef
movq 0x180(%rsp), %rdi
movq 0x281e2(%rip), %rsi     # 0x3fe90
movq 0x2cd4b(%rip), %rcx     # 0x44a00
movq 0x2cd44(%rip), %r8      # 0x44a00
movl $0x1, %edx
callq 0x184d0
movq 0x180(%rsp), %rdi
movq 0x281c3(%rip), %rsi     # 0x3fe98
movq 0x2cd24(%rip), %rcx     # 0x44a00
movq 0x2cd1d(%rip), %r8      # 0x44a00
movl $0x1, %edx
callq 0x184d0
jmp 0x17d20
movq 0x180(%rsp), %rdi
movq 0x281a2(%rip), %rsi     # 0x3fea0
movq 0x168(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x168(%rsp), %rax
movq 0x28(%rax), %r8
movl $0x1, %edx
callq 0x184d0
movq 0x150(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x161c0
movzwl %ax, %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, %eax
je 0x17d6c
movq 0x180(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x14(%rsp), %edx
movq 0x168(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x168(%rsp), %rax
movq 0x28(%rax), %r8
callq 0x184d0
jmp 0x17d6e
jmp 0x17d70
jmp 0x17da9
movq 0x150(%rsp), %rdi
callq 0x5030
movq 0x2cc6a(%rip), %rax     # 0x449f0
movq %rax, (%rsp)
callq 0x18f50
movq (%rsp), %rsi
movl %eax, %edx
movq 0x150(%rsp), %rcx
movl $0x41, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x17dab
jmp 0x17dad
jmp 0x1789d
jmp 0x17db4
callq 0x18790
movsbl %al, %eax
cmpl $0x3b, %eax
je 0x1789b
movl $0x1, %edi
callq 0x18830
cmpq $0x0, 0x170(%rsp)
je 0x17de7
movq 0x170(%rsp), %rdi
callq 0x5030
movl $0x7b, %edi
movl $0x7d, %esi
callq 0x17f10
addq $0x188, %rsp            # imm = 0x188
retq
nop