// File: /workspace/github_c_makefile_star2_O3/thegenemyers[P]DASCRUBBER/DB.c
// Function: Open_QVs
int Open_QVs(DAZZ_DB *db)
{ FILE        *quiva, *istub, *indx;
  char        *root;
  uint16      *table;
  DAZZ_QV     *qvtrk;
  QVcoding    *coding, *nx;
  int          ncodes = 0;

  if (db->tracks != NULL && db->tracks->name == qtrack_name)
    return (0);

  if (db->trimmed)
    { EPRINTF(EPLACE,"%s: Cannot load QVs after trimming the DB\n",Prog_Name);
      EXIT(1);
    }

  if (db->reads[db->nreads-1].coff < 0)
    { if (db->part > 0)
        { EPRINTF(EPLACE,"%s: All QVs for this block have not been added to the DB!\n",Prog_Name);
          EXIT(1);
        }
      else
        { EPRINTF(EPLACE,"%s: All QVs for this DB have not been added!\n",Prog_Name);
          EXIT(1);
        }
    }

  //  Open .qvs, .idx, and .db files

  quiva = Fopen(MyCatenate(db->path,"","",".qvs"),"r");
  if (quiva == NULL)
    return (-1);

  istub  = NULL;
  indx   = NULL; 
  table  = NULL;
  coding = NULL;
  qvtrk  = NULL;

  root = rindex(db->path,'/');
  if (root[1] == '.')
    { *root = '\0';
      istub = Fopen(MyCatenate(db->path,"/",root+2,".db"),"r");
      *root = '/';
    }
  else
    istub = Fopen(MyCatenate(db->path,"","",".db"),"r");
  if (istub == NULL)
    goto error;

  { int   first, last, nfiles;
    char  prolog[MAX_NAME], fname[MAX_NAME];
    int   i, j;

    if (fscanf(istub,DB_NFILE,&nfiles) != 1)
      { EPRINTF(EPLACE,"%s: Stub file (.db) of %s is junk\n",Prog_Name,root);
        goto error;
      }

    if (db->part > 0)
      { int       pfirst, plast;
        int       fbeg, fend;
        int       n, k;
        FILE     *indx;

        //  Determine first how many and which files span the block (fbeg to fend)

        pfirst = db->ufirst;
        plast  = pfirst + db->nreads;

        first = 0;
        for (fbeg = 0; fbeg < nfiles; fbeg++)
          { if (fscanf(istub,DB_FDATA,&last,fname,prolog) != 3)
              { EPRINTF(EPLACE,"%s: Stub file (.db) of %s is junk\n",Prog_Name,root);
                goto error;
              }
            if (last > pfirst)
              break;
            first = last;
          }
        for (fend = fbeg+1; fend <= nfiles; fend++)
          { if (last >= plast)
              break;
            if (fscanf(istub,DB_FDATA,&last,fname,prolog) != 3)
              { EPRINTF(EPLACE,"%s: Stub file (.db) of %s is junk\n",Prog_Name,root);
                goto error;
              }
            first = last;
          }

        indx   = Fopen(MyCatenate(db->path,"","",".idx"),"r");
        ncodes = fend-fbeg;
        coding = (QVcoding *) Malloc(sizeof(QVcoding)*ncodes,"Allocating coding schemes");
        table  = (uint16 *) Malloc(sizeof(uint16)*db->nreads,"Allocating QV table indices");
        if (indx == NULL || coding == NULL || table == NULL)
          { ncodes = 0;
            goto error;
          }

        //  Carefully get the first coding scheme (its offset is most likely in a DAZZ_RECORD
        //    in .idx that is *not* in memory).  Get all the other coding schemes normally and
        //    assign the tables # for each read in the block in "tables".

        rewind(istub);
        (void) fscanf(istub,DB_NFILE,&nfiles);

        first = 0;
        for (n = 0; n < fbeg; n++)
          { (void) fscanf(istub,DB_FDATA,&last,fname,prolog);
            first = last;
          }

        for (n = fbeg; n < fend; n++)
          { (void) fscanf(istub,DB_FDATA,&last,fname,prolog);

            i = n-fbeg;
            if (first < pfirst)
              { DAZZ_READ read;

                fseeko(indx,sizeof(DAZZ_DB) + sizeof(DAZZ_READ)*first,SEEK_SET);
                if (fread(&read,sizeof(DAZZ_READ),1,indx) != 1)
                  { EPRINTF(EPLACE,"%s: Index file (.idx) of %s is junk\n",Prog_Name,root);
                    ncodes = i;
                    goto error;
                  }
                fseeko(quiva,read.coff,SEEK_SET);
                nx = Read_QVcoding(quiva);
                if (nx == NULL)
                  { ncodes = i;
                    goto error;
                  }
                coding[i] = *nx;
              }
            else
              { fseeko(quiva,db->reads[first-pfirst].coff,SEEK_SET);
                nx = Read_QVcoding(quiva);
                if (nx == NULL)
                  { ncodes = i;
                    goto error;
                  }
                coding[i] = *nx;
                db->reads[first-pfirst].coff = ftello(quiva);
              }

            j = first-pfirst;
            if (j < 0)
              j = 0;
            k = last-pfirst;
            if (k > db->nreads)
              k = db->nreads;
            while (j < k)
              table[j++] = (uint16) i;

            first = last;
	  }

        fclose(indx);
        indx = NULL;
      }

    else
      { //  Load in coding scheme for each file, adjust .coff of first read in the file, and
        //    record which table each read uses

        ncodes = nfiles;
        coding = (QVcoding *) Malloc(sizeof(QVcoding)*nfiles,"Allocating coding schemes");
        table  = (uint16 *) Malloc(sizeof(uint16)*db->nreads,"Allocating QV table indices");
        if (coding == NULL || table == NULL)
          goto error;
  
        first = 0;
        for (i = 0; i < nfiles; i++)
          { if (fscanf(istub,DB_FDATA,&last,fname,prolog) != 3)
              { EPRINTF(EPLACE,"%s: Stub file (.db) of %s is junk\n",Prog_Name,root);
                goto error;
              }
  
            fseeko(quiva,db->reads[first].coff,SEEK_SET);
            nx = Read_QVcoding(quiva);
            if (nx == NULL)
              { ncodes = i;
                goto error;
              }
            coding[i] = *nx;
	    db->reads[first].coff = ftello(quiva);

            for (j = first; j < last; j++)
              table[j] = (uint16) i;

            first = last;
          }
      }

    //  Allocate and fill in the DAZZ_QV record and add it to the front of the
    //    track list

    qvtrk = (DAZZ_QV *) Malloc(sizeof(DAZZ_QV),"Allocating QV pseudo-track");
    if (qvtrk == NULL)
      goto error;
    qvtrk->name   = qtrack_name;
    if (qvtrk->name == NULL)
      goto error;
    qvtrk->next   = db->tracks;
    db->tracks    = (DAZZ_TRACK *) qvtrk;
    qvtrk->ncodes = ncodes;
    qvtrk->table  = table;
    qvtrk->coding = coding;
    qvtrk->quiva  = quiva;
  }

  fclose(istub);
  return (0);

error:
  if (qvtrk != NULL)
    free(qvtrk);
  if (table != NULL)
    free(table);
  if (coding != NULL)
    { int i;
      for (i = 0; i < ncodes; i++)
        Free_QVcoding(coding+i);
      free(coding);
    }
  if (indx != NULL)
    fclose(indx);
  if (istub != NULL)
    fclose(istub);
  fclose(quiva);
  EXIT(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4eb8, %rsp           # imm = 0x4EB8
movq %rdi, %rbx
movq 0x68(%rdi), %rax
testq %rax, %rax
je 0x695a
leaq 0x4d13(%rip), %rcx      # 0xb663
cmpq %rcx, 0x8(%rax)
je 0x747e
cmpl $0x0, 0x34(%rbx)
jne 0x7544
movq 0x60(%rbx), %rax
movslq 0x30(%rbx), %rcx
leaq (%rcx,%rcx,4), %rcx
cmpq $0x0, -0x10(%rax,%rcx,8)
js 0x7549
movq 0x48(%rbx), %rdi
leaq 0x5033(%rip), %rdx      # 0xb9ba
leaq 0x53b6(%rip), %rcx      # 0xbd44
movq %rdx, %rsi
callq 0x427d
leaq 0x5414(%rip), %rsi      # 0xbdb1
movq %rax, %rdi
callq 0x2c15
testq %rax, %rax
je 0x6a09
movq %rbx, %r14
movq %rax, %rbp
movq 0x48(%rbx), %rbx
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x1250
movq %rax, %r15
cmpb $0x2e, 0x1(%rax)
movq %r14, 0x20(%rsp)
jne 0x6a13
movb $0x0, (%r15)
movq 0x48(%r14), %rdi
movq %r15, %rdx
addq $0x2, %rdx
leaq 0x4b09(%rip), %rsi      # 0xb4ee
leaq 0x4afe(%rip), %rcx      # 0xb4ea
callq 0x427d
leaq 0x53b9(%rip), %rsi      # 0xbdb1
movq %rax, %rdi
callq 0x2c15
movq %rax, %r12
movb $0x2f, (%r15)
jmp 0x6a3e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7480
leaq 0x4fa0(%rip), %rdx      # 0xb9ba
leaq 0x4ac9(%rip), %rcx      # 0xb4ea
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x427d
leaq 0x537e(%rip), %rsi      # 0xbdb1
movq %rax, %rdi
callq 0x2c15
movq %rax, %r12
testq %r12, %r12
je 0x74bc
leaq 0x4a0b(%rip), %rsi      # 0xb459
leaq 0x4(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x7492
movq 0x20(%rsp), %rbx
cmpl $0x0, 0x38(%rbx)
movq %rbp, 0x8(%rsp)
movq %r12, 0x10(%rsp)
jle 0x6af3
movq %r15, 0x38(%rsp)
movl 0x3c(%rbx), %eax
movl 0x30(%rbx), %r12d
movl %eax, 0x30(%rsp)
addl %eax, %r12d
cmpl $0x0, 0x4(%rsp)
jle 0x6e97
leaq 0x49c6(%rip), %rbx      # 0xb466
movq %rsp, %r14
leaq 0x90(%rsp), %r15
leaq 0x27a0(%rsp), %rbp
xorl %r13d, %r13d
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x1090
cmpl $0x3, %eax
jne 0x6efc
movl 0x30(%rsp), %eax
cmpl %eax, (%rsp)
jg 0x6e9a
incl %r13d
cmpl 0x4(%rsp), %r13d
jl 0x6ab6
jmp 0x6e9a
movslq 0x4(%rsp), %r14
movq %r14, %rax
shlq $0x3, %rax
leaq (%rax,%rax,8), %rdi
leaq 0x523f(%rip), %rsi      # 0xbd49
callq 0x2af5
movq %rax, %r13
movslq 0x30(%rbx), %rdi
addq %rdi, %rdi
leaq 0x5243(%rip), %rsi      # 0xbd63
callq 0x2af5
movq %r13, 0x28(%rsp)
testq %r13, %r13
movq %rax, 0x40(%rsp)
je 0x74f6
testq %rax, %rax
je 0x74f6
cmpl $0x0, 0x4(%rsp)
jle 0x7427
movq %r14, 0x18(%rsp)
movq %r15, 0x38(%rsp)
addq $0xe, %rax
movq %rax, 0x30(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x20(%rsp), %rbx
movq 0x8(%rsp), %rbp
movq %r12, %rdi
leaq 0x48ed(%rip), %rsi      # 0xb466
movq %rsp, %rdx
leaq 0x90(%rsp), %rcx
leaq 0x27a0(%rsp), %r8
xorl %eax, %eax
callq 0x1090
cmpl $0x3, %eax
jne 0x74ce
movq 0x60(%rbx), %rax
movslq %r15d, %r13
leaq (,%r13,4), %r12
addq %r13, %r12
movq 0x18(%rax,%r12,8), %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x1230
movq %rbp, %rdi
callq 0x8c1b
testq %rax, %rax
je 0x7538
leaq (%r14,%r14,8), %rcx
movq 0x28(%rsp), %rdx
leaq (%rdx,%rcx,8), %rdi
movl $0x9, %ecx
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbp, %rdi
callq 0x1080
movq 0x60(%rbx), %rcx
movq %rax, 0x18(%rcx,%r12,8)
movl (%rsp), %eax
cmpl %eax, %r15d
movq 0x10(%rsp), %r12
movdqa 0x4676(%rip), %xmm7     # 0xb280
movdqa 0x467d(%rip), %xmm8     # 0xb290
movdqa 0x4684(%rip), %xmm9     # 0xb2a0
movdqa 0x462b(%rip), %xmm10    # 0xb250
movdqa 0x4632(%rip), %xmm11    # 0xb260
pcmpeqd %xmm12, %xmm12
jge 0x6e7e
movslq %eax, %rdx
subq %r13, %rdx
leaq 0x7(%rdx), %rcx
andq $-0x8, %rcx
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq 0x30(%rsp), %rdx
leaq (%rdx,%r13,2), %rdx
pxor %xmm11, %xmm0
xorl %esi, %esi
movq %rsi, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por %xmm10, %xmm2
pxor %xmm11, %xmm2
movdqa %xmm2, %xmm4
pcmpgtd %xmm0, %xmm4
pshufd $0xa0, %xmm4, %xmm3     # xmm3 = xmm4[0,0,2,2]
pshuflw $0xe8, %xmm3, %xmm5     # xmm5 = xmm3[0,2,2,3,4,5,6,7]
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pshuflw $0xe8, %xmm2, %xmm6     # xmm6 = xmm2[0,2,2,3,4,5,6,7]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pshuflw $0xe8, %xmm4, %xmm5     # xmm5 = xmm4[0,2,2,3,4,5,6,7]
por %xmm6, %xmm5
pxor %xmm12, %xmm5
packssdw %xmm5, %xmm5
movd %xmm5, %edi
testb $0x1, %dil
je 0x6cc7
movw %r14w, -0xe(%rdx,%rsi,2)
pand %xmm3, %xmm2
por %xmm4, %xmm2
packssdw %xmm2, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm2
movd %xmm2, %edi
shrl $0x10, %edi
testb $0x1, %dil
je 0x6cef
movw %r14w, -0xc(%rdx,%rsi,2)
movdqa %xmm1, %xmm3
por %xmm9, %xmm3
pxor %xmm11, %xmm3
movdqa %xmm3, %xmm4
pcmpgtd %xmm0, %xmm4
pshufd $0xa0, %xmm4, %xmm2     # xmm2 = xmm4[0,0,2,2]
pcmpeqd %xmm0, %xmm3
pshufd $0xf5, %xmm3, %xmm3     # xmm3 = xmm3[1,1,3,3]
movdqa %xmm3, %xmm5
pand %xmm2, %xmm5
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
por %xmm4, %xmm5
packssdw %xmm5, %xmm5
pxor %xmm12, %xmm5
packssdw %xmm5, %xmm5
pextrw $0x2, %xmm5, %edi
testb $0x1, %dil
je 0x6d42
movw %r14w, -0xa(%rdx,%rsi,2)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm3, %xmm3     # xmm3 = xmm3[0,1,2,3,4,5,4,6]
pand %xmm2, %xmm3
pshufhw $0x84, %xmm4, %xmm2     # xmm2 = xmm4[0,1,2,3,4,5,4,6]
por %xmm3, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm2
pextrw $0x3, %xmm2, %edi
testb $0x1, %dil
je 0x6d73
movw %r14w, -0x8(%rdx,%rsi,2)
movdqa %xmm1, %xmm2
por %xmm8, %xmm2
pxor %xmm11, %xmm2
movdqa %xmm2, %xmm4
pcmpgtd %xmm0, %xmm4
pshufd $0xa0, %xmm4, %xmm3     # xmm3 = xmm4[0,0,2,2]
pshuflw $0xe8, %xmm3, %xmm5     # xmm5 = xmm3[0,2,2,3,4,5,6,7]
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pshuflw $0xe8, %xmm2, %xmm6     # xmm6 = xmm2[0,2,2,3,4,5,6,7]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pshuflw $0xe8, %xmm4, %xmm5     # xmm5 = xmm4[0,2,2,3,4,5,6,7]
por %xmm6, %xmm5
pxor %xmm12, %xmm5
packssdw %xmm5, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0x6dcd
movw %r14w, -0x6(%rdx,%rsi,2)
pand %xmm3, %xmm2
por %xmm4, %xmm2
packssdw %xmm2, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm2
pextrw $0x5, %xmm2, %edi
testb $0x1, %dil
je 0x6df3
movw %r14w, -0x4(%rdx,%rsi,2)
por %xmm7, %xmm1
pxor %xmm11, %xmm1
movdqa %xmm1, %xmm3
pcmpgtd %xmm0, %xmm3
pshufd $0xa0, %xmm3, %xmm2     # xmm2 = xmm3[0,0,2,2]
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
movdqa %xmm1, %xmm4
pand %xmm2, %xmm4
pshufd $0xf5, %xmm3, %xmm3     # xmm3 = xmm3[1,1,3,3]
por %xmm3, %xmm4
packssdw %xmm4, %xmm4
pxor %xmm12, %xmm4
packssdw %xmm4, %xmm4
pextrw $0x6, %xmm4, %edi
testb $0x1, %dil
je 0x6e41
movw %r14w, -0x2(%rdx,%rsi,2)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm1, %xmm1     # xmm1 = xmm1[0,1,2,3,4,5,4,6]
pand %xmm2, %xmm1
pshufhw $0x84, %xmm3, %xmm2     # xmm2 = xmm3[0,1,2,3,4,5,4,6]
por %xmm1, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm1
pextrw $0x7, %xmm1, %edi
testb $0x1, %dil
je 0x6e71
movw %r14w, (%rdx,%rsi,2)
addq $0x8, %rsi
cmpq %rsi, %rcx
jne 0x6c64
incq %r14
movslq 0x4(%rsp), %rcx
movl %eax, %r15d
cmpq %rcx, %r14
jl 0x6b6f
jmp 0x741d
xorl %r13d, %r13d
movl %r13d, %r14d
movl $0x1, %eax
movq %rax, 0x18(%rsp)
movq %rsp, %r15
leaq 0x90(%rsp), %rbp
leaq 0x27a0(%rsp), %rbx
movq %r14, 0x48(%rsp)
cmpl 0x4(%rsp), %r14d
jge 0x6f2f
cmpl %r12d, (%rsp)
jge 0x6f2f
movq 0x10(%rsp), %rdi
leaq 0x458e(%rip), %rsi      # 0xb466
movq %r15, %rdx
movq %rbp, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x1090
incq %r14
movq 0x18(%rsp), %rcx
incl %ecx
movq %rcx, 0x18(%rsp)
cmpl $0x3, %eax
je 0x6ebf
movq 0x90f5(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0xb9db(%rip), %rdx      # 0x128e8
leaq 0x4666(%rip), %rsi      # 0xb57a
movq 0x38(%rsp), %rcx
xorl %eax, %eax
callq 0x11a0
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %r12
jmp 0x74b4
movq 0x20(%rsp), %rbx
movq 0x48(%rbx), %rdi
leaq 0x4a7b(%rip), %rdx      # 0xb9ba
leaq 0x460a(%rip), %rcx      # 0xb550
movq %rdx, %rsi
callq 0x427d
leaq 0x4e5c(%rip), %rsi      # 0xbdb1
movq %rax, %rdi
callq 0x2c15
movq %rax, %r12
movslq 0x18(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,8), %rdi
leaq 0x4dd5(%rip), %rsi      # 0xbd49
callq 0x2af5
movq %rax, %r15
movslq 0x30(%rbx), %rdi
addq %rdi, %rdi
leaq 0x4dd9(%rip), %rsi      # 0xbd63
callq 0x2af5
movq %r12, 0x50(%rsp)
testq %r12, %r12
movq %r15, 0x28(%rsp)
movq %rax, 0x40(%rsp)
je 0x7589
testq %r15, %r15
movq 0x10(%rsp), %r12
je 0x757c
testq %rax, %rax
je 0x757c
movq %r12, %rdi
callq 0x1110
leaq 0x448c(%rip), %rsi      # 0xb459
xorl %ebp, %ebp
leaq 0x4(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
testl %r13d, %r13d
je 0x7018
leaq 0x90(%rsp), %rbx
leaq 0x27a0(%rsp), %rbp
movl %r13d, %r15d
movq %r12, %rdi
leaq 0x4466(%rip), %rsi      # 0xb466
movq %rsp, %rdx
movq %rbx, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x1090
decl %r15d
jne 0x6ff6
movl (%rsp), %ebp
cmpl %r14d, %r13d
movq 0x48(%rsp), %r15
ja 0x7413
movslq %r13d, %rax
movq %rax, 0x60(%rsp)
incq %r14
movq 0x40(%rsp), %rax
addq $0xe, %rax
movq %rax, 0x58(%rsp)
movq %r12, %rdi
leaq 0x441d(%rip), %rsi      # 0xb466
movq %rsp, %rdx
leaq 0x90(%rsp), %rcx
leaq 0x27a0(%rsp), %r8
xorl %eax, %eax
callq 0x1090
movq %r15, 0x48(%rsp)
subq 0x60(%rsp), %r15
movl %ebp, %r13d
subl 0x30(%rsp), %r13d
jge 0x7101
movslq %ebp, %rax
leaq (%rax,%rax,4), %rax
leaq 0x70(,%rax,8), %rsi
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1230
movl $0x28, %esi
movl $0x1, %edx
leaq 0x68(%rsp), %rdi
movq %rbx, %rcx
callq 0x10b0
cmpq $0x1, %rax
jne 0x74e4
movq 0x80(%rsp), %rsi
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
xorl %edx, %edx
callq 0x1230
movq %rbp, %rdi
callq 0x8c1b
testq %rax, %rax
je 0x74f3
leaq (%r15,%r15,8), %rcx
movq 0x28(%rsp), %rdx
leaq (%rdx,%rcx,8), %rdi
movl $0x9, %ecx
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x20(%rsp), %rbx
jmp 0x7164
movq 0x20(%rsp), %rbx
movq 0x60(%rbx), %rax
movslq %r13d, %rcx
leaq (%rcx,%rcx,4), %r12
movq 0x18(%rax,%r12,8), %rsi
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
xorl %edx, %edx
callq 0x1230
movq %rbp, %rdi
callq 0x8c1b
testq %rax, %rax
je 0x753a
leaq (%r15,%r15,8), %rcx
movq 0x28(%rsp), %rdx
leaq (%rdx,%rcx,8), %rdi
movl $0x9, %ecx
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbp, %rdi
callq 0x1080
movq 0x60(%rbx), %rcx
movq %rax, 0x18(%rcx,%r12,8)
movq 0x10(%rsp), %r12
movdqa 0x4114(%rip), %xmm7     # 0xb280
movdqa 0x411b(%rip), %xmm8     # 0xb290
movdqa 0x4122(%rip), %xmm9     # 0xb2a0
movdqa 0x40c9(%rip), %xmm10    # 0xb250
movdqa 0x40d0(%rip), %xmm11    # 0xb260
pcmpeqd %xmm12, %xmm12
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
movl (%rsp), %ebp
movl %ebp, %eax
subl 0x30(%rsp), %eax
movl 0x30(%rbx), %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
cmpl %eax, %r13d
jge 0x7402
movl %r13d, %ecx
movl %eax, %edx
subq %rcx, %rdx
leaq 0x7(%rdx), %rax
andq $-0x8, %rax
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq 0x58(%rsp), %rdx
leaq (%rdx,%rcx,2), %rcx
pxor %xmm11, %xmm0
xorl %edx, %edx
movq %rdx, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por %xmm10, %xmm2
pxor %xmm11, %xmm2
movdqa %xmm2, %xmm4
pcmpgtd %xmm0, %xmm4
pshufd $0xa0, %xmm4, %xmm3     # xmm3 = xmm4[0,0,2,2]
pshuflw $0xe8, %xmm3, %xmm5     # xmm5 = xmm3[0,2,2,3,4,5,6,7]
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pshuflw $0xe8, %xmm2, %xmm6     # xmm6 = xmm2[0,2,2,3,4,5,6,7]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pshuflw $0xe8, %xmm4, %xmm5     # xmm5 = xmm4[0,2,2,3,4,5,6,7]
por %xmm6, %xmm5
pxor %xmm12, %xmm5
packssdw %xmm5, %xmm5
movd %xmm5, %esi
testb $0x1, %sil
je 0x724b
movw %r15w, -0xe(%rcx,%rdx,2)
pand %xmm3, %xmm2
por %xmm4, %xmm2
packssdw %xmm2, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm2
movd %xmm2, %esi
shrl $0x10, %esi
testb $0x1, %sil
je 0x7273
movw %r15w, -0xc(%rcx,%rdx,2)
movdqa %xmm1, %xmm3
por %xmm9, %xmm3
pxor %xmm11, %xmm3
movdqa %xmm3, %xmm4
pcmpgtd %xmm0, %xmm4
pshufd $0xa0, %xmm4, %xmm2     # xmm2 = xmm4[0,0,2,2]
pcmpeqd %xmm0, %xmm3
pshufd $0xf5, %xmm3, %xmm3     # xmm3 = xmm3[1,1,3,3]
movdqa %xmm3, %xmm5
pand %xmm2, %xmm5
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
por %xmm4, %xmm5
packssdw %xmm5, %xmm5
pxor %xmm12, %xmm5
packssdw %xmm5, %xmm5
pextrw $0x2, %xmm5, %esi
testb $0x1, %sil
je 0x72c6
movw %r15w, -0xa(%rcx,%rdx,2)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm3, %xmm3     # xmm3 = xmm3[0,1,2,3,4,5,4,6]
pand %xmm2, %xmm3
pshufhw $0x84, %xmm4, %xmm2     # xmm2 = xmm4[0,1,2,3,4,5,4,6]
por %xmm3, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm2
pextrw $0x3, %xmm2, %esi
testb $0x1, %sil
je 0x72f7
movw %r15w, -0x8(%rcx,%rdx,2)
movdqa %xmm1, %xmm2
por %xmm8, %xmm2
pxor %xmm11, %xmm2
movdqa %xmm2, %xmm4
pcmpgtd %xmm0, %xmm4
pshufd $0xa0, %xmm4, %xmm3     # xmm3 = xmm4[0,0,2,2]
pshuflw $0xe8, %xmm3, %xmm5     # xmm5 = xmm3[0,2,2,3,4,5,6,7]
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pshuflw $0xe8, %xmm2, %xmm6     # xmm6 = xmm2[0,2,2,3,4,5,6,7]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pshuflw $0xe8, %xmm4, %xmm5     # xmm5 = xmm4[0,2,2,3,4,5,6,7]
por %xmm6, %xmm5
pxor %xmm12, %xmm5
packssdw %xmm5, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0x7351
movw %r15w, -0x6(%rcx,%rdx,2)
pand %xmm3, %xmm2
por %xmm4, %xmm2
packssdw %xmm2, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm2
pextrw $0x5, %xmm2, %esi
testb $0x1, %sil
je 0x7377
movw %r15w, -0x4(%rcx,%rdx,2)
por %xmm7, %xmm1
pxor %xmm11, %xmm1
movdqa %xmm1, %xmm3
pcmpgtd %xmm0, %xmm3
pshufd $0xa0, %xmm3, %xmm2     # xmm2 = xmm3[0,0,2,2]
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
movdqa %xmm1, %xmm4
pand %xmm2, %xmm4
pshufd $0xf5, %xmm3, %xmm3     # xmm3 = xmm3[1,1,3,3]
por %xmm3, %xmm4
packssdw %xmm4, %xmm4
pxor %xmm12, %xmm4
packssdw %xmm4, %xmm4
pextrw $0x6, %xmm4, %esi
testb $0x1, %sil
je 0x73c5
movw %r15w, -0x2(%rcx,%rdx,2)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm1, %xmm1     # xmm1 = xmm1[0,1,2,3,4,5,4,6]
pand %xmm2, %xmm1
pshufhw $0x84, %xmm3, %xmm2     # xmm2 = xmm3[0,1,2,3,4,5,4,6]
por %xmm1, %xmm2
pxor %xmm12, %xmm2
packssdw %xmm2, %xmm1
pextrw $0x7, %xmm1, %esi
testb $0x1, %sil
je 0x73f5
movw %r15w, (%rcx,%rdx,2)
addq $0x8, %rdx
cmpq %rdx, %rax
jne 0x71e8
movq 0x48(%rsp), %r15
incq %r15
cmpq %r15, %r14
jne 0x703f
movq 0x50(%rsp), %rdi
callq 0x10c0
movq 0x8(%rsp), %rbp
movq 0x18(%rsp), %r14
leaq 0x4951(%rip), %rsi      # 0xbd7f
movl $0x30, %edi
callq 0x2af5
testq %rax, %rax
movq 0x28(%rsp), %rsi
je 0x74f6
leaq 0x4216(%rip), %rcx      # 0xb663
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rdx
movq 0x68(%rdx), %rcx
movq %rcx, (%rax)
movq %rax, 0x68(%rdx)
movl %r14d, 0x10(%rax)
movq 0x40(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq %rsi, 0x18(%rax)
movq %rbp, 0x28(%rax)
movq %r12, %rdi
callq 0x10c0
xorl %eax, %eax
addq $0x4eb8, %rsp           # imm = 0x4EB8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8b5f(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0xb445(%rip), %rdx      # 0x128e8
leaq 0x40d0(%rip), %rsi      # 0xb57a
movq %r15, %rcx
xorl %eax, %eax
callq 0x11a0
movq %r12, %rdi
callq 0x10c0
movq %rbp, %rdi
callq 0x10c0
movl $0x1, %edi
callq 0x1270
movq 0x38(%rsp), %rdi
callq 0x1d5a
movq 0x8(%rsp), %rbp
movq 0x18(%rsp), %r14
jmp 0x74f6
movq 0x38(%rsp), %rdi
callq 0x1d82
movq 0x8(%rsp), %rbp
movl %r15d, %r14d
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
movq 0x28(%rsp), %r15
je 0x750a
callq 0x1030
testq %r15, %r15
je 0x74b4
testl %r14d, %r14d
jle 0x752b
movl %r14d, %r14d
movq %r15, %rbx
movq %rbx, %rdi
callq 0x9073
addq $0x48, %rbx
decq %r14
jne 0x751a
movq %r15, %rdi
callq 0x1030
jmp 0x74b4
jmp 0x753d
movl %r15d, %r14d
movq 0x10(%rsp), %r12
jmp 0x74f6
callq 0x1d32
cmpl $0x0, 0x38(%rbx)
movq 0x8aa4(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0xb38a(%rip), %rdx      # 0x128e8
jle 0x7569
leaq 0x4774(%rip), %rsi      # 0xbcdb
jmp 0x7570
leaq 0x47a6(%rip), %rsi      # 0xbd16
xorl %eax, %eax
callq 0x11a0
jmp 0x74c4
xorl %r14d, %r14d
movq 0x8(%rsp), %rbp
jmp 0x74f6
xorl %r14d, %r14d
movq 0x8(%rsp), %rbp
jmp 0x753d