// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/zdc.c
// Function: main_single
int main_single(int argc, char *argv[]){
  FILE *fp_ref;
  zd_mem_buffer tar_buf;
  zd_mem_buffer ref_buf;
  Bytef *delta = NULL;
  uLong d_size = 0;

  /* open and check the input files */
  if( !(fp_ref = fopen(argv[1],"rb")) )
  {
    perror(argv[1]);
    exit(0);
  }

  if(argc>2 && (!freopen(argv[2],"rb",stdin)))
  {
    perror(argv[2]); 
    exit(0);
  }

  /* copy input data to memory */
  if(dread_file(fp_ref,&ref_buf) < 0) perror(argv[1]);
  if(dread_file(stdin,&tar_buf) < 0) perror(argv[2]);

  /* compress the data */
  if(zd_compress1((const Bytef*) ref_buf.buffer, ref_buf.pos - ref_buf.buffer,
		  (const Bytef*) tar_buf.buffer, tar_buf.pos - tar_buf.buffer,
		  &delta, &d_size) == ZD_OK){

    /* successfull compression write the delta to a file */
    if(argc>3 && (!freopen(argv[3],"wb",stdout))){
      perror(argv[3]);
      exit(0);
    }
    if(d_size != fwrite(delta, sizeof(char), d_size, stdout)) perror("ouput");
  }
  
  /* release memory */
  free(delta);
  zd_free(&tar_buf);
  zd_free(&ref_buf);

  /* close files */
  fclose(fp_ref);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xed96(%rip), %rsi      # 0x10004
callq 0x1100
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x1291
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1110
xorl %edi, %edi
callq 0x1120
cmpl $0x2, -0x4(%rbp)
jle 0x12cf
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x12d32(%rip), %rax     # 0x13fd8
movq (%rax), %rdx
leaq 0xed54(%rip), %rsi      # 0x10004
callq 0x1090
cmpq $0x0, %rax
jne 0x12cf
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1110
xorl %edi, %edi
callq 0x1120
movq -0x18(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x16e0
cmpl $0x0, %eax
jge 0x12ee
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1110
movq 0x12ce3(%rip), %rax     # 0x13fd8
movq (%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x16e0
cmpl $0x0, %eax
jge 0x1313
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1110
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rax
subq %rax, %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rax, %rcx
leaq -0x50(%rbp), %r8
leaq -0x58(%rbp), %r9
callq 0x1970
cmpl $0x0, %eax
jne 0x13bf
cmpl $0x3, -0x4(%rbp)
jle 0x1381
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq 0x12c78(%rip), %rax     # 0x13fd0
movq (%rax), %rdx
leaq 0xeca5(%rip), %rsi      # 0x10007
callq 0x1090
cmpq $0x0, %rax
jne 0x1381
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1110
xorl %edi, %edi
callq 0x1120
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq 0x12c38(%rip), %rax     # 0x13fd0
movq (%rax), %rcx
movl $0x1, %esi
callq 0x1130
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
je 0x13bd
leaq 0xec52(%rip), %rdi      # 0x1000a
callq 0x1110
jmp 0x13bf
movq -0x50(%rbp), %rdi
callq 0x1030
leaq -0x30(%rbp), %rdi
callq 0x15d0
leaq -0x48(%rbp), %rdi
callq 0x15d0
movq -0x18(%rbp), %rdi
callq 0x1060
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)