// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
cmpl $0x0, 0x54(%rdi)
je 0xec87
cmpl $0x0, 0x58(%rbx)
je 0xecaf
movq 0xc8(%rbx), %rax
testq %rax, %rax
jne 0xeca6
movzbl 0x50(%rbx), %eax
leaq 0x20503(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rax
movq 0x10(%rax), %rax
jmp 0xeca6
movq 0xc8(%rbx), %rax
testq %rax, %rax
jne 0xeca6
movzbl 0x50(%rbx), %eax
leaq 0x204e2(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x249ab(%rip)     # 0x33658
jmp 0xecb6
movq 0x249a2(%rip), %rax     # 0x33658
testq %rax, %rax
je 0xf7ae
movb $0x1, 0x2499a(%rip)     # 0x33660
movq $0x0, 0x24937(%rip) # 0x33608
movl $0x0, 0x24941(%rip)     # 0x3361c
leaq 0x13ed4(%rip), %rdi     # 0x22bb6
movabsq $0x7fffffffffffffff, %r14 # imm = 0x7FFFFFFFFFFFFFFF
xorl %esi, %esi
movq %r14, %rdx
callq 0xeba5
movq %rax, 0x24943(%rip)     # 0x33640
movq %rax, 0x24934(%rip)     # 0x33638
movq %rax, 0x24925(%rip)     # 0x33630
leaq 0x13ea1(%rip), %rdi     # 0x22bb3
xorl %esi, %esi
movq %r14, %rdx
callq 0xeba5
movq %rax, 0x24945(%rip)     # 0x33668
movq 0x24906(%rip), %rdi     # 0x33630
movq 0xd8(%rbx), %rsi
callq 0xeb62
movq 0xc0(%rbx), %rax
testq %rax, %rax
leaq 0x13e77(%rip), %rcx     # 0x22bbe
cmovneq %rax, %rcx
movq %rcx, 0x248ce(%rip)     # 0x33620
leaq 0x13f97(%rip), %rdx     # 0x22cf0
leaq 0x30(%rsp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x5100
movq %r14, %rdi
callq 0x669d
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf37
movq %rax, %r14
testq %rax, %rax
je 0xeda5
orw $0x8001, 0x80(%r14)     # imm = 0x8001
leaq 0x138(%rbx), %rdi
movq %r14, %rsi
callq 0x6713
movq %r14, 0x248c4(%rip)     # 0x33670
movq 0x2486d(%rip), %rsi     # 0x33620
movq 0x2489e(%rip), %rdx     # 0x33658
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x103dc
leaq 0x13e00(%rip), %r14     # 0x22bce
leaq 0x13e00(%rip), %rbp     # 0x22bd5
leaq 0x12bf2(%rip), %r13     # 0x219ce
xorl %r12d, %r12d
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xee52
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x5160
testl %eax, %eax
je 0xee60
movq %r15, %rdi
movq %rbp, %rsi
callq 0x5160
testl %eax, %eax
je 0xee74
movq %r15, %rdi
movq %r13, %rsi
callq 0x5160
testl %eax, %eax
je 0xeeca
movq %rbx, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0xd8ec
testl %eax, %eax
jne 0xeddf
callq 0xfeed
cmpb $0x3d, %al
jne 0xf322
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xe258
jmp 0xeddf
callq 0xfeed
cmpb $0x3b, %al
je 0xeddf
jmp 0xf779
movl $0x1, 0x244(%rbx)
testl %r12d, %r12d
jne 0xee87
jmp 0xf358
movl $0x1, 0x244(%rbx)
testl %r12d, %r12d
je 0xf44d
movq 0x24792(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x64, %edi
movq %r13, %rsi
leaq 0x12b2c(%rip), %r13     # 0x219ce
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6f14
xorl %edi, %edi
movl $0x7b, %esi
movl $0x7d, %edx
callq 0xff0c
movl $0x1, %r12d
jmp 0xeddf
movl $0x1, 0x244(%rbx)
testl %r12d, %r12d
je 0xeef6
movq 0x24740(%rip), %r15     # 0x33620
callq 0x103d5
movl $0x4a, %edi
movq %r15, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
cmpq $0x0, 0x1f8(%rbx)
leaq 0x30(%rsp), %r14
jne 0xef5b
movq 0x24724(%rip), %r9      # 0x33630
movq %r9, (%rsp)
movq %rbx, %rdi
leaq 0x1793e(%rip), %rsi     # 0x26858
movl $0x1, %edx
movl $0x45, %ecx
movq $-0x1, %r8
callq 0xf7c0
movq 0x246f9(%rip), %r9      # 0x33630
movq %r9, (%rsp)
movq %rbx, %rdi
leaq 0x13d7a(%rip), %rsi     # 0x22cbf
movl $0x1, %edx
movl $0x46, %ecx
movq $-0x1, %r8
callq 0xf7c0
movl $0x1, 0x246b7(%rip)     # 0x3361c
movl $0x7b, %edi
callq 0xf8fc
testl %eax, %eax
je 0xf306
callq 0xfe58
callq 0xff5c
movq %rax, 0x246c0(%rip)     # 0x33648
callq 0x103d5
movl %eax, 0x246bd(%rip)     # 0x33650
movq $0x0, 0x10(%rsp)
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xefda
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movl $0x8002, %edx           # imm = 0x8002
callq 0xd8ec
testl %eax, %eax
jne 0xef9c
callq 0xfeed
cmpb $0x3d, %al
jne 0xefe8
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xe258
jmp 0xef9c
callq 0xfeed
cmpb $0x3b, %al
je 0xef9c
jmp 0xf2de
movl $0x1, %edi
callq 0xff51
movq %r15, %rdi
callq 0x669d
movq %rax, %r12
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0xe981
testl %eax, %eax
je 0xf1c3
movl %eax, %r15d
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xc37c
movq %rax, %r14
movl 0x30(%rsp), %eax
movl $0x4f4c4f4e, %ecx       # imm = 0x4F4C4F4E
xorl %ecx, %eax
movl 0x33(%rsp), %ecx
movl $0x44414f, %edx         # imm = 0x44414F
xorl %edx, %ecx
orl %eax, %ecx
movq %r12, 0x8(%rsp)
jne 0xf056
orb $0x1, 0x24(%r14)
cmpl $0x4, %r15d
jb 0xf067
movq 0x24605(%rip), %rax     # 0x33668
movq %rax, 0x28(%r14)
movq 0x18(%r14), %rax
movq %rax, 0x24606(%rip)     # 0x33678
movl $0x2, 0x245a0(%rip)     # 0x3361c
xorl %r12d, %r12d
movl $0x5, %edi
callq 0xff64
testq %rax, %rax
je 0xf0e9
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movl $0x8002, %edx           # imm = 0x8002
callq 0xd8ec
testl %eax, %eax
jne 0xf07f
callq 0xfeed
cmpb $0x3d, %al
je 0xf0f4
movzbl %al, %eax
cmpl $0x28, %eax
je 0xf106
movq 0x24563(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x41, %edi
movq %r13, %rsi
leaq 0x128fd(%rip), %r13     # 0x219ce
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
jmp 0xf07f
callq 0xfeed
cmpb $0x3b, %al
je 0xf07f
jmp 0xf153
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xe258
jmp 0xf07f
testq %r12, %r12
jne 0xf13a
movq 0x2455e(%rip), %rdi     # 0x33670
movq 0x8(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xc0a9
movq %r14, 0x18(%rax)
movq 0x24545(%rip), %rdi     # 0x33670
addq $0x20, %rdi
movq %rax, %r12
movq %rax, %rsi
callq 0x6729
movl $0x1, %edi
movl $0x28, %esi
movl $0x29, %edx
callq 0xff0c
jmp 0xf07f
movl $0x1, %edi
callq 0xff51
movl $0x1, 0x244b5(%rip)     # 0x3361c
movq $0x0, 0x24506(%rip) # 0x33678
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe455
testq %rax, %rax
je 0xf1eb
movq %rax, %r15
cmpq $0x0, 0x30(%r14)
movq 0x10(%rsp), %rcx
jne 0xf19c
movq 0x244a0(%rip), %rax     # 0x33638
movq %rax, 0x30(%r14)
cmpq $0x0, 0x28(%r14)
jne 0xf1ae
movq 0x24496(%rip), %rax     # 0x33640
movq %rax, 0x28(%r14)
movq (%r15), %rax
testq %rax, %rax
jne 0xf1f5
testq %rcx, %rcx
je 0xf1f5
movq %r15, %rdi
movq %rcx, %r15
jmp 0xf20e
movq %r12, %rdi
callq 0x5040
movq 0x2444e(%rip), %r15     # 0x33620
callq 0x103d5
movl $0x41, %edi
movq %r15, %rsi
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6f14
movq 0x10(%rsp), %r12
jmp 0xf2cf
movq %rcx, %r12
testq %rax, %rax
cmovneq %r15, %r12
je 0xf219
testq %rcx, %rcx
je 0xf219
movq %rcx, %rdi
cmpq %rcx, %r15
je 0xf219
callq 0x5040
movq (%r15), %rax
movq %r15, %r12
testq %rax, %rax
je 0xf23d
addq $0x8, %r15
cmpl $0x0, 0x20(%rax)
je 0xf22c
orb $0x10, 0x24(%rax)
movq (%r15), %rax
addq $0x8, %r15
testq %rax, %rax
jne 0xf222
jmp 0xf2cf
movq 0x28(%r14), %r8
movq 0x30(%r14), %rcx
movq 0x243e4(%rip), %rax     # 0x33630
movq %rcx, %rdx
xorq %rax, %rdx
movq %r8, %rsi
xorq %rcx, %rsi
movq %rbx, %rdi
orq %rdx, %rsi
jne 0xf292
leaq 0x175f1(%rip), %rsi     # 0x26858
movl $0x1, %edx
movq %rax, %rcx
movq %rax, %r8
callq 0xfd8f
movq 0x243b2(%rip), %rcx     # 0x33630
movq %rbx, %rdi
leaq 0x13a37(%rip), %rsi     # 0x22cbf
movl $0x1, %edx
movq %rcx, %r8
jmp 0xf29e
leaq 0x13a51(%rip), %rsi     # 0x22cea
movl $0x1, %edx
callq 0xfd8f
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe78d
testw %ax, %ax
je 0xf2cf
movzwl %ax, %edx
movq 0x18(%rsp), %rsi
movq 0x28(%r14), %r8
movq 0x30(%r14), %rcx
movq %rbx, %rdi
callq 0xfd8f
movq %r12, 0x10(%rsp)
leaq 0x30(%rsp), %r14
jmp 0xef9c
movl $0x1, %edi
callq 0xff51
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf2f7
callq 0x5040
movl $0x7b, %edi
movl $0x7d, %esi
callq 0xf9cc
movl $0x0, 0x2430c(%rip)     # 0x3361c
movl $0x1, %r12d
leaq 0x138b1(%rip), %r14     # 0x22bce
jmp 0xeddf
movq 0x242f7(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x41, %edi
movq %r13, %rsi
leaq 0x12691(%rip), %r13     # 0x219ce
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
jmp 0xeddf
movl $0x7b, %edi
callq 0xf8fc
testl %eax, %eax
je 0xeddc
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
leaq 0x30(%rsp), %r12
je 0xf439
movq %r12, %rdi
movq %rax, %rsi
callq 0x5080
callq 0xfeed
cmpb $0x28, %al
jne 0xf3af
movl $0x1, %edi
movl $0x28, %esi
movl $0x29, %edx
callq 0xff0c
callq 0xfeed
cmpb $0x3a, %al
jne 0xf3e7
leaq 0x13949(%rip), %rdi     # 0x22d03
callq 0xfccf
movq %rax, %r15
callq 0xfeed
cmpb $0x2c, %al
jne 0xf404
leaq 0x13938(%rip), %rdi     # 0x22d0a
callq 0xfccf
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xeba5
jmp 0xf426
movq 0x24232(%rip), %r15     # 0x33620
callq 0x103d5
movl $0x42, %edi
movq %r15, %rsi
movl %eax, %edx
movl $0x3a, %ecx
jmp 0xf41f
movq 0x24215(%rip), %r15     # 0x33620
callq 0x103d5
movl $0x42, %edi
movq %r15, %rsi
movl %eax, %edx
movl $0x2c, %ecx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
jne 0xf382
movl $0x7b, %edi
movl $0x7d, %esi
callq 0xf9cc
jmp 0xeddc
movl $0x7b, %edi
callq 0xf8fc
testl %eax, %eax
je 0xeddc
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
leaq 0x30(%rsp), %r12
je 0xf702
movq %r12, %rdi
movq %rax, %rsi
callq 0x5080
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xf4fe
movq %rax, %r15
cmpb $0x50, (%rax)
jne 0xf4d5
cmpb $0x54, 0x1(%r15)
jne 0xf4d5
cmpb $0x5f, 0x2(%r15)
jne 0xf4d5
movzbl 0x3(%r15), %eax
leal -0x49(%rax), %ecx
cmpl $0xa, %ecx
ja 0xf544
leaq 0x135d1(%rip), %rdx     # 0x22a90
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x3, 0x8(%rsp)
jmp 0xf5aa
movq 0x24144(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x63, %edi
movq %r13, %rsi
leaq 0x124de(%rip), %r13     # 0x219ce
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6f14
jmp 0xf51b
movq 0x2411b(%rip), %r15     # 0x33620
callq 0x103d5
movl $0x4e, %edi
movq %r15, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
xorl %esi, %esi
movl $0x3b, %edx
callq 0xff0c
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
jne 0xf477
jmp 0xf702
cmpl $0x44, %eax
jne 0xf553
movl $0x2, 0x8(%rsp)
jmp 0xf5aa
movq 0x240c6(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x0, 0x8(%rsp)
movl $0x63, %edi
movq %r13, %rsi
leaq 0x12458(%rip), %r13     # 0x219ce
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6f14
jmp 0xf5aa
movl $0x5, 0x8(%rsp)
jmp 0xf5aa
movl $0x4, 0x8(%rsp)
jmp 0xf5aa
movl $0x1, 0x8(%rsp)
jmp 0xf5aa
movl $0x6, 0x8(%rsp)
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xf68a
movq %rax, %r15
movq $-0x1, 0x10(%rsp)
xorl %r12d, %r12d
movq %r15, %rdi
leaq 0x1373b(%rip), %rsi     # 0x22d11
callq 0x5160
testl %eax, %eax
je 0xf63e
movq %r15, %rdi
movq %rbp, %rsi
callq 0x5160
testl %eax, %eax
je 0xf647
cmpb $0x41, (%r15)
jne 0xf602
cmpb $0x54, 0x1(%r15)
jne 0xf602
cmpb $0x0, 0x2(%r15)
je 0xf661
movq %r15, %rdi
leaq 0x1370d(%rip), %rsi     # 0x22d19
callq 0x5160
testl %eax, %eax
je 0xf650
movq 0x24004(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x41, %edi
movq %r13, %rsi
leaq 0x1239e(%rip), %r13     # 0x219ce
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6f14
jmp 0xf672
orl $0x800, %r12d           # imm = 0x800
jmp 0xf672
orl $0x400, %r12d           # imm = 0x400
jmp 0xf672
callq 0xfa2a
andl $0x7, %eax
orl %eax, %r12d
orl $0x40, %r12d
jmp 0xf672
callq 0xfa2a
movq %rax, 0x10(%rsp)
orl $0x80, %r12d
movl $0x1, %edi
callq 0xff64
movq %rax, %r15
testq %rax, %rax
jne 0xf5cc
jmp 0xf696
movq $-0x1, 0x10(%rsp)
xorl %r12d, %r12d
callq 0xfeed
cmpb $0x3b, %al
je 0xf6d5
movl %eax, %r15d
movq 0x23f77(%rip), %r13     # 0x33620
callq 0x103d5
movl $0x42, %edi
movq %r13, %rsi
leaq 0x12311(%rip), %r13     # 0x219ce
movl %eax, %edx
movl $0x3b, %ecx
xorl %eax, %eax
callq 0x6f14
cmpb $0x7d, %r15b
je 0xeddc
movq $0x0, (%rsp)
movzwl %r12w, %ecx
movq %rbx, %rdi
leaq 0x30(%rsp), %r12
movq %r12, %rsi
movl 0x8(%rsp), %edx
movq 0x10(%rsp), %r8
xorl %r9d, %r9d
callq 0xf7c0
jmp 0xf52c
movl $0x7b, %edi
movl $0x7d, %esi
callq 0xf9cc
movq 0x1f8(%rbx), %rax
testq %rax, %rax
je 0xeddc
xorl %ecx, %ecx
cmpl $0x6, 0x20(%rax)
je 0xeddc
testb $0x4, 0x25(%rax)
movl $0x1, %edx
cmovnel %edx, %ecx
movq (%rax), %rax
testq %rax, %rax
jne 0xf723
testl %ecx, %ecx
je 0xeddc
movq 0x23ee0(%rip), %r9      # 0x33630
movq %r9, (%rsp)
movq %rbx, %rdi
leaq 0x1347d(%rip), %rsi     # 0x22bdb
movl $0x6, %edx
movl $0x400, %ecx            # imm = 0x400
movq $-0x1, %r8
callq 0xf7c0
jmp 0xeddc
movzbl %al, %eax
testl %eax, %eax
je 0xf7a7
movl $0x1, %edi
callq 0xff51
movq 0x23e8f(%rip), %rbx     # 0x33620
callq 0x103d5
movl $0x4e, %edi
movq %rbx, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
movb $0x0, 0x23eb2(%rip)     # 0x33660
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq