// File: salleaffaire[P]MXFParser/./bit_extractor.hpp
// Function: bit_extractor::show_bits(unsigned char)
unsigned int show_bits(unsigned char n) {
      unsigned int rval = 0;

      unsigned char *p = mBuffer + mContextBytePos; 
      
      const unsigned char comp_bit_pos = 8 - mContextBitPos;


      rval |= ((unsigned int)*p++ >> mContextBitPos);
      //std::cout << "R0: " << std::hex << rval << std::endl;
      rval |= ((unsigned int)*p++ << comp_bit_pos);
      //std::cout << "R1: " << std::hex << rval << std::endl;
      rval |= ((unsigned int)*p++ << (comp_bit_pos+8));
      //std::cout << "R2: " << std::hex << rval << std::endl;
      rval |= ((unsigned int)*p++ << (comp_bit_pos+16));
      //std::cout << "R3: " << std::hex << rval << std::endl;
      
      if (mContextBitPos) {
         rval |= ((unsigned int)*p++ << (comp_bit_pos+24));
         //std::cout << "R4: " << std::hex << rval << std::endl;
      }
      
      unsigned int mask = g_mask[n-1]; 
      
      rval &= mask;

      if (mEndianess) {
         unsigned int temp1 = 0;
         unsigned int temp2 = 0;
         unsigned int temp3 = 0;
         unsigned int temp4 = 0;

         if (n == 16) {
            temp1 = rval >> 8;

            rval = temp1 | ((rval & 0xFF) << 8);
         }
         else if (n == 24) {
            temp1 = rval & 0xFF;     // First byte
            temp2 = rval & 0xFF0000; // Third byte

            rval  = (temp1 << 16) | (rval & 0xFF00) | (temp2 >> 16);  
         }
         else if (n == 32) {
            temp1 = rval & 0xFF;        // First byte
            temp2 = rval & 0xFF00;      // Second byte            
            temp3 = rval & 0xFF0000;    // Third byte
            temp4 = rval & 0xFF000000;  // Fourth byte
            
            rval = (temp1 << 24) | (temp2 << 8) | (temp3 >> 8) | (temp4 >> 24);
         }
      }

      return rval;
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x10(%rbp)
movq (%rax), %rcx
movl 0x10(%rax), %edx
addq %rdx, %rcx
movq %rcx, -0x18(%rbp)
movzbl 0xc(%rax), %edx
movl $0x8, %ecx
subl %edx, %ecx
movb %cl, -0x19(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movzbl (%rcx), %edx
movzbl 0xc(%rax), %ecx
shrl %cl, %edx
movl %edx, %ecx
orl -0x10(%rbp), %ecx
movl %ecx, -0x10(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movzbl (%rcx), %edx
movzbl -0x19(%rbp), %ecx
shll %cl, %edx
movl %edx, %ecx
orl -0x10(%rbp), %ecx
movl %ecx, -0x10(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movzbl (%rcx), %edx
movzbl -0x19(%rbp), %ecx
addl $0x8, %ecx
shll %cl, %edx
movl %edx, %ecx
orl -0x10(%rbp), %ecx
movl %ecx, -0x10(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movzbl (%rcx), %edx
movzbl -0x19(%rbp), %ecx
addl $0x10, %ecx
shll %cl, %edx
movl %edx, %ecx
orl -0x10(%rbp), %ecx
movl %ecx, -0x10(%rbp)
cmpb $0x0, 0xc(%rax)
je 0x57f5
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movzbl (%rax), %eax
movzbl -0x19(%rbp), %ecx
addl $0x18, %ecx
shll %cl, %eax
orl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x38(%rbp), %rax
movzbl -0x9(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rdx
leaq 0xb9e6(%rip), %rcx      # 0x111f0
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x20(%rbp)
movl -0x20(%rbp), %ecx
andl -0x10(%rbp), %ecx
movl %ecx, -0x10(%rbp)
testb $0x1, 0x14(%rax)
je 0x5903
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movzbl -0x9(%rbp), %eax
cmpl $0x10, %eax
jne 0x586a
movl -0x10(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x10(%rbp), %ecx
andl $0xff, %ecx
shll $0x8, %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
jmp 0x5901
movzbl -0x9(%rbp), %eax
cmpl $0x18, %eax
jne 0x58a7
movl -0x10(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x24(%rbp)
movl -0x10(%rbp), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
shll $0x10, %eax
movl -0x10(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %ecx, %eax
movl -0x28(%rbp), %ecx
shrl $0x10, %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
jmp 0x58ff
movzbl -0x9(%rbp), %eax
cmpl $0x20, %eax
jne 0x58fd
movl -0x10(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x24(%rbp)
movl -0x10(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
movl %eax, -0x28(%rbp)
movl -0x10(%rbp), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
movl %eax, -0x2c(%rbp)
movl -0x10(%rbp), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
shll $0x18, %eax
movl -0x28(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
shrl $0x8, %ecx
orl %ecx, %eax
movl -0x30(%rbp), %ecx
shrl $0x18, %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
jmp 0x58ff
jmp 0x5901
jmp 0x5903
movl -0x10(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)