// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzWriteOpen
BZFILE* BZ_API(BZ2_bzWriteOpen) 
                    ( int*  bzerror,      
                      FILE* f, 
                      int   blockSize100k, 
                      int   verbosity,
                      int   workFactor )
{
   Int32   ret;
   bzFile* bzf = NULL;

   BZ_SETERR(BZ_OK);

   if (f == NULL ||
       (blockSize100k < 1 || blockSize100k > 9) ||
       (workFactor < 0 || workFactor > 250) ||
       (verbosity < 0 || verbosity > 4))
      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };

   if (ferror(f))
      { BZ_SETERR(BZ_IO_ERROR); return NULL; };

   bzf = malloc ( sizeof(bzFile) );
   if (bzf == NULL)
      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };

   BZ_SETERR(BZ_OK);
   bzf->initialisedOk = False;
   bzf->bufN          = 0;
   bzf->handle        = f;
   bzf->writing       = True;
   bzf->strm.bzalloc  = NULL;
   bzf->strm.bzfree   = NULL;
   bzf->strm.opaque   = NULL;

   if (workFactor == 0) workFactor = 30;
   ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, 
                              verbosity, workFactor );
   if (ret != BZ_OK)
      { BZ_SETERR(ret); free(bzf); return NULL; };

   bzf->strm.avail_in = 0;
   bzf->initialisedOk = True;
   return bzf;   
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
movl %ecx, 0x18(%rsp)
movl %r8d, 0x14(%rsp)
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0xca5c7
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca5de
movq 0x8(%rsp), %rax
movl $0x0, 0x13e8(%rax)
cmpq $0x0, 0x20(%rsp)
je 0xca613
cmpl $0x1, 0x1c(%rsp)
jl 0xca613
cmpl $0x9, 0x1c(%rsp)
jg 0xca613
cmpl $0x0, 0x14(%rsp)
jl 0xca613
cmpl $0xfa, 0x14(%rsp)
jg 0xca613
cmpl $0x0, 0x18(%rsp)
jl 0xca613
cmpl $0x4, 0x18(%rsp)
jle 0xca64b
cmpq $0x0, 0x28(%rsp)
je 0xca626
movq 0x28(%rsp), %rax
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
cmpq $0x0, 0x8(%rsp)
je 0xca63d
movq 0x8(%rsp), %rax
movl $0xfffffffe, 0x13e8(%rax) # imm = 0xFFFFFFFE
movq $0x0, 0x30(%rsp)
jmp 0xca80a
movq 0x20(%rsp), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xca692
cmpq $0x0, 0x28(%rsp)
je 0xca66d
movq 0x28(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, 0x8(%rsp)
je 0xca684
movq 0x8(%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
movq $0x0, 0x30(%rsp)
jmp 0xca80a
movl $0x13f0, %edi           # imm = 0x13F0
callq 0xbcb8
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0xca6e1
cmpq $0x0, 0x28(%rsp)
je 0xca6bc
movq 0x28(%rsp), %rax
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
cmpq $0x0, 0x8(%rsp)
je 0xca6d3
movq 0x8(%rsp), %rax
movl $0xfffffffd, 0x13e8(%rax) # imm = 0xFFFFFFFD
movq $0x0, 0x30(%rsp)
jmp 0xca80a
cmpq $0x0, 0x28(%rsp)
je 0xca6f4
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca70b
movq 0x8(%rsp), %rax
movl $0x0, 0x13e8(%rax)
movq 0x8(%rsp), %rax
movb $0x0, 0x13ec(%rax)
movq 0x8(%rsp), %rax
movl $0x0, 0x1390(%rax)
movq 0x20(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movb $0x1, 0x1394(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0x13d0(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0x13d8(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0x13e0(%rax)
cmpl $0x0, 0x14(%rsp)
jne 0xca77e
movl $0x1e, 0x14(%rsp)
movq 0x8(%rsp), %rdi
addq $0x1398, %rdi           # imm = 0x1398
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
movl 0x14(%rsp), %ecx
callq 0xc7bb0
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x10(%rsp)
je 0xca7e5
cmpq $0x0, 0x28(%rsp)
je 0xca7b9
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca7d0
movl 0x10(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x13e8(%rax)
movq 0x8(%rsp), %rdi
callq 0xb760
movq $0x0, 0x30(%rsp)
jmp 0xca80a
movq 0x8(%rsp), %rax
movl $0x0, 0x13a0(%rax)
movq 0x8(%rsp), %rax
movb $0x1, 0x13ec(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)