// File: /workspace/github_c_makefile_star2_O0/negge[P]xlink/src/ec.c
// Function: xlink_decoder_read_bit
static int xlink_decoder_read_bit(xlink_decoder *dec, xlink_word c0,
 xlink_word c1) {
  int bit;
  xlink_word s;
  XLINK_ERROR(c0 == 0 || c1 == 0 || (c0 > EC_MASK - c1),
   ("Error invalid counts, c0 = %i and c1 = %i", c0, c1));
  /* Fill value with bits until EC_BASE <= range < 2*EC_BASE */
  while (dec->range < EC_BASE) {
    dec->low <<= 1;
    dec->range <<= 1;
    dec->value <<= 1;
    dec->value |=
     dec->pos >= dec->bits ? 0 : XLINK_GET_BIT(dec->bytes->data, dec->pos);
    dec->pos++;
  }
  s = ((xlink_dword)dec->range)*c1/(c0 + c1);
  XLINK_ERROR(s == 0 || s >= dec->range, ("Invalid scale value s = %02x", s));
  bit = dec->value < s;
  if (!bit) {
    dec->low += s;
    dec->range -= s;
    dec->value -= s;
  }
  else {
    dec->range = s;
  }
  return bit;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0xab4d
cmpl $0x0, -0x10(%rbp)
je 0xab4d
movl -0xc(%rbp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
subl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jbe 0xab6b
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq 0x5566(%rip), %rdi      # 0x100c0
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0xab6d
jmp 0xab6f
movq -0x8(%rbp), %rax
cmpl $0x80000000, 0x1c(%rax) # imm = 0x80000000
jae 0xac08
movq -0x8(%rbp), %rax
movl 0x18(%rax), %ecx
shll %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
shll %ecx
movl %ecx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
shll %ecx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jl 0xabbb
xorl %eax, %eax
movl %eax, -0x1c(%rbp)
jmp 0xabe9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x14(%rcx), %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0x7, %ecx
sarl %cl, %eax
andl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
orl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0xab6f
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl -0x10(%rbp), %ecx
imulq %rcx, %rax
movl -0xc(%rbp), %ecx
addl -0x10(%rbp), %ecx
movl %ecx, %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0xac38
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jb 0xac53
movl -0x18(%rbp), %esi
leaq 0x54e7(%rip), %rdi      # 0x10129
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0xac55
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
cmpl -0x18(%rbp), %eax
setb %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xac9d
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x18(%rax), %ecx
movl %ecx, 0x18(%rax)
movl -0x18(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x1c(%rax)
movl -0x18(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x20(%rax)
jmp 0xaca7
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq