// File: /workspace/github_c_makefile_star2_O0/zhiyb[P]png2tlg/png2tlg.cpp
// Function: TryCompressGolomb::Try(char*, int)
int Try(char *buf, int size)
	{
		for(int i = 0; i < size; i++)
		{
			if(buf[i])
			{
				// write zero count
				if(!LastNonZero)
				{
					if(Count)
						TotalBits +=
							TLG6BitStream::GetGammaBitLength(Count);

					// count non-zero values
					Count = 0;
				}

				// write non-zero values
				for(; i < size; i++)
				{
					int e = buf[i];
					if(!e) break;
					Count ++;
					int k = TVPTLG6GolombBitLengthTable[A][N];
					int m = ((e >= 0) ? 2*e : -2*e-1) - 1;
					int unexp_bits = (m>>k);
					if(unexp_bits >= (GOLOMB_GIVE_UP_BYTES*8-8/2))
						unexp_bits = (GOLOMB_GIVE_UP_BYTES*8-8/2)+8;
					TotalBits += unexp_bits + 1 + k;
					A += (m>>1);
					if (--N < 0) {
						A >>= 1; N = TVP_TLG6_GOLOMB_N_COUNT - 1;
					}
				}

				// write non-zero count

				i--;
				LastNonZero = true;
			}
			else
			{
				// zero
				if(LastNonZero)
				{
					if(Count)
					{
						TotalBits += TLG6BitStream::GetGammaBitLength(Count);
						Count = 0;
					}
				}

				Count ++;
				LastNonZero = false;
			}
		}
		return TotalBits;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1f4a9
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x1f455
movq -0x30(%rbp), %rax
testb $0x1, 0x10(%rax)
jne 0x1f365
movq -0x30(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x1f35a
movq -0x30(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x1f940
movl %eax, %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x4(%rax)
jmp 0x1f367
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1f442
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1f38d
jmp 0x1f442
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x4(%rcx)
movslq 0xc(%rcx), %rdx
leaq 0x6fab(%rip), %rax      # 0x26350
shlq $0x2, %rdx
addq %rdx, %rax
movslq 0x8(%rcx), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x1f3c7
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x34(%rbp)
jmp 0x1f3d4
imull $0xfffffffe, -0x1c(%rbp), %eax # imm = 0xFFFFFFFE
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x20(%rbp), %ecx
sarl %cl, %eax
movl %eax, -0x28(%rbp)
cmpl $0x1c, -0x28(%rbp)
jl 0x1f3f5
movl $0x24, -0x28(%rbp)
movq -0x30(%rbp), %rcx
movl -0x28(%rbp), %eax
addl $0x1, %eax
addl -0x20(%rbp), %eax
addl (%rcx), %eax
movl %eax, (%rcx)
movl -0x24(%rbp), %eax
sarl %eax
addl 0xc(%rcx), %eax
movl %eax, 0xc(%rcx)
movl 0x8(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x8(%rcx)
cmpl $0x0, %eax
jge 0x1f432
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
sarl %ecx
movl %ecx, 0xc(%rax)
movl $0x3, 0x8(%rax)
jmp 0x1f434
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1f367
movq -0x30(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $-0x1, %ecx
movl %ecx, -0x18(%rbp)
movb $0x1, 0x10(%rax)
jmp 0x1f499
movq -0x30(%rbp), %rax
testb $0x1, 0x10(%rax)
je 0x1f488
movq -0x30(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x1f486
movq -0x30(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x1f940
movl %eax, %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl $0x0, 0x4(%rax)
jmp 0x1f488
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movb $0x0, 0x10(%rax)
jmp 0x1f49b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1f312
movq -0x30(%rbp), %rax
movl (%rax), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop