// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/zdu.c
// Function: main_single
int main_single(int argc, char *argv[]){
  FILE *fp_ref;

  zd_mem_buffer ref_buf;
  zd_mem_buffer delta;
  Bytef *tar_buf = NULL;
  uLong t_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]); exit(0);}
  if(dread_file(stdin,&delta) < 0) {perror(argv[2]); exit(0);}

  /* decompress the data */
  if(zd_uncompress1((const Bytef*)ref_buf.buffer, ref_buf.pos - ref_buf.buffer,
		    &tar_buf, &t_size,
		    (const Bytef*) delta.buffer, 
		    delta.pos - delta.buffer) == ZD_OK){
    
    /* successfull compression write the delta to a file */
    if(argc>3 && (!freopen(argv[3],"wb",stdout))){
      perror(argv[3]);
      exit(0);
    }
    if(t_size !=  fwrite(tar_buf, sizeof(char),t_size ,stdout))
      perror("ouput");
  }
  
  /* release memory */
  free(tar_buf);
  zd_free(&delta);
  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 -0x30(%rbp), %rsi
callq 0x16f0
cmpl $0x0, %eax
jge 0x12f5
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1110
xorl %edi, %edi
callq 0x1120
movq 0x12cdc(%rip), %rax     # 0x13fd8
movq (%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x16f0
cmpl $0x0, %eax
jge 0x1321
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1110
xorl %edi, %edi
callq 0x1120
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rax, %rsi
movq -0x48(%rbp), %r8
movq -0x40(%rbp), %r9
movq -0x48(%rbp), %rax
subq %rax, %r9
leaq -0x50(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x1cf0
cmpl $0x0, %eax
jne 0x13cd
cmpl $0x3, -0x4(%rbp)
jle 0x138f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq 0x12c6a(%rip), %rax     # 0x13fd0
movq (%rax), %rdx
leaq 0xec97(%rip), %rsi      # 0x10007
callq 0x1090
cmpq $0x0, %rax
jne 0x138f
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 0x12c2a(%rip), %rax     # 0x13fd0
movq (%rax), %rcx
movl $0x1, %esi
callq 0x1130
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
je 0x13cb
leaq 0xec44(%rip), %rdi      # 0x1000a
callq 0x1110
jmp 0x13cd
movq -0x50(%rbp), %rdi
callq 0x1030
leaq -0x48(%rbp), %rdi
callq 0x15e0
leaq -0x30(%rbp), %rdi
callq 0x15e0
movq -0x18(%rbp), %rdi
callq 0x1060
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)