// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/ldscript.c
// Function: parse_pattern
static bool parse_pattern(struct GlobalVars *gv,char *keyword,
                          char **fpat,char ***spatlist)
/* parse file/section-pattern and allocate pattern-lists */
{
  const char *sortcmd = "SORT";
  char *patternlist[64];   /* yes... it's ugly :| */
  int pcnt = 0;
  bool sortsec;

  gv->scriptflags &= ~(LDSF_KEEP | LDSF_SORTFIL | LDSF_SORTSEC);
  if (!strcmp(keyword,"KEEP")) {
    if (keyword = getpattern()) {
      if (getchr() != '(') {
        error(66,scriptname,getlineno(),'(');  /* '(' expected */
        back(1);
        return FALSE;
      }
    }
    else {
      error(78,scriptname,getlineno());   /* missing argument */
      return FALSE;
    }
    gv->scriptflags |= LDSF_KEEP;
  }

  if (!strcmp(keyword,sortcmd)) {
    if (keyword = getpattern()) {
      if (getchr() != '(') {
        error(66,scriptname,getlineno(),'(');  /* '(' expected */
        back(1);
        return FALSE;
      }
    }
    else {
      error(78,scriptname,getlineno());   /* missing argument */
      return FALSE;
    }
    gv->scriptflags |= LDSF_SORTFIL;
  }
  *fpat = alloc(strlen(keyword)+1);
  strcpy(*fpat,keyword);
  if (gv->scriptflags & LDSF_SORTFIL) {
    if (!endofblock('(',')')) {
      free(*fpat);
      return FALSE;
    }
  }

  while (keyword = getpattern()) {
    sortsec = FALSE;
    if (!strcmp(keyword,sortcmd)) {
      if (getchr() == '(') {
        if (!(keyword = getpattern())) {
          error(78,scriptname,getlineno());   /* missing argument */
          free(*fpat);
          return FALSE;
        }
      }
      else {
        error(66,scriptname,getlineno(),'(');  /* '(' expected */
        back(1);
        free(*fpat);
        return FALSE;
      }
      if (!endofblock('(',')')) {
        free(*fpat);
        return FALSE;
      }
      gv->scriptflags |= LDSF_SORTSEC;
      sortsec = TRUE;
    }

    if (pcnt < 63) {
      patternlist[pcnt] = alloc(strlen(keyword) + (sortsec ? 2 : 1));
      if (sortsec) {
        *patternlist[pcnt] = '$';   /* indicate sort-request */
        strcpy(patternlist[pcnt]+1,keyword);
      }
      else
        strcpy(patternlist[pcnt],keyword);
      pcnt++;
    }
    else
      ierror("parse_pattern(): pattern buffer overrun");
  }

  patternlist[pcnt++] = NULL;
  *spatlist = alloc(pcnt * sizeof(char *));
  memcpy(*spatlist,patternlist,pcnt*sizeof(char *));

  if (!endofblock('(',')')) {
    free_patterns(*fpat,*spatlist);
    return FALSE;
  }
  if (gv->scriptflags & LDSF_KEEP) {
    if (!endofblock('(',')')) {
      free_patterns(*fpat,*spatlist);
      return FALSE;
    }
  }
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
andb $-0x8, 0x248(%rdi)
leaq 0x15194(%rip), %rsi     # 0x22be9
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0xdba6
leaq 0x15178(%rip), %rsi     # 0x22be4
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0xdbce
movq %r12, %rdi
callq 0x50e0
leaq 0x1(%rax), %rdi
callq 0x6638
movq %rax, (%rbx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x5080
testb $0x2, 0x248(%r15)
je 0xdabc
movl $0x28, %edi
movl $0x29, %esi
callq 0xf9cc
testl %eax, %eax
je 0xdce2
movq %r14, 0x8(%rsp)
movq %rbx, (%rsp)
movl $0x5, %edi
callq 0xff64
testq %rax, %rax
je 0xdc4d
movq %rax, %rbp
leaq 0x15102(%rip), %r12     # 0x22be4
xorl %ebx, %ebx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5160
movl %eax, %r14d
testl %eax, %eax
jne 0xdb38
callq 0xfeed
cmpb $0x28, %al
jne 0xdce7
movl $0x5, %edi
callq 0xff64
testq %rax, %rax
je 0xdd17
movq %rax, %rbp
movl $0x28, %edi
movl $0x29, %esi
callq 0xf9cc
testl %eax, %eax
je 0xdd44
orb $0x4, 0x248(%r15)
cmpl $0x3e, %ebx
jg 0xdb7d
xorl %r13d, %r13d
testl %r14d, %r14d
sete %r13b
movq %rbp, %rdi
callq 0x50e0
leaq (%rax,%r13), %rdi
incq %rdi
callq 0x6638
movslq %ebx, %rcx
movq %rax, 0x10(%rsp,%rcx,8)
testl %r14d, %r14d
jne 0xdb6e
movb $0x24, (%rax)
incq %rax
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5080
incl %ebx
jmp 0xdb8b
leaq 0x1506a(%rip), %rdi     # 0x22bee
xorl %eax, %eax
callq 0x52b0
movl $0x5, %edi
callq 0xff64
movq %rax, %rbp
testq %rax, %rax
jne 0xdae4
jmp 0xdc4f
movl $0x5, %edi
callq 0xff64
testq %rax, %rax
je 0xdbf6
movq %rax, %r12
callq 0xfeed
cmpb $0x28, %al
jne 0xdc1a
orb $0x1, 0x248(%r15)
jmp 0xda65
movl $0x5, %edi
callq 0xff64
testq %rax, %rax
je 0xdbf6
movq %rax, %r12
callq 0xfeed
cmpb $0x28, %al
jne 0xdc1a
orb $0x2, 0x248(%r15)
jmp 0xda7c
movq 0x25a23(%rip), %rbx     # 0x33620
callq 0x103d5
xorl %ebp, %ebp
movl $0x4e, %edi
movq %rbx, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
jmp 0xdd52
movq 0x259ff(%rip), %rbx     # 0x33620
callq 0x103d5
xorl %ebp, %ebp
movl $0x42, %edi
movq %rbx, %rsi
movl %eax, %edx
movl $0x28, %ecx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
jmp 0xdd52
xorl %ebx, %ebx
movslq %ebx, %rax
movq $0x0, 0x10(%rsp,%rax,8)
leaq 0x8(,%rax,8), %r14
movq %r14, %rdi
callq 0x6638
movq 0x8(%rsp), %rbx
movq %rax, (%rbx)
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x51a0
movl $0x28, %edi
movl $0x29, %esi
callq 0xf9cc
testl %eax, %eax
je 0xdcd1
movl $0x1, %ebp
testb $0x1, 0x248(%r15)
je 0xdd52
movl $0x28, %edi
movl $0x29, %esi
callq 0xf9cc
testl %eax, %eax
jne 0xdd52
movq (%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movq (%rax), %rsi
jmp 0xdcdb
movq (%rsp), %rax
movq (%rax), %rdi
movq (%rbx), %rsi
callq 0xd784
jmp 0xdd50
movq (%rbx), %rdi
jmp 0xdd4b
movq 0x25932(%rip), %r14     # 0x33620
callq 0x103d5
xorl %ebp, %ebp
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x28, %ecx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
jmp 0xdd36
movq 0x25902(%rip), %r14     # 0x33620
callq 0x103d5
xorl %ebp, %ebp
movl $0x4e, %edi
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6f14
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x5040
jmp 0xdd52
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x5040
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq