// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DB.c
// Function: Check_Track
int Check_Track(DAZZ_DB *db, char *track, int *kind)
{ FILE       *afile;
  int         tracklen, size, ispart;
  int         ureads, treads;

  afile = NULL;
  if (db->part > 0)
    { afile  = fopen(MyCatenate(db->path,MyNumbered_Suffix(".",db->part,"."),track,".anno"),"r");
      ispart = 1;
    }
  if (afile == NULL)
    { afile  = fopen(MyCatenate(db->path,".",track,".anno"),"r");
      ispart = 0;
    }
  if (afile == NULL)
    return (-2);

  if (fread(&tracklen,sizeof(int),1,afile) != 1)
    { EPRINTF(EPLACE,"%s: track files for %s are corrupted\n",Prog_Name,track);
      fclose(afile);
      EXIT(-3);
    }
  if (fread(&size,sizeof(int),1,afile) != 1)
    { EPRINTF(EPLACE,"%s: track files for %s are corrupted\n",Prog_Name,track);
      fclose(afile);
      EXIT(-3);
    }

  if (size == 0)
    *kind = MASK_TRACK;
  else if (size > 0)
    *kind = CUSTOM_TRACK;
  else
    { EPRINTF(EPLACE,"%s: track files for %s are corrupted\n",Prog_Name,track);
      fclose(afile);
      EXIT(-3);
    }
  
  fclose(afile);

  if (ispart)
    { ureads = ((int *) (db->reads))[-1];
      treads = ((int *) (db->reads))[-2];
    }
  else
    { ureads = db->ureads;
      treads = db->treads;
    }

  if (tracklen == ureads)
    return (0);
  else if (tracklen == treads)
    return (1);
  else
    return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jle 0x6549
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %esi
leaq 0x7fde(%rip), %rdx      # 0xe4ee
movq %rdx, %rdi
callq 0x6710
movq -0x48(%rbp), %rdi
movq %rax, %rsi
movq -0x18(%rbp), %rdx
leaq 0x833c(%rip), %rcx      # 0xe866
callq 0x4550
movq %rax, %rdi
leaq 0x881b(%rip), %rsi      # 0xed54
callq 0x1230
movq %rax, -0x28(%rbp)
movl $0x1, -0x34(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x6589
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x7f8b(%rip), %rsi      # 0xe4ee
leaq 0x82fc(%rip), %rcx      # 0xe866
callq 0x4550
movq %rax, %rdi
leaq 0x87db(%rip), %rsi      # 0xed54
callq 0x1230
movq %rax, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x659c
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x6707
movq -0x28(%rbp), %rcx
leaq -0x2c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x65ef
movq 0xba38(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xe4be(%rip), %rdx      # 0x14a88
movq -0x18(%rbp), %rcx
leaq 0x8297(%rip), %rsi      # 0xe86c
movb $0x0, %al
callq 0x1180
movq -0x28(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
movq -0x28(%rbp), %rcx
leaq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x6642
movq 0xb9e5(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xe46b(%rip), %rdx      # 0x14a88
movq -0x18(%rbp), %rcx
leaq 0x8244(%rip), %rsi      # 0xe86c
movb $0x0, %al
callq 0x1180
movq -0x28(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
cmpl $0x0, -0x30(%rbp)
jne 0x6654
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x669e
cmpl $0x0, -0x30(%rbp)
jle 0x6666
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x669c
movq 0xb98b(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xe411(%rip), %rdx      # 0x14a88
movq -0x18(%rbp), %rcx
leaq 0x81ea(%rip), %rsi      # 0xe86c
movb $0x0, %al
callq 0x1180
movq -0x28(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
jmp 0x669e
movq -0x28(%rbp), %rdi
callq 0x10b0
cmpl $0x0, -0x34(%rbp)
je 0x66cb
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x66de
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x66ef
movl $0x0, -0x4(%rbp)
jmp 0x6707
movl -0x2c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x6700
movl $0x1, -0x4(%rbp)
jmp 0x6707
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq