// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/ldscript.c
// Function: init_ld_script
void init_ld_script(struct GlobalVars *gv)
{
  char c;

  if (!gv->dest_object) {
    scriptbase = gv->ldscript ? gv->ldscript :
                                fff[gv->dest_format]->exeldscript;
  }
  else if (gv->dest_sharedobj) {
    scriptbase = gv->ldscript ? gv->ldscript :
                                fff[gv->dest_format]->soldscript;
  }

  if (scriptbase) {
    bool secdef = FALSE;
    char *keyword;

    /* initialization */
    preparse = TRUE;
    current_ls = NULL;
    level = 0; /* outside SECTIONS block */
    defmem = vdefmem = ldefmem = add_memblock(defmemname,MEM_DEFORG,MEM_DEFLEN);
    atdefmem = add_memblock("lmadefault",MEM_DEFORG,MEM_DEFLEN);
    change_address(defmem,gv->start_addr);
    if (!(scriptname = gv->scriptname))
      scriptname = "built-in script";
    script_obj = make_ld_objunit(gv);

    /* pre-parse script: get memory-regions and symbol definitions */
    init_parser(gv,scriptname,scriptbase,1);

    do {
      while (keyword = getword()) {

        if (!strcmp(keyword,"MEMORY")) {
          gv->use_ldscript = TRUE;
          if (secdef == FALSE) {
            define_memory(gv);
          }
          else {
            /* MEMORY behind SECTIONS ignored */
            error(100,scriptname,getlineno(),keyword);
            skipblock(0,'{','}');
          }
        }

        else if (!strcmp(keyword,"PHDRS")) {
          gv->use_ldscript = TRUE;
          if (secdef == FALSE) {
            define_phdrs(gv);
          }
          else {
            /* PHDRS behind SECTIONS ignored */
            error(100,scriptname,getlineno(),keyword);
            skipblock(0,'{','}');
          }
        }

        else if (!strcmp(keyword,"SECTIONS")) {
          gv->use_ldscript = TRUE;
          if (secdef)
            error(74,scriptname,getlineno());  /* SECTIONS block def. twice */
          else
            secdef = TRUE;

          /* Define default PHDRs */
          if (gv->phdrlist == NULL) {
            add_phdr(gv,deftxt,PT_LOAD,PHDR_FLAGS|PF_X|PF_R,
                     ADDR_NONE,defmem,defmem);
            add_phdr(gv,defdat,PT_LOAD,PHDR_FLAGS|PF_R|PF_W,
                     ADDR_NONE,defmem,defmem);
          }
          level = 1;
          predefine_sections(gv);
          level = 0;
        }

        else {
          if (check_command(gv,keyword,SCMDF_GLOBAL)) {
            /* script-command executed */
            continue;
          }

          else if (getchr() == '=') {
            /* symbol assignment */
            symbol_assignment(gv,keyword,0);
          }

          else {
            /* unknown keyword ignored */
            error(65,scriptname,getlineno(),keyword);
            back(1);
          }
        }
      }
    }
    while ((c = getchr()) == ';');

    if (c) {
      back(1);
      error(78,scriptname,getlineno());   /* missing argument */
    }
    preparse = FALSE;
  }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x16c83
movq 0x50(%rsp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x16c56
movq 0x50(%rsp), %rax
movq 0xc8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x16c75
movq 0x50(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x28dc8(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x2dda7(%rip)     # 0x44a28
jmp 0x16cdd
movq 0x50(%rsp), %rax
cmpl $0x0, 0x58(%rax)
je 0x16cdb
movq 0x50(%rsp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x16cb0
movq 0x50(%rsp), %rax
movq 0xc8(%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0x16ccf
movq 0x50(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x28d6e(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x2dd4d(%rip)     # 0x44a28
jmp 0x16cdd
cmpq $0x0, 0x2dd43(%rip)     # 0x44a28
je 0x1709c
movl $0x0, 0x48(%rsp)
movl $0x1, 0x2dd33(%rip)     # 0x44a30
movq $0x0, 0x2dcd0(%rip) # 0x449d8
movl $0x0, 0x2dcda(%rip)     # 0x449ec
movq 0x2915f(%rip), %rdi     # 0x3fe78
xorl %eax, %eax
movl %eax, %esi
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
callq 0x16b10
movq %rax, 0x2dcdd(%rip)     # 0x44a10
movq %rax, 0x2dcce(%rip)     # 0x44a08
movq %rax, 0x2dcbf(%rip)     # 0x44a00
leaq 0x1ee7b(%rip), %rdi     # 0x35bc3
xorl %eax, %eax
movl %eax, %esi
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
callq 0x16b10
movq %rax, 0x2dcd6(%rip)     # 0x44a38
movq 0x2dc97(%rip), %rdi     # 0x44a00
movq 0x50(%rsp), %rax
movq 0xd8(%rax), %rsi
callq 0x16a60
movq 0x50(%rsp), %rax
movq 0xc0(%rax), %rax
movq %rax, 0x2dc63(%rip)     # 0x449f0
cmpq $0x0, %rax
jne 0x16da1
leaq 0x1ee34(%rip), %rax     # 0x35bce
movq %rax, 0x2dc4f(%rip)     # 0x449f0
movq 0x50(%rsp), %rdi
callq 0x170b0
movq %rax, 0x2dc8e(%rip)     # 0x44a40
movq 0x50(%rsp), %rdi
movq 0x2dc32(%rip), %rsi     # 0x449f0
movq 0x2dc63(%rip), %rdx     # 0x44a28
movl $0x1, %ecx
callq 0x18f60
jmp 0x16dd1
callq 0x167b0
movq %rax, 0x40(%rsp)
cmpq $0x0, %rax
je 0x17046
movq 0x40(%rsp), %rdi
leaq 0x1eded(%rip), %rsi     # 0x35bde
callq 0x5130
cmpl $0x0, %eax
jne 0x16e5c
movq 0x50(%rsp), %rax
movl $0x1, 0x244(%rax)
cmpl $0x0, 0x48(%rsp)
jne 0x16e1d
movq 0x50(%rsp), %rdi
callq 0x17150
jmp 0x16e57
movq 0x2dbcc(%rip), %rax     # 0x449f0
movq %rax, 0x28(%rsp)
callq 0x18f50
movq 0x28(%rsp), %rsi
movl %eax, %edx
movq 0x40(%rsp), %rcx
movl $0x64, %edi
movb $0x0, %al
callq 0x8c00
xorl %edi, %edi
movl $0x7b, %esi
movl $0x7d, %edx
callq 0x187c0
jmp 0x17041
movq 0x40(%rsp), %rdi
leaq 0x1ed7d(%rip), %rsi     # 0x35be5
callq 0x5130
cmpl $0x0, %eax
jne 0x16ed3
movq 0x50(%rsp), %rax
movl $0x1, 0x244(%rax)
cmpl $0x0, 0x48(%rsp)
jne 0x16e94
movq 0x50(%rsp), %rdi
callq 0x17290
jmp 0x16ece
movq 0x2db55(%rip), %rax     # 0x449f0
movq %rax, 0x20(%rsp)
callq 0x18f50
movq 0x20(%rsp), %rsi
movl %eax, %edx
movq 0x40(%rsp), %rcx
movl $0x64, %edi
movb $0x0, %al
callq 0x8c00
xorl %edi, %edi
movl $0x7b, %esi
movl $0x7d, %edx
callq 0x187c0
jmp 0x1703f
movq 0x40(%rsp), %rdi
leaq 0x1dae2(%rip), %rsi     # 0x349c1
callq 0x5130
cmpl $0x0, %eax
jne 0x16fc8
movq 0x50(%rsp), %rax
movl $0x1, 0x244(%rax)
cmpl $0x0, 0x48(%rsp)
je 0x16f29
movq 0x2dae6(%rip), %rax     # 0x449f0
movq %rax, 0x18(%rsp)
callq 0x18f50
movq 0x18(%rsp), %rsi
movl %eax, %edx
movl $0x4a, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x16f31
movl $0x1, 0x48(%rsp)
movq 0x50(%rsp), %rax
cmpq $0x0, 0x1f8(%rax)
jne 0x16fa8
movq 0x50(%rsp), %rdi
movq 0x28f44(%rip), %rsi     # 0x3fe90
movq 0x2daad(%rip), %r9      # 0x44a00
movq 0x2daa6(%rip), %rax     # 0x44a00
movl $0x1, %edx
movl $0x45, %ecx
movq $-0x1, %r8
movq %rax, (%rsp)
callq 0x17660
movq 0x50(%rsp), %rdi
movq 0x28f18(%rip), %rsi     # 0x3fe98
movq 0x2da79(%rip), %r9      # 0x44a00
movq 0x2da72(%rip), %rax     # 0x44a00
movl $0x1, %edx
movl $0x46, %ecx
movq $-0x1, %r8
movq %rax, (%rsp)
callq 0x17660
movl $0x1, 0x2da3a(%rip)     # 0x449ec
movq 0x50(%rsp), %rdi
callq 0x17850
movl $0x0, 0x2da26(%rip)     # 0x449ec
jmp 0x1703d
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl $0x2, %edx
callq 0x14dd0
cmpl $0x0, %eax
je 0x16fe6
jmp 0x16dd1
callq 0x18790
movsbl %al, %eax
cmpl $0x3d, %eax
jne 0x17006
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0x15a10
jmp 0x17039
movq 0x2d9e3(%rip), %rax     # 0x449f0
movq %rax, 0x10(%rsp)
callq 0x18f50
movq 0x10(%rsp), %rsi
movl %eax, %edx
movq 0x40(%rsp), %rcx
movl $0x41, %edi
movb $0x0, %al
callq 0x8c00
movl $0x1, %edi
callq 0x18830
jmp 0x1703b
jmp 0x1703d
jmp 0x1703f
jmp 0x17041
jmp 0x16dd1
jmp 0x17048
callq 0x18790
movb %al, 0x4f(%rsp)
movsbl %al, %eax
cmpl $0x3b, %eax
je 0x16dcf
cmpb $0x0, 0x4f(%rsp)
je 0x17092
movl $0x1, %edi
callq 0x18830
movq 0x2d97b(%rip), %rax     # 0x449f0
movq %rax, 0x8(%rsp)
callq 0x18f50
movq 0x8(%rsp), %rsi
movl %eax, %edx
movl $0x4e, %edi
movb $0x0, %al
callq 0x8c00
movl $0x0, 0x2d994(%rip)     # 0x44a30
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)