// File: salleaffaire[P]MXFParser/./mxf_base.hpp
// Function: mxf_file::decode_body_partition_pack(klv_item&)
int decode_body_partition_pack(klv_item &klv) {
      int rval = 0;
      
      bit_extractor be(klv.mValue, klv.mLength, BE_BIG_ENDIAN);
      
      m_body.m_bpp.m_major_version      = be.get_bits(16);
      m_body.m_bpp.m_minor_version      = be.get_bits(16);
      m_body.m_bpp.m_kag_size           = be.get_bits(32);
      m_body.m_bpp.m_this_partition     = be.get_64bits();
      m_body.m_bpp.m_previous_partition = be.get_64bits();
      m_body.m_bpp.m_footer_partition   = be.get_64bits();
      m_body.m_bpp.m_header_byte_count  = be.get_64bits();
      m_body.m_bpp.m_index_byte_count   = be.get_64bits();
      m_body.m_bpp.m_index_sid          = be.get_bits(32);
      m_body.m_bpp.m_body_offset        = be.get_64bits();
      m_body.m_bpp.m_body_sid           = be.get_bits(32);
      
      // UL of operational Pattern
      for (int i=0;i<16;++i) {
         m_body.m_bpp.m_operational_pattern.mKey[i] = be.get_bits(8);
      }

      // UL Batch - Skip the 8 bytes 
      be.get_64bits();
      
      uint32_t nunmber_of_ul = be.get_bytes_left();
      m_body.m_bpp.m_essence_containers = new Key<16>[nunmber_of_ul];

      for (int j=0;j<nunmber_of_ul;j++) {
         for (int i=0;i<16;++i) {
            m_body.m_bpp.m_essence_containers[j].mKey[i] = be.get_bits(8);
         }  
      }

      
#if 1
      
      std::cout << "  Major Version        = " << hex_to_string(m_header.m_hpp.m_major_version)
                << std::endl;
      std::cout << "  Minor Version        = " << hex_to_string(m_header.m_hpp.m_minor_version)
                << std::endl;
      std::cout << "  KAG Size             = " << hex_to_string(m_header.m_hpp.m_kag_size)
                << std::endl;
      std::cout << "  This Partition #     = " << hex_to_string(m_header.m_hpp.m_this_partition)
                << std::endl;
      std::cout << "  Previous Partition # = " << hex_to_string(m_header.m_hpp.m_previous_partition)
                << std::endl;
      std::cout << "  Footer Partition #   = " << hex_to_string(m_header.m_hpp.m_footer_partition)
                << std::endl;
      std::cout << "  Header Byte Count    = " << hex_to_string(m_header.m_hpp.m_header_byte_count)
                << std::endl;
      std::cout << "  Index Byte Count     = " << hex_to_string(m_header.m_hpp.m_index_byte_count)
                << std::endl;
      std::cout << "  Index SID            = " << hex_to_string(m_header.m_hpp.m_index_sid)
                << std::endl;
      std::cout << "  Body Offset          = " << hex_to_string(m_header.m_hpp.m_body_offset)
                << std::endl;
      std::cout << "  Body SID             = " << hex_to_string(m_header.m_hpp.m_body_sid)
                << std::endl;
      
#endif

      return rval;
      
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
movl $0x1, %ecx
callq 0x5090
movq -0x1c0(%rbp), %rdi
movl $0x10, %esi
callq 0x51c0
movl %eax, -0x1b4(%rbp)
jmp 0x801e
movq -0x1c8(%rbp), %rax
movl -0x1b4(%rbp), %ecx
movw %cx, 0xa0(%rax)
leaq -0x30(%rbp), %rdi
movl $0x10, %esi
callq 0x51c0
movl %eax, -0x1cc(%rbp)
jmp 0x8048
movq -0x1c8(%rbp), %rax
movl -0x1cc(%rbp), %ecx
movw %cx, 0xa2(%rax)
leaq -0x30(%rbp), %rdi
movl $0x20, %esi
callq 0x51c0
movl %eax, -0x1d0(%rbp)
jmp 0x8072
movq -0x1c8(%rbp), %rax
movl -0x1d0(%rbp), %ecx
movl %ecx, 0xa4(%rax)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0xa8(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0xb0(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0xb8(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0xc0(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0xc8(%rax)
movl $0x20, %esi
callq 0x51c0
movl %eax, -0x1d4(%rbp)
jmp 0x8133
movq -0x1c8(%rbp), %rax
movl -0x1d4(%rbp), %ecx
movl %ecx, 0xd0(%rax)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x9220
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0xd8(%rax)
movl $0x20, %esi
callq 0x51c0
movl %eax, -0x1e4(%rbp)
jmp 0x8180
movq -0x1c8(%rbp), %rax
movl -0x1e4(%rbp), %ecx
movl %ecx, 0xe0(%rax)
movl $0x0, -0x40(%rbp)
cmpl $0x10, -0x40(%rbp)
jge 0x81ec
leaq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x51c0
movl %eax, -0x1f4(%rbp)
jmp 0x81b6
movq -0x1c8(%rbp), %rax
movl -0x1f4(%rbp), %ecx
movb %cl, %dl
movslq -0x40(%rbp), %rcx
movb %dl, 0xe4(%rax,%rcx)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x819a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x88cf
leaq -0x30(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x9220
movq -0x208(%rbp), %rdi
callq 0x5170
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, %edi
shlq $0x4, %rdi
callq 0x3040
movq %rax, -0x200(%rbp)
jmp 0x8222
movq -0x1c8(%rbp), %rax
movq -0x200(%rbp), %rcx
movq %rcx, 0xf8(%rax)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x82a9
movl $0x0, -0x4c(%rbp)
cmpl $0x10, -0x4c(%rbp)
jge 0x829c
leaq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x51c0
movl %eax, -0x20c(%rbp)
jmp 0x8269
movq -0x1c8(%rbp), %rax
movl -0x20c(%rbp), %ecx
movb %cl, %dl
movq 0xf8(%rax), %rax
movslq -0x48(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x4c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x824d
jmp 0x829e
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x823e
movq 0x8d28(%rip), %rdi      # 0x10fd8
leaq 0x4136(%rip), %rsi      # 0xc3ed
callq 0x31f0
movq %rax, -0x218(%rbp)
jmp 0x82c5
movq -0x1c8(%rbp), %rax
movzwl 0x18(%rax), %esi
leaq -0x70(%rbp), %rdi
callq 0x93d0
jmp 0x82db
movq -0x218(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x31d0
movq %rax, -0x220(%rbp)
jmp 0x82f4
movq -0x220(%rbp), %rdi
movq 0x8cb6(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8309
leaq -0x70(%rbp), %rdi
callq 0x33c8
movq 0x8cbf(%rip), %rdi      # 0x10fd8
leaq 0x40e7(%rip), %rsi      # 0xc407
callq 0x31f0
movq %rax, -0x228(%rbp)
jmp 0x832e
movq -0x1c8(%rbp), %rax
movzwl 0x1a(%rax), %esi
leaq -0x90(%rbp), %rdi
callq 0x93d0
jmp 0x8347
movq -0x228(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x31d0
movq %rax, -0x230(%rbp)
jmp 0x8363
movq -0x230(%rbp), %rdi
movq 0x8c47(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8378
leaq -0x90(%rbp), %rdi
callq 0x33c8
movq 0x8c4d(%rip), %rdi      # 0x10fd8
leaq 0x408f(%rip), %rsi      # 0xc421
callq 0x31f0
movq %rax, -0x238(%rbp)
jmp 0x83a0
movq -0x1c8(%rbp), %rax
movl 0x1c(%rax), %esi
leaq -0xb0(%rbp), %rdi
callq 0x9540
jmp 0x83b8
movq -0x238(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x240(%rbp)
jmp 0x83d4
movq -0x240(%rbp), %rdi
movq 0x8bd6(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x83e9
leaq -0xb0(%rbp), %rdi
callq 0x33c8
movq 0x8bdc(%rip), %rdi      # 0x10fd8
leaq 0x4038(%rip), %rsi      # 0xc43b
callq 0x31f0
movq %rax, -0x248(%rbp)
jmp 0x8411
movq -0x1c8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x9690
jmp 0x842a
movq -0x248(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x250(%rbp)
jmp 0x8446
movq -0x250(%rbp), %rdi
movq 0x8b64(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x845b
leaq -0xd0(%rbp), %rdi
callq 0x33c8
movq 0x8b6a(%rip), %rdi      # 0x10fd8
leaq 0x3fe0(%rip), %rsi      # 0xc455
callq 0x31f0
movq %rax, -0x258(%rbp)
jmp 0x8483
movq -0x1c8(%rbp), %rax
movq 0x28(%rax), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x9690
jmp 0x849c
movq -0x258(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x260(%rbp)
jmp 0x84b8
movq -0x260(%rbp), %rdi
movq 0x8af2(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x84cd
leaq -0xf0(%rbp), %rdi
callq 0x33c8
movq 0x8af8(%rip), %rdi      # 0x10fd8
leaq 0x3f88(%rip), %rsi      # 0xc46f
callq 0x31f0
movq %rax, -0x268(%rbp)
jmp 0x84f5
movq -0x1c8(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0x110(%rbp), %rdi
callq 0x9690
jmp 0x850e
movq -0x268(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x31d0
movq %rax, -0x270(%rbp)
jmp 0x852a
movq -0x270(%rbp), %rdi
movq 0x8a80(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x853f
leaq -0x110(%rbp), %rdi
callq 0x33c8
movq 0x8a86(%rip), %rdi      # 0x10fd8
leaq 0x3f30(%rip), %rsi      # 0xc489
callq 0x31f0
movq %rax, -0x278(%rbp)
jmp 0x8567
movq -0x1c8(%rbp), %rax
movq 0x38(%rax), %rsi
leaq -0x130(%rbp), %rdi
callq 0x9690
jmp 0x8580
movq -0x278(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x31d0
movq %rax, -0x280(%rbp)
jmp 0x859c
movq -0x280(%rbp), %rdi
movq 0x8a0e(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x85b1
leaq -0x130(%rbp), %rdi
callq 0x33c8
movq 0x8a14(%rip), %rdi      # 0x10fd8
leaq 0x3ed8(%rip), %rsi      # 0xc4a3
callq 0x31f0
movq %rax, -0x288(%rbp)
jmp 0x85d9
movq -0x1c8(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x150(%rbp), %rdi
callq 0x9690
jmp 0x85f2
movq -0x288(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x31d0
movq %rax, -0x290(%rbp)
jmp 0x860e
movq -0x290(%rbp), %rdi
movq 0x899c(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8623
leaq -0x150(%rbp), %rdi
callq 0x33c8
movq 0x89a2(%rip), %rdi      # 0x10fd8
leaq 0x3e80(%rip), %rsi      # 0xc4bd
callq 0x31f0
movq %rax, -0x298(%rbp)
jmp 0x864b
movq -0x1c8(%rbp), %rax
movl 0x48(%rax), %esi
leaq -0x170(%rbp), %rdi
callq 0x9540
jmp 0x8663
movq -0x298(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x31d0
movq %rax, -0x2a0(%rbp)
jmp 0x867f
movq -0x2a0(%rbp), %rdi
movq 0x892b(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8694
leaq -0x170(%rbp), %rdi
callq 0x33c8
movq 0x8931(%rip), %rdi      # 0x10fd8
leaq 0x3e29(%rip), %rsi      # 0xc4d7
callq 0x31f0
movq %rax, -0x2a8(%rbp)
jmp 0x86bc
movq -0x1c8(%rbp), %rax
movq 0x50(%rax), %rsi
leaq -0x190(%rbp), %rdi
callq 0x9690
jmp 0x86d5
movq -0x2a8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x31d0
movq %rax, -0x2b0(%rbp)
jmp 0x86f1
movq -0x2b0(%rbp), %rdi
movq 0x88b9(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8706
leaq -0x190(%rbp), %rdi
callq 0x33c8
movq 0x88bf(%rip), %rdi      # 0x10fd8
leaq 0x3dd1(%rip), %rsi      # 0xc4f1
callq 0x31f0
movq %rax, -0x2b8(%rbp)
jmp 0x872e
movq -0x1c8(%rbp), %rax
movl 0x58(%rax), %esi
leaq -0x1b0(%rbp), %rdi
callq 0x9540
jmp 0x8746
movq -0x2b8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x2c0(%rbp)
jmp 0x8762
movq -0x2c0(%rbp), %rdi
movq 0x8848(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8777
leaq -0x1b0(%rbp), %rdi
callq 0x33c8
movl -0x14(%rbp), %eax
movl %eax, -0x2c4(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x51b0
movl -0x2c4(%rbp), %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x33c8
jmp 0x88cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x33c8
leaq -0x30(%rbp), %rdi
callq 0x51b0
movq -0x38(%rbp), %rdi
callq 0x3380
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)