// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DB.c
// Function: Late_Track_Trim
static int Late_Track_Trim(DAZZ_DB *db, DAZZ_TRACK *track, int ispart)
{ int         i, j, r;
  int         allflag, cutoff;
  int         ureads;
  char       *root;
  DAZZ_READ   read;
  FILE       *indx;

  if (db->cutoff <= 0 && (db->allarr & DB_ALL) != 0) return (0);

  cutoff = db->cutoff;
  if ((db->allarr & DB_ALL) != 0)
    allflag = 0;
  else
    allflag = DB_BEST;

  root = rindex(db->path,'/') + 2;
  indx = Fopen(MyCatenate(db->path,"","",".idx"),"r");
  fseeko(indx,sizeof(DAZZ_DB) + sizeof(DAZZ_READ)*db->ufirst,SEEK_SET);
  if (ispart)
    ureads = ((int *) (db->reads))[-1];
  else
    ureads = db->ureads;

  { int    size;

    size = track->size;
    if (track->data == NULL)
      { char *anno = (char *) track->anno;
        j = r = 0;
        for (i = r = 0; i < ureads; i++, r += size)
          { if (fread(&read,sizeof(DAZZ_READ),1,indx) != 1)
              { EPRINTF(EPLACE,"%s: Index file (.idx) of %s is junk\n",Prog_Name,root);
                fclose(indx);
                EXIT(1);
              }
            if ((read.flags & DB_BEST) >= allflag && read.rlen >= cutoff)
              { memmove(anno+j,anno+r,size);
                j += size;
              }
            r += size;
          }
        track->anno = Realloc(track->anno,track->size*j,NULL);
      }
    else if (size == 4)
      { int *anno4 = (int *) (track->anno);
        int *alen  = track->alen;

        j = 0;
        for (i = 0; i < ureads; i++)
          { if (fread(&read,sizeof(DAZZ_READ),1,indx) != 1)
              { EPRINTF(EPLACE,"%s: Index file (.idx) of %s is junk\n",Prog_Name,root);
                fclose(indx);
                EXIT(1);
              }
            if ((read.flags & DB_BEST) >= allflag && read.rlen >= cutoff)
              { anno4[j] = anno4[i];
                alen[j]  = alen[i];
                j += 1;
              }
          }
        track->alen = Realloc(track->alen,sizeof(int)*j,NULL);
        track->anno = Realloc(track->anno,track->size*(j+1),NULL);
      }
    else // size == 8
      { int64 *anno8 = (int64 *) (track->anno);
        int   *alen  = track->alen;

        j = 0;
        for (i = 0; i < ureads; i++)
          { if (fread(&read,sizeof(DAZZ_READ),1,indx) != 1)
              { EPRINTF(EPLACE,"%s: Index file (.idx) of %s is junk\n",Prog_Name,root);
                fclose(indx);
                EXIT(1);
              }
            if ((read.flags & DB_BEST) >= allflag && read.rlen >= cutoff)
              { anno8[j] = anno8[i];
                alen[j]  = alen[i];
                j += 1;
              }
          }
        track->alen = Realloc(track->alen,sizeof(int)*j,NULL);
        track->anno = Realloc(track->anno,track->size*(j+1),NULL);
      }
  }

  fclose(indx);
  return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jg 0x711b
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x711b
movl $0x0, -0x4(%rbp)
jmp 0x75a0
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x713d
movl $0x0, -0x2c(%rbp)
jmp 0x7144
movl $0x800, -0x2c(%rbp)     # imm = 0x800
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movl $0x2f, %esi
callq 0x1240
addq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
leaq 0x77f0(%rip), %rdx      # 0xe95d
leaq 0x737c(%rip), %rcx      # 0xe4f0
movq %rdx, %rsi
callq 0x4550
movq %rax, %rdi
leaq 0x7bce(%rip), %rsi      # 0xed54
callq 0x2480
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x3c(%rax), %rax
imulq $0x28, %rax, %rsi
addq $0x70, %rsi
xorl %edx, %edx
callq 0x1220
cmpl $0x0, -0x1c(%rbp)
je 0x71c0
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0x71c9
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x72f5
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x72c6
movq -0x70(%rbp), %rcx
leaq -0x68(%rbp), %rdi
movl $0x28, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x7269
movq 0xadbe(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xd844(%rip), %rdx      # 0x14a88
movq -0x40(%rbp), %rcx
leaq 0x72a6(%rip), %rsi      # 0xe4f5
movb $0x0, %al
callq 0x1180
movq -0x70(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
movl -0x48(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl -0x2c(%rbp), %eax
jl 0x72a6
movl -0x64(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0x72a6
movq -0x80(%rbp), %rdi
movslq -0x24(%rbp), %rax
addq %rax, %rdi
movq -0x80(%rbp), %rsi
movslq -0x28(%rbp), %rax
addq %rax, %rsi
movslq -0x74(%rbp), %rdx
callq 0x1210
movl -0x74(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x74(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x74(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x720a
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
imull -0x24(%rbp), %eax
movslq %eax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2340
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x7590
cmpl $0x4, -0x74(%rbp)
jne 0x7448
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x73f0
movq -0x70(%rbp), %rcx
leaq -0x68(%rbp), %rdi
movl $0x28, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x738a
movq 0xac9d(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xd723(%rip), %rdx      # 0x14a88
movq -0x40(%rbp), %rcx
leaq 0x7185(%rip), %rsi      # 0xe4f5
movb $0x0, %al
callq 0x1180
movq -0x70(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
movl -0x48(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl -0x2c(%rbp), %eax
jl 0x73e0
movl -0x64(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0x73e0
movq -0x88(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x88(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x90(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x90(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x73e2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x732b
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0x24(%rbp), %rsi
shlq $0x2, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2340
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movslq %eax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2340
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x758e
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x753b
movq -0x70(%rbp), %rcx
leaq -0x68(%rbp), %rdi
movl $0x28, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x74d3
movq 0xab54(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xd5da(%rip), %rdx      # 0x14a88
movq -0x40(%rbp), %rcx
leaq 0x703c(%rip), %rsi      # 0xe4f5
movb $0x0, %al
callq 0x1180
movq -0x70(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
movl -0x48(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl -0x2c(%rbp), %eax
jl 0x752b
movl -0x64(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0x752b
movq -0x98(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x98(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xa0(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0xa0(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x752d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x7474
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0x24(%rbp), %rsi
shlq $0x2, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2340
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movslq %eax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2340
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x7590
movq -0x70(%rbp), %rdi
callq 0x10b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)