// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdi, %r14
leaq 0x20(%rdi), %r15
leaq 0x130(%rdi), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%r14), %rbx
testq %rbx, %rbx
je 0xd12b
movq 0x10(%r14), %rax
cmpq $0x3c, %rax
jb 0xd12b
addq $-0x3c, %rax
movq %rax, 0x10(%r14)
movb $0x0, 0x20(%r14)
leaq 0x30(%rbx), %rdi
leaq 0x15b40(%rip), %rsi     # 0x22a54
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x51e0
movb (%rbx), %bpl
cmpb $0x2f, %bpl
jne 0xcf2f
cmpb $0x20, 0x1(%rbx)
je 0xcf4a
movl $0xa, %edx
movq %rbx, %rdi
leaq 0x15b1a(%rip), %rsi     # 0x22a58
callq 0x5070
movb $0x1, %r12b
testl %eax, %eax
jne 0xcf4d
xorl %r12d, %r12d
leaq 0x3c(%rbx), %r13
movl $0xc, %edx
movq %rbx, %rdi
leaq 0x15b03(%rip), %rsi     # 0x22a63
callq 0x5070
testl %eax, %eax
je 0xcf7b
cmpb $0x2f, %bpl
jne 0xcf87
cmpb $0x2f, 0x1(%rbx)
jne 0xcf87
cmpb $0x20, 0x2(%rbx)
jne 0xcf87
movq %r13, 0x18(%r14)
movb (%rbx), %bpl
xorl %r12d, %r12d
jmp 0xcf8e
cmpq $0x0, 0x18(%r14)
je 0xcffb
cmpb $0x2f, %bpl
je 0xcf9d
movzbl %bpl, %eax
cmpl $0x20, %eax
jne 0xcffb
movb 0x1(%rbx), %al
addb $-0x30, %al
cmpb $0x9, %al
ja 0xcffb
leaq 0x1(%rbx), %rdi
leaq 0x16575(%rip), %rsi     # 0x23526
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x51e0
movslq 0x4(%rsp), %rcx
addq 0x18(%r14), %rcx
xorl %eax, %eax
movzbl (%rcx,%rax), %edx
cmpq $0x2f, %rdx
ja 0xcfe2
movabsq $0x800000000401, %rsi   # imm = 0x800000000401
btq %rdx, %rsi
jb 0xcff0
movb %dl, (%r15,%rax)
incq %rax
cmpl $0xff, %eax
jne 0xcfc8
addq %r15, %rax
movb $0x0, (%rax)
jmp 0xd0bf
cmpb $0x23, %bpl
jne 0xd07e
cmpb $0x31, 0x1(%rbx)
jne 0xd07e
cmpb $0x2f, 0x2(%rbx)
jne 0xd07e
leaq 0x3(%rbx), %rdi
leaq 0x1650e(%rip), %rsi     # 0x23526
movq %rsp, %rdx
xorl %eax, %eax
callq 0x51e0
movl (%rsp), %eax
movslq %eax, %rbp
cmpq %rbp, 0x10(%r14)
jae 0xd046
movq (%r14), %rsi
movl $0x25, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6f14
movl (%rsp), %eax
movslq %eax, %rbp
movl $0xff, %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
movslq %eax, %rdx
movq %rdx, 0x8(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x51a0
movq 0x8(%rsp), %rax
movb $0x0, 0x20(%r14,%rax)
subq %rbp, 0x130(%r14)
addq %rbp, %r13
subq %rbp, 0x10(%r14)
jmp 0xd0bf
leaq 0xf(%rbx), %rcx
movl $0x10, %eax
movb (%rcx), %dl
cmpb $0x20, %dl
jne 0xd09f
leal -0x1(%rax), %edx
decq %rcx
cmpl $0x1, %eax
movl %edx, %eax
ja 0xd087
xorl %ebp, %ebp
jmp 0xd0ac
xorl %ecx, %ecx
cmpb $0x2f, %dl
sete %cl
subl %ecx, %eax
movslq %eax, %rbp
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x51a0
movb $0x0, (%r15,%rbp)
cmpb $0x60, 0x3a(%rbx)
jne 0xd0cb
cmpb $0xa, 0x3b(%rbx)
je 0xd0dd
movq (%r14), %rsi
movl $0x2a, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6f14
movq %rbx, 0x120(%r14)
movq %r13, 0x128(%r14)
movq 0x130(%r14), %rax
leal (%rax,%r13), %ecx
andl $0x1, %ecx
addq %rax, %rcx
addq %rcx, %r13
movq %r13, 0x8(%r14)
subq %rcx, 0x10(%r14)
jns 0xd11b
movq (%r14), %rsi
movl $0x25, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6f14
testb %r12b, %r12b
je 0xcee1
movl $0x1, %eax
jmp 0xd12d
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq