// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/ldscript.c
// Function: next_pattern
int next_pattern(struct GlobalVars *gv,char **fpat,char ***spatlist)
/* Returns next file-pattern and a list of section-patterns, when present */
{
  static char *fn = "next_pattern(): ";
  static struct Phdr **defplist=NULL;
  struct Phdr **plist;
  char c,*keyword;

  level = 2;
  *fpat = NULL;
  *spatlist = NULL;
  if (secdefbase) {
    /* reset to beginning of section definition */
    init_parser(gv,scriptname,secdefbase,secdefline);
    secdefbase = NULL;
  }

  do {
    while (keyword = getpattern()) {
      if (check_command(gv,keyword,SCMDF_GLOBAL|SCMDF_SECDEF)) {
        continue;
      }
      else {
        c = getchr();
        if (c == '=') {
          symbol_assignment(gv,keyword,0);
        }
        else if (c == '(') {
          if (parse_pattern(gv,keyword,fpat,spatlist))
            return 1;
        }
        else
          back(1);
      }
    }
  }
  while (getchr() == ';');
  back(1);

  level = 1;
  if (plist = endofsecdef(gv,NULL)) {
    struct Phdr *guess_plist[3];

    if (*plist == NULL) {
      free(plist);
      if (!defplist) {
        /* No PHDR specification available, so we have to guess:
           In this default mode there are two PT_LOAD-segments
           available: text(non-writable,executable) and data(read-write).
           Dynamic, Interp and Note segments will be recognized by name */
        static char *phdr_miss_err = "%sPHDR %s missing";
        const char *pname;

        plist = guess_plist;

        if (!(current_ls->flags & SF_ALLOC)) {
          plist[0] = NULL;  /* not part of any segment */
        }

        else if (current_ls->relocmem==defmem &&
                 current_ls->destmem==defmem) {

          if (current_ls->type==ST_CODE ||
              (current_ls->protection & SP_EXEC) ||
              !(current_ls->protection & SP_WRITE)) {
            if (!(plist[0] = find_phdr(gv,deftxt,defmem,defmem)))
              ierror(phdr_miss_err,fn,deftxt);
            if (plist[0]->flags & PHDR_CLOSED) {
              if (!(plist[0] = find_phdr(gv,defdat,defmem,defmem)))
                ierror(phdr_miss_err,fn,defdat);
            }
          }
          else {
            if (!(plist[0] = find_phdr(gv,defdat,defmem,defmem)))
              ierror(phdr_miss_err,fn,defdat);
          }

          if (guess_special_segment(current_ls->name,&pname)) {
            if (!(plist[1] = find_phdr(gv,pname,defmem,defmem)))
              ierror(phdr_miss_err,fn,pname);
            plist[2] = NULL;
          }
          else
            plist[1] = NULL;
        }

        else {
          if (!(plist[0] = find_phdr(gv,defload,current_ls->relocmem,
                                     current_ls->destmem)))
            ierror(phdr_miss_err,fn,defload);

          if (guess_special_segment(current_ls->name,&pname)) {
            if (!(plist[1] = find_phdr(gv,pname,current_ls->relocmem,
                                       current_ls->destmem)))
              ierror(phdr_miss_err,fn,pname);
            plist[2] = NULL;
          }
          else
            plist[1] = NULL;
        }

      }
      else
        plist = defplist;
    }
    else {
      if (defplist)
        free(defplist);
      defplist = plist;
    }

    /* at this point there is at least one PHDR reference in the list */
    add_section_to_segments(gv,current_ls,plist);
  }

  vdefmem = current_ls->relocmem;
  ldefmem = current_ls->destmem;
  current_ls = NULL;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl $0x2, 0x25766(%rip)     # 0x3361c
xorl %eax, %eax
movq %rax, (%rsi)
movq %rax, (%rdx)
movq 0x2574b(%rip), %rdx     # 0x33610
testq %rdx, %rdx
je 0xdeea
movq 0x2574f(%rip), %rsi     # 0x33620
movl 0x25741(%rip), %ecx     # 0x33618
movq %rbx, %rdi
callq 0x1056a
movq $0x0, 0x25726(%rip) # 0x33610
movl $0x5, %edi
callq 0x100e6
testq %rax, %rax
je 0xdf67
movq %rax, %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq 0xda00
testl %eax, %eax
je 0xdf24
movl $0x5, %edi
callq 0x100e6
movq %rax, %r12
testq %rax, %rax
jne 0xdefc
jmp 0xdf67
callq 0x1006f
cmpb $0x28, %al
je 0xdf44
movzbl %al, %eax
cmpl $0x3d, %eax
jne 0xdf5b
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xe363
jmp 0xdf10
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xdb59
testl %eax, %eax
je 0xdf10
jmp 0xdfc4
movl $0x1, %edi
callq 0x100d3
jmp 0xdf10
callq 0x1006f
cmpb $0x3b, %al
je 0xdeea
movl $0x1, %edi
callq 0x100d3
movl $0x1, 0x25694(%rip)     # 0x3361c
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe568
testq %rax, %rax
je 0xe329
movq %rax, %r14
cmpq $0x0, (%rax)
je 0xdfcf
movq 0x2567a(%rip), %rdi     # 0x33628
testq %rdi, %rdi
je 0xdfb8
callq 0x5040
movq %r14, 0x25669(%rip)     # 0x33628
jmp 0xe18e
movl $0x1, %r12d
jmp 0xe351
movq %r14, %rdi
callq 0x5040
movq 0x2564a(%rip), %r14     # 0x33628
testq %r14, %r14
jne 0xe18e
movq 0x2561a(%rip), %rax     # 0x33608
testb $0x1, 0x21(%rax)
jne 0xe002
movq $0x0, 0x10(%rsp)
jmp 0xe189
movq 0x30(%rax), %rdx
movq 0x25623(%rip), %rcx     # 0x33630
cmpq %rcx, %rdx
jne 0xe01c
cmpq %rcx, 0x28(%rax)
je 0xe0bb
movq 0x28(%rax), %rcx
leaq 0x14ce2(%rip), %rsi     # 0x22d09
movq %rbx, %rdi
callq 0xe871
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0xe055
leaq 0x14b50(%rip), %rdi     # 0x22b90
leaq 0x14b38(%rip), %rsi     # 0x22b7f
leaq 0x14cbb(%rip), %rdx     # 0x22d09
xorl %eax, %eax
callq 0x52b0
movq 0x255ac(%rip), %r14     # 0x33608
movq 0x18(%r14), %rdi
leaq 0x28(%rsp), %rsi
callq 0xe8c3
testw %ax, %ax
je 0xe180
movq 0x28(%rsp), %r15
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe871
movq %rax, 0x18(%rsp)
testq %rax, %rax
jne 0xe0ad
leaq 0x14af4(%rip), %rdi     # 0x22b90
leaq 0x14adc(%rip), %rsi     # 0x22b7f
movq %r15, %rdx
xorl %eax, %eax
callq 0x52b0
movq $0x0, 0x20(%rsp)
jmp 0xe189
cmpb $0x1, 0x20(%rax)
je 0xe0ca
movb 0x22(%rax), %al
andb $0x6, %al
cmpb $0x2, %al
je 0xe114
leaq 0x187a7(%rip), %rsi     # 0x26878
movq %rbx, %rdi
movq %rcx, %rdx
callq 0xe871
movq %rax, %r15
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0xe105
leaq 0x14aa0(%rip), %rdi     # 0x22b90
leaq 0x14a88(%rip), %rsi     # 0x22b7f
leaq 0x1877a(%rip), %rdx     # 0x26878
xorl %eax, %eax
callq 0x52b0
cmpw $0x0, 0x24(%r15)
jns 0xe14c
movq 0x2551c(%rip), %rcx     # 0x33630
leaq 0x14bc3(%rip), %rsi     # 0x22cde
movq %rbx, %rdi
movq %rcx, %rdx
callq 0xe871
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0xe14c
leaq 0x14a59(%rip), %rdi     # 0x22b90
leaq 0x14a41(%rip), %rsi     # 0x22b7f
leaq 0x14b99(%rip), %rdx     # 0x22cde
xorl %eax, %eax
callq 0x52b0
movq 0x254b5(%rip), %rax     # 0x33608
movq 0x18(%rax), %rdi
leaq 0x28(%rsp), %rsi
callq 0xe8c3
testw %ax, %ax
je 0xe180
movq 0x28(%rsp), %r15
movq 0x254be(%rip), %rcx     # 0x33630
movq %rbx, %rdi
movq %r15, %rsi
movq %rcx, %rdx
jmp 0xe086
movq $0x0, 0x18(%rsp)
leaq 0x10(%rsp), %r14
movq 0x25473(%rip), %r13     # 0x33608
testb $0x1, 0x21(%r13)
je 0xe329
cmpb $0x0, 0x20(%r13)
je 0xe329
movq %r14, 0x30(%rsp)
movq (%r14), %r14
testq %r14, %r14
je 0xe2e6
leaq 0x1f8(%rbx), %rbp
movq 0x30(%rsp), %r15
movl $0x0, 0xc(%rsp)
cmpw $0x0, 0x24(%r14)
js 0xe219
cmpl $0x1, 0x20(%r14)
jne 0xe244
cmpl $0x0, 0xc(%rsp)
je 0xe23c
movq 0x25433(%rip), %r12     # 0x33620
callq 0x10563
movq 0x18(%r13), %rcx
movl $0x50, %edi
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f84
andb $-0x11, 0x24(%r14)
movl $0x1, 0xc(%rsp)
jmp 0xe2d6
movq 0x25400(%rip), %r12     # 0x33620
callq 0x10563
movq 0x8(%r14), %rcx
movl $0x4b, %edi
movq %r12, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f84
jmp 0xe293
movl $0x1, 0xc(%rsp)
cmpq $-0x1, 0x30(%r14)
jne 0xe257
movq 0x38(%r13), %rax
movq %rax, 0x38(%r14)
movq %rax, 0x30(%r14)
cmpq $-0x1, 0x28(%r14)
jne 0xe266
movq 0x40(%r13), %rax
movq %rax, 0x28(%r14)
movq 0x38(%r13), %rax
movq 0x48(%r13), %rcx
addq %rax, %rcx
movq %rcx, 0x40(%r14)
movq 0x50(%r13), %rcx
testq %rcx, %rcx
je 0xe285
addq %rax, %rcx
movq %rcx, 0x38(%r14)
movb 0x23(%r13), %al
cmpb 0x26(%r14), %al
jbe 0xe293
movb %al, 0x26(%r14)
movq (%rbp), %rax
cmpq %r14, %rax
je 0xe2b1
testq %rax, %rax
je 0xe2b8
cmpq %r14, (%rax)
jne 0xe2ac
movq (%r14), %rcx
movq %rcx, (%rax)
movq (%rax), %rax
jmp 0xe29c
movq (%r14), %rax
movq %rax, (%rbp)
movq (%rbp), %rax
movq %rbp, %rcx
testq %rax, %rax
je 0xe2cc
movq %rax, %rcx
movq (%rax), %rax
jmp 0xe2bf
movq %r14, (%rcx)
movq $0x0, (%r14)
addq $0x8, %r15
movq (%r15), %r14
testq %r14, %r14
jne 0xe1d0
movq 0x1f8(%rbx), %rax
testq %rax, %rax
movl $0x0, %r12d
movq 0x30(%rsp), %rsi
je 0xe329
movq %rsi, %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
je 0xe311
addq $0x8, %rcx
cmpq %rdx, %rax
jne 0xe300
testq %rdx, %rdx
jne 0xe321
cmpq $-0x1, 0x30(%rax)
je 0xe321
orb $-0x80, 0x25(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0xe2fd
movq 0x252d8(%rip), %rax     # 0x33608
movq 0x30(%rax), %rcx
movq %rcx, 0x252fd(%rip)     # 0x33638
movq 0x28(%rax), %rax
movq %rax, 0x252fa(%rip)     # 0x33640
movq $0x0, 0x252b7(%rip) # 0x33608
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq