// File: /workspace/github_c_makefile_star2_O0/ijleesw[P]data-compression/src/arithmetic/arithmetic_decoder.h
// Function: arithmetic_decoder::decode(unsigned int, unsigned int, unsigned int)
inline void decode(DWORD lower_bound, DWORD upper_bound, DWORD total)
  {
    bool eql_cond, e3_cond;
    QWORD range = (QWORD)u - l + 1;

    ASSERT(l < u);   
    ASSERT((lower_bound <= upper_bound) && (upper_bound <= total));
    
    u = l + (DWORD)(((range * upper_bound) / total) - 1);
    l = l + (DWORD)((range * lower_bound) / total);

    while( (eql_cond = (MSB(u) == MSB(l))) ||
           (e3_cond  = ((M2SB(l) == 1) && (M2SB(u) == 0))) )
    {  
      if(eql_cond)
      {
        l <<= 1;
        u <<= 1;
        tag <<= 1;
        
        u += 1;
        
        bit b = m_input->read_next();        
        ASSERT (((tag + b)  == tag + 1) || ((tag + b) == tag));        
        tag += b;
      }
      else if (e3_cond)
      {
        l <<= 1;
        u <<= 1;
        tag <<= 1;
        u += 1;
        
        bit b = m_input->read_next();
        ASSERT (((tag + b) == tag + 1) || ((tag + b) == tag));
        tag += b;
        
        l += MSB_MASK; 
        u += MSB_MASK;
        tag += MSB_MASK;
      }
    }
    ASSERT(l < u);
  }

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movl %esi, 0x2c(%rsp)
movl %edx, 0x28(%rsp)
movl %ecx, 0x24(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rax), %ecx
movl 0xc(%rax), %edx
subq %rdx, %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rsp)
movl 0xc(%rax), %ecx
movq 0x18(%rsp), %rax
movl 0x28(%rsp), %edx
imulq %rdx, %rax
movl 0x24(%rsp), %edx
movl %edx, %esi
xorl %edx, %edx
divq %rsi
movq %rax, %rdx
movq 0x8(%rsp), %rax
subq $0x1, %rdx
addl %edx, %ecx
movl %ecx, 0x10(%rax)
movl 0xc(%rax), %ecx
movq 0x18(%rsp), %rax
movl 0x2c(%rsp), %edx
imulq %rdx, %rax
movl 0x24(%rsp), %edx
movl %edx, %esi
xorl %edx, %edx
divq %rsi
movq %rax, %rdx
movq 0x8(%rsp), %rax
addl %edx, %ecx
movl %ecx, 0xc(%rax)
movq 0x8(%rsp), %rcx
movl 0x10(%rcx), %eax
shrl $0x1f, %eax
movl 0xc(%rcx), %ecx
shrl $0x1f, %ecx
cmpl %ecx, %eax
sete %cl
movb %cl, %al
andb $0x1, %al
movb %al, 0x23(%rsp)
movb $0x1, %al
testb $0x1, %cl
movb %al, 0x7(%rsp)
jne 0x4540
movq 0x8(%rsp), %rax
movl 0xc(%rax), %ecx
shrl $0x1e, %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
movb %al, 0x6(%rsp)
jne 0x452f
movq 0x8(%rsp), %rax
movl 0x10(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
sete %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
movb %al, %cl
andb $0x1, %cl
movb %cl, 0x22(%rsp)
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x454d
jmp 0x4620
testb $0x1, 0x23(%rsp)
je 0x45a2
movq 0x8(%rsp), %rax
movl 0xc(%rax), %ecx
shll %ecx
movl %ecx, 0xc(%rax)
movl 0x10(%rax), %ecx
shll %ecx
movl %ecx, 0x10(%rax)
movl 0x14(%rax), %ecx
shll %ecx
movl %ecx, 0x14(%rax)
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq (%rax), %rdi
callq 0x32b0
movb %al, %cl
movq 0x8(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x17(%rsp)
movb 0x17(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
jmp 0x461b
testb $0x1, 0x22(%rsp)
je 0x4619
movq 0x8(%rsp), %rax
movl 0xc(%rax), %ecx
shll %ecx
movl %ecx, 0xc(%rax)
movl 0x10(%rax), %ecx
shll %ecx
movl %ecx, 0x10(%rax)
movl 0x14(%rax), %ecx
shll %ecx
movl %ecx, 0x14(%rax)
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq (%rax), %rdi
callq 0x32b0
movb %al, %cl
movq 0x8(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x16(%rsp)
movb 0x16(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
movl 0xc(%rax), %ecx
addl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
movl 0x10(%rax), %ecx
addl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x10(%rax)
movl 0x14(%rax), %ecx
addl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x14(%rax)
jmp 0x461b
jmp 0x44d5
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)
nop