// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/ar.c
// Function: ar_extract
bool ar_extract(struct ar_info *ai)
/* fill ar_info structure with informations about the next */
/* archive member */
{
  struct ar_hdr *ah;
  uint8_t *p;
  bool cont;
  unsigned long size;

  do {
    cont = FALSE;
    if (ai->next==NULL || ai->arlen<sizeof(struct ar_hdr))
      return FALSE;  /* archive ends here */

    ah = ai->next;
    p = ((uint8_t *)ah) + sizeof(struct ar_hdr);
    ai->arlen -= sizeof(struct ar_hdr);
    ai->name[0] = 0;
    sscanf(ah->ar_size,"%lu",&ai->size);  /* file size */

    if (!strncmp(ah->ar_name,"/ ",2) ||             /* GNU symbol table */
        !strncmp(ah->ar_name,"__.SYMDEF ",10))      /* BSD symbol table */
      cont = TRUE;

    if (!strncmp(ah->ar_name,"ARFILENAMES/",12) ||  /* GNU long names 1 */
        !strncmp(ah->ar_name,"// ",3)) {            /* GNU long names 2 */
      ai->long_names = p;
      cont = TRUE;
    }

    if (ai->long_names &&                           /* long name (GNU) */
        (ah->ar_name[0]=='/' || ah->ar_name[0]==' ') &&
        (ah->ar_name[1]>='0' && ah->ar_name[1]<='9')) {
      int i,offset;
      char c,*s,*d=ai->name;

      sscanf(&ah->ar_name[1],"%d",&offset);  /* name offset */
      s = ai->long_names + offset;
      for (i=0; i<MAXARNAME; i++) {
        c = *s++;
        if (c==0 || c=='/' || c=='\n')
          break;
        *d++ = c;
      }
      *d = 0;
    }
    else if (!strncmp(ah->ar_name,"#1/",3)) {  /* ext. name fmt. #1 (BSD) */
      int d,len;

      sscanf(&ah->ar_name[3],"%d",&d);  /* ext.fmt. name length */
      if (d > ai->arlen)
        error(37,ai->arname,ai->name);  /* Malformatted archive member */
      len = (d>MAXARNAME) ? MAXARNAME : d;
      memcpy(ai->name,p,len);
      ai->name[len] = 0;
      p += d;  /* set real beginning of file and size */
      ai->size -= d;
      ai->arlen -= d;
    }
    else {  /* normal file name < 16 chars */
      char *n = &ah->ar_name[16];
      int len;

      for (len=16; len>0; len--)
        if (*(--n) != ' ')
          break;
      if (len && *n=='/')  /* GNU */
        --len;
      memcpy(ai->name,ah->ar_name,len);
      ai->name[len] = 0;
    }

    if (strncmp(ah->ar_fmag,ARFMAG,2))
      error(42,ai->arname,ai->name);  /* consistency check failed */
    ai->header = ah;
    ai->data = p;
    size = ((unsigned long)(p + ai->size) & 1) ? (ai->size+1) : ai->size;
    ai->next = (struct ar_hdr *)(p + size);
    if ((long)(ai->arlen -= size) < 0)
      error(37,ai->arname,ai->name);  /* Malformatted archive member */
  }
  while (cont);
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
leaq 0x20(%rdi), %r15
leaq 0x130(%rdi), %r12
movq %r15, 0x20(%rsp)
movq %r12, 0x18(%rsp)
movq 0x8(%r14), %rbp
testq %rbp, %rbp
je 0xd22b
movq 0x10(%r14), %rax
cmpq $0x3c, %rax
jb 0xd22b
addq $-0x3c, %rax
movq %rax, 0x10(%r14)
movb $0x0, 0x20(%r14)
leaq 0x30(%rbp), %rdi
leaq 0x15a96(%rip), %rsi     # 0x22a64
movq %r12, %rdx
xorl %eax, %eax
callq 0x51e0
movl $0x2, %edx
movq %rbp, %rdi
leaq 0x15a9a(%rip), %rsi     # 0x22a81
callq 0x5070
testl %eax, %eax
je 0xd00b
movl $0xa, %edx
movq %rbp, %rdi
leaq 0x15a69(%rip), %rsi     # 0x22a68
callq 0x5070
xorl %r13d, %r13d
testl %eax, %eax
jne 0xd011
movl $0x1, %r13d
leaq 0x3c(%rbp), %rbx
movl $0xc, %edx
movq %rbp, %rdi
leaq 0x15a4f(%rip), %rsi     # 0x22a73
callq 0x5070
testl %eax, %eax
je 0xd045
movl $0x3, %edx
movq %rbp, %rdi
leaq 0x15a44(%rip), %rsi     # 0x22a80
callq 0x5070
testl %eax, %eax
jne 0xd04f
movq %rbx, 0x18(%r14)
movl $0x1, %r13d
cmpq $0x0, 0x18(%r14)
je 0xd0c2
movzbl (%rbp), %eax
cmpl $0x2f, %eax
je 0xd064
cmpl $0x20, %eax
jne 0xd0c2
movb 0x1(%rbp), %al
addb $-0x30, %al
cmpb $0x9, %al
ja 0xd0c2
leaq 0x1(%rbp), %rdi
leaq 0x164ce(%rip), %rsi     # 0x23546
leaq 0x14(%rsp), %rdx
xorl %eax, %eax
callq 0x51e0
movslq 0x14(%rsp), %rcx
addq 0x18(%r14), %rcx
xorl %eax, %eax
movzbl (%rcx,%rax), %edx
cmpq $0x2f, %rdx
ja 0xd0a9
movabsq $0x800000000401, %rsi   # imm = 0x800000000401
btq %rdx, %rsi
jb 0xd0b7
movb %dl, (%r15,%rax)
incq %rax
cmpl $0xff, %eax
jne 0xd08f
addq %r15, %rax
movb $0x0, (%rax)
jmp 0xd1b3
movl $0x3, %edx
movq %rbp, %rdi
leaq 0x159b3(%rip), %rsi     # 0x22a84
callq 0x5070
testl %eax, %eax
je 0xd0fd
leaq 0xf(%rbp), %rcx
movl $0x11, %eax
cmpb $0x20, (%rcx)
jne 0xd178
decl %eax
decq %rcx
cmpl $0x1, %eax
ja 0xd0e3
xorl %eax, %eax
movq %rbp, %rcx
jmp 0xd17a
movl %r13d, 0x10(%rsp)
leaq 0x3(%rbp), %rdi
leaq 0x16439(%rip), %rsi     # 0x23546
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x51e0
movslq 0xc(%rsp), %rax
cmpq %rax, 0x10(%r14)
jae 0xd136
movq (%r14), %rsi
movl $0x25, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6f84
movslq 0xc(%rsp), %r12
movl $0xff, %eax
cmpl %eax, %r12d
cmovll %r12d, %eax
movslq %eax, %r13
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x51a0
movb $0x0, 0x20(%r14,%r13)
subq %r12, 0x130(%r14)
addq %r12, %rbx
subq %r12, 0x10(%r14)
movq 0x18(%rsp), %r12
movl 0x10(%rsp), %r13d
jmp 0xd1b3
decl %eax
movl %r13d, %r12d
testl %eax, %eax
je 0xd190
xorl %edx, %edx
cmpb $0x2f, (%rcx)
sete %dl
subl %edx, %eax
movslq %eax, %r13
jmp 0xd193
xorl %r13d, %r13d
movq 0x20(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x51a0
movb $0x0, (%r15,%r13)
movl %r12d, %r13d
movq 0x18(%rsp), %r12
leaq 0x3a(%rbp), %rdi
movl $0x2, %edx
leaq 0x158c5(%rip), %rsi     # 0x22a88
callq 0x5070
testl %eax, %eax
je 0xd1de
movq (%r14), %rsi
movl $0x2a, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6f84
movq %rbp, 0x120(%r14)
movq %rbx, 0x128(%r14)
movq 0x130(%r14), %rax
leal (%rax,%rbx), %ecx
andl $0x1, %ecx
addq %rax, %rcx
addq %rcx, %rbx
movq %rbx, 0x8(%r14)
subq %rcx, 0x10(%r14)
jns 0xd21b
movq (%r14), %rsi
movl $0x25, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6f84
testl %r13d, %r13d
jne 0xcf9b
movl $0x1, %eax
jmp 0xd22d
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq