// File: /workspace/github_c_makefile_star2_O0/coapp-packages[P]bzip2/bzip2.c
// Function: compressStream
static 
void compressStream ( FILE *stream, FILE *zStream )
{
   BZFILE* bzf = NULL;
   UChar   ibuf[5000];
   Int32   nIbuf;
   UInt32  nbytes_in_lo32, nbytes_in_hi32;
   UInt32  nbytes_out_lo32, nbytes_out_hi32;
   Int32   bzerr, bzerr_dummy, ret;

   SET_BINARY_MODE(stream);
   SET_BINARY_MODE(zStream);

   if (ferror(stream)) goto errhandler_io;
   if (ferror(zStream)) goto errhandler_io;

   bzf = BZ2_bzWriteOpen ( &bzerr, zStream, 
                           blockSize100k, verbosity, workFactor );   
   if (bzerr != BZ_OK) goto errhandler;

   if (verbosity >= 2) fprintf ( stderr, "\n" );

   while (True) {

      if (myfeof(stream)) break;
      nIbuf = fread ( ibuf, sizeof(UChar), 5000, stream );
      if (ferror(stream)) goto errhandler_io;
      if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf );
      if (bzerr != BZ_OK) goto errhandler;

   }

   BZ2_bzWriteClose64 ( &bzerr, bzf, 0, 
                        &nbytes_in_lo32, &nbytes_in_hi32,
                        &nbytes_out_lo32, &nbytes_out_hi32 );
   if (bzerr != BZ_OK) goto errhandler;

   if (ferror(zStream)) goto errhandler_io;
   ret = fflush ( zStream );
   if (ret == EOF) goto errhandler_io;
   if (zStream != stdout) {
      Int32 fd = fileno ( zStream );
      if (fd < 0) goto errhandler_io;
      applySavedFileAttrToOutputFile ( fd );
      ret = fclose ( zStream );
      outputHandleJustInCase = NULL;
      if (ret == EOF) goto errhandler_io;
   }
   outputHandleJustInCase = NULL;
   if (ferror(stream)) goto errhandler_io;
   ret = fclose ( stream );
   if (ret == EOF) goto errhandler_io;

   if (verbosity >= 1) {
      if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) {
	 fprintf ( stderr, " no data compressed.\n");
      } else {
	 Char   buf_nin[32], buf_nout[32];
	 UInt64 nbytes_in,   nbytes_out;
	 double nbytes_in_d, nbytes_out_d;
	 uInt64_from_UInt32s ( &nbytes_in, 
			       nbytes_in_lo32, nbytes_in_hi32 );
	 uInt64_from_UInt32s ( &nbytes_out, 
			       nbytes_out_lo32, nbytes_out_hi32 );
	 nbytes_in_d  = uInt64_to_double ( &nbytes_in );
	 nbytes_out_d = uInt64_to_double ( &nbytes_out );
	 uInt64_toAscii ( buf_nin, &nbytes_in );
	 uInt64_toAscii ( buf_nout, &nbytes_out );
	 fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, "
		   "%5.2f%% saved, %s in, %s out.\n",
		   nbytes_in_d / nbytes_out_d,
		   (8.0 * nbytes_out_d) / nbytes_in_d,
		   100.0 * (1.0 - nbytes_out_d / nbytes_in_d),
		   buf_nin,
		   buf_nout
		 );
      }
   }

   return;

   errhandler:
   BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, 
                        &nbytes_in_lo32, &nbytes_in_hi32,
                        &nbytes_out_lo32, &nbytes_out_hi32 );
   switch (bzerr) {
      case BZ_CONFIG_ERROR:
         configError(); break;
      case BZ_MEM_ERROR:
         outOfMemory (); break;
      case BZ_IO_ERROR:
         errhandler_io:
         ioError(); break;
      default:
         panic ( "compress:unexpected error" );
   }

   panic ( "compress:end" );
   /*notreached*/
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1440, %rsp           # imm = 0x1440
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x20b0
cmpl $0x0, %eax
je 0x4dde
jmp 0x5179
movq -0x10(%rbp), %rdi
callq 0x20b0
cmpl $0x0, %eax
je 0x4df1
jmp 0x5179
movq -0x10(%rbp), %rsi
movl 0x19085(%rip), %edx     # 0x1de80
movl 0x1907b(%rip), %ecx     # 0x1de7c
movl 0x19088(%rip), %r8d     # 0x1de90
leaq -0x13b8(%rbp), %rdi
callq 0x84d0
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x13b8(%rbp)
je 0x4e26
jmp 0x5109
cmpl $0x2, 0x1904f(%rip)     # 0x1de7c
jl 0x4e47
movq 0x181c2(%rip), %rax     # 0x1cff8
movq (%rax), %rdi
leaq 0x14e69(%rip), %rsi     # 0x19ca9
movb $0x0, %al
callq 0x2170
jmp 0x4e49
movq -0x8(%rbp), %rdi
callq 0x5220
cmpb $0x0, %al
je 0x4e58
jmp 0x4ec1
leaq -0x13a0(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x1, %esi
movl $0x1388, %edx           # imm = 0x1388
callq 0x20d0
movl %eax, -0x13a4(%rbp)
movq -0x8(%rbp), %rdi
callq 0x20b0
cmpl $0x0, %eax
je 0x4e8b
jmp 0x5179
cmpl $0x0, -0x13a4(%rbp)
jle 0x4eb1
movq -0x18(%rbp), %rsi
leaq -0x13a0(%rbp), %rdx
movl -0x13a4(%rbp), %ecx
leaq -0x13b8(%rbp), %rdi
callq 0x8720
cmpl $0x0, -0x13b8(%rbp)
je 0x4ebf
jmp 0x5109
jmp 0x4e49
movq -0x18(%rbp), %rsi
leaq -0x13b8(%rbp), %rdi
xorl %edx, %edx
leaq -0x13a8(%rbp), %rcx
leaq -0x13ac(%rbp), %r8
leaq -0x13b0(%rbp), %r9
leaq -0x13b4(%rbp), %rax
movq %rax, (%rsp)
callq 0x89e0
cmpl $0x0, -0x13b8(%rbp)
je 0x4f01
jmp 0x5109
movq -0x10(%rbp), %rdi
callq 0x20b0
cmpl $0x0, %eax
je 0x4f14
jmp 0x5179
movq -0x10(%rbp), %rdi
callq 0x21b0
movl %eax, -0x13c0(%rbp)
cmpl $-0x1, -0x13c0(%rbp)
jne 0x4f31
jmp 0x5179
movq -0x10(%rbp), %rax
movq 0x18094(%rip), %rcx     # 0x1cfd0
cmpq (%rcx), %rax
je 0x4f93
movq -0x10(%rbp), %rdi
callq 0x2190
movl %eax, -0x13c4(%rbp)
cmpl $0x0, -0x13c4(%rbp)
jge 0x4f5e
jmp 0x5179
movl -0x13c4(%rbp), %edi
callq 0x5260
movq -0x10(%rbp), %rdi
callq 0x20e0
movl %eax, -0x13c0(%rbp)
movq $0x0, 0x18eed(%rip) # 0x1de70
cmpl $-0x1, -0x13c0(%rbp)
jne 0x4f91
jmp 0x5179
jmp 0x4f93
movq $0x0, 0x18ed2(%rip) # 0x1de70
movq -0x8(%rbp), %rdi
callq 0x20b0
cmpl $0x0, %eax
je 0x4fb1
jmp 0x5179
movq -0x8(%rbp), %rdi
callq 0x20e0
movl %eax, -0x13c0(%rbp)
cmpl $-0x1, -0x13c0(%rbp)
jne 0x4fce
jmp 0x5179
cmpl $0x1, 0x18ea7(%rip)     # 0x1de7c
jl 0x5100
cmpl $0x0, -0x13a8(%rbp)
jne 0x500a
cmpl $0x0, -0x13ac(%rbp)
jne 0x500a
movq 0x18004(%rip), %rax     # 0x1cff8
movq (%rax), %rdi
leaq 0x146a8(%rip), %rsi     # 0x196a6
movb $0x0, %al
callq 0x2170
jmp 0x50fe
movl -0x13a8(%rbp), %esi
movl -0x13ac(%rbp), %edx
leaq -0x1418(%rbp), %rdi
callq 0x52b0
movl -0x13b0(%rbp), %esi
movl -0x13b4(%rbp), %edx
leaq -0x1420(%rbp), %rdi
callq 0x52b0
leaq -0x1418(%rbp), %rdi
callq 0x5360
movsd %xmm0, -0x1428(%rbp)
leaq -0x1420(%rbp), %rdi
callq 0x5360
movsd %xmm0, -0x1430(%rbp)
leaq -0x13f0(%rbp), %rdi
leaq -0x1418(%rbp), %rsi
callq 0x53e0
leaq -0x1410(%rbp), %rdi
leaq -0x1420(%rbp), %rsi
callq 0x53e0
movq 0x17f69(%rip), %rax     # 0x1cff8
movq (%rax), %rdi
movsd -0x1428(%rbp), %xmm0
divsd -0x1430(%rbp), %xmm0
movsd 0x130ce(%rip), %xmm1    # 0x18178
mulsd -0x1430(%rbp), %xmm1
divsd -0x1428(%rbp), %xmm1
movsd -0x1430(%rbp), %xmm2
divsd -0x1428(%rbp), %xmm2
movsd 0x1309e(%rip), %xmm3    # 0x18170
subsd %xmm2, %xmm3
movsd 0x1308a(%rip), %xmm2    # 0x18168
mulsd %xmm3, %xmm2
leaq -0x13f0(%rbp), %rdx
leaq -0x1410(%rbp), %rcx
leaq 0x145c5(%rip), %rsi     # 0x196bc
movb $0x3, %al
callq 0x2170
jmp 0x5100
addq $0x1440, %rsp           # imm = 0x1440
popq %rbp
retq
movq -0x18(%rbp), %rsi
movq %rsp, %rax
leaq -0x13b4(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x13bc(%rbp), %rdi
movl $0x1, %edx
leaq -0x13a8(%rbp), %rcx
leaq -0x13ac(%rbp), %r8
leaq -0x13b0(%rbp), %r9
callq 0x89e0
movl -0x13b8(%rbp), %eax
movl %eax, -0x1434(%rbp)
subl $-0x9, %eax
je 0x516d
jmp 0x5153
movl -0x1434(%rbp), %eax
subl $-0x6, %eax
je 0x5177
jmp 0x5160
movl -0x1434(%rbp), %eax
subl $-0x3, %eax
je 0x5172
jmp 0x517e
callq 0x5490
callq 0x4a90
jmp 0x5179
callq 0x51e0
leaq 0x147cb(%rip), %rdi     # 0x19950
callq 0x4ad0
nopw (%rax,%rax)