// File: salleaffaire[P]MXFParser/./mxf_base.hpp
// Function: mxf_file::decode_footer_partition_pack(klv_item&)
int decode_footer_partition_pack(klv_item &klv) {
      int rval = 0;
      
      bit_extractor be(klv.mValue, klv.mLength, BE_BIG_ENDIAN);
      
      m_footer.m_fpp.m_major_version      = be.get_bits(16);
      m_footer.m_fpp.m_minor_version      = be.get_bits(16);
      m_footer.m_fpp.m_kag_size           = be.get_bits(32);
      m_footer.m_fpp.m_this_partition     = be.get_64bits();
      m_footer.m_fpp.m_previous_partition = be.get_64bits();
      m_footer.m_fpp.m_footer_partition   = be.get_64bits();
      m_footer.m_fpp.m_header_byte_count  = be.get_64bits();
      m_footer.m_fpp.m_index_byte_count   = be.get_64bits();
      m_footer.m_fpp.m_index_sid          = be.get_bits(32);
      m_footer.m_fpp.m_body_offset        = be.get_64bits();
      m_footer.m_fpp.m_body_sid           = be.get_bits(32);
      
      // UL of operational Pattern
      for (int i=0;i<16;++i) {
         m_footer.m_fpp.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_footer.m_fpp.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_footer.m_fpp.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 0x894e
movq -0x1c8(%rbp), %rax
movl -0x1b4(%rbp), %ecx
movw %cx, 0x110(%rax)
leaq -0x30(%rbp), %rdi
movl $0x10, %esi
callq 0x51c0
movl %eax, -0x1cc(%rbp)
jmp 0x8978
movq -0x1c8(%rbp), %rax
movl -0x1cc(%rbp), %ecx
movw %cx, 0x112(%rax)
leaq -0x30(%rbp), %rdi
movl $0x20, %esi
callq 0x51c0
movl %eax, -0x1d0(%rbp)
jmp 0x89a2
movq -0x1c8(%rbp), %rax
movl -0x1d0(%rbp), %ecx
movl %ecx, 0x114(%rax)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0x118(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0x120(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0x128(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0x130(%rax)
callq 0x9220
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0x138(%rax)
movl $0x20, %esi
callq 0x51c0
movl %eax, -0x1d4(%rbp)
jmp 0x8a63
movq -0x1c8(%rbp), %rax
movl -0x1d4(%rbp), %ecx
movl %ecx, 0x140(%rax)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x9220
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movq %rcx, 0x148(%rax)
movl $0x20, %esi
callq 0x51c0
movl %eax, -0x1e4(%rbp)
jmp 0x8ab0
movq -0x1c8(%rbp), %rax
movl -0x1e4(%rbp), %ecx
movl %ecx, 0x150(%rax)
movl $0x0, -0x40(%rbp)
cmpl $0x10, -0x40(%rbp)
jge 0x8b1c
leaq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x51c0
movl %eax, -0x1f4(%rbp)
jmp 0x8ae6
movq -0x1c8(%rbp), %rax
movl -0x1f4(%rbp), %ecx
movb %cl, %dl
movslq -0x40(%rbp), %rcx
movb %dl, 0x154(%rax,%rcx)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x8aca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x91ff
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 0x8b52
movq -0x1c8(%rbp), %rax
movq -0x200(%rbp), %rcx
movq %rcx, 0x168(%rax)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x8bd9
movl $0x0, -0x4c(%rbp)
cmpl $0x10, -0x4c(%rbp)
jge 0x8bcc
leaq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x51c0
movl %eax, -0x20c(%rbp)
jmp 0x8b99
movq -0x1c8(%rbp), %rax
movl -0x20c(%rbp), %ecx
movb %cl, %dl
movq 0x168(%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 0x8b7d
jmp 0x8bce
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x8b6e
movq 0x83f8(%rip), %rdi      # 0x10fd8
leaq 0x3806(%rip), %rsi      # 0xc3ed
callq 0x31f0
movq %rax, -0x218(%rbp)
jmp 0x8bf5
movq -0x1c8(%rbp), %rax
movzwl 0x18(%rax), %esi
leaq -0x70(%rbp), %rdi
callq 0x93d0
jmp 0x8c0b
movq -0x218(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x31d0
movq %rax, -0x220(%rbp)
jmp 0x8c24
movq -0x220(%rbp), %rdi
movq 0x8386(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8c39
leaq -0x70(%rbp), %rdi
callq 0x33c8
movq 0x838f(%rip), %rdi      # 0x10fd8
leaq 0x37b7(%rip), %rsi      # 0xc407
callq 0x31f0
movq %rax, -0x228(%rbp)
jmp 0x8c5e
movq -0x1c8(%rbp), %rax
movzwl 0x1a(%rax), %esi
leaq -0x90(%rbp), %rdi
callq 0x93d0
jmp 0x8c77
movq -0x228(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x31d0
movq %rax, -0x230(%rbp)
jmp 0x8c93
movq -0x230(%rbp), %rdi
movq 0x8317(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8ca8
leaq -0x90(%rbp), %rdi
callq 0x33c8
movq 0x831d(%rip), %rdi      # 0x10fd8
leaq 0x375f(%rip), %rsi      # 0xc421
callq 0x31f0
movq %rax, -0x238(%rbp)
jmp 0x8cd0
movq -0x1c8(%rbp), %rax
movl 0x1c(%rax), %esi
leaq -0xb0(%rbp), %rdi
callq 0x9540
jmp 0x8ce8
movq -0x238(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x240(%rbp)
jmp 0x8d04
movq -0x240(%rbp), %rdi
movq 0x82a6(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8d19
leaq -0xb0(%rbp), %rdi
callq 0x33c8
movq 0x82ac(%rip), %rdi      # 0x10fd8
leaq 0x3708(%rip), %rsi      # 0xc43b
callq 0x31f0
movq %rax, -0x248(%rbp)
jmp 0x8d41
movq -0x1c8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x9690
jmp 0x8d5a
movq -0x248(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x250(%rbp)
jmp 0x8d76
movq -0x250(%rbp), %rdi
movq 0x8234(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8d8b
leaq -0xd0(%rbp), %rdi
callq 0x33c8
movq 0x823a(%rip), %rdi      # 0x10fd8
leaq 0x36b0(%rip), %rsi      # 0xc455
callq 0x31f0
movq %rax, -0x258(%rbp)
jmp 0x8db3
movq -0x1c8(%rbp), %rax
movq 0x28(%rax), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x9690
jmp 0x8dcc
movq -0x258(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x260(%rbp)
jmp 0x8de8
movq -0x260(%rbp), %rdi
movq 0x81c2(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8dfd
leaq -0xf0(%rbp), %rdi
callq 0x33c8
movq 0x81c8(%rip), %rdi      # 0x10fd8
leaq 0x3658(%rip), %rsi      # 0xc46f
callq 0x31f0
movq %rax, -0x268(%rbp)
jmp 0x8e25
movq -0x1c8(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0x110(%rbp), %rdi
callq 0x9690
jmp 0x8e3e
movq -0x268(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x31d0
movq %rax, -0x270(%rbp)
jmp 0x8e5a
movq -0x270(%rbp), %rdi
movq 0x8150(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8e6f
leaq -0x110(%rbp), %rdi
callq 0x33c8
movq 0x8156(%rip), %rdi      # 0x10fd8
leaq 0x3600(%rip), %rsi      # 0xc489
callq 0x31f0
movq %rax, -0x278(%rbp)
jmp 0x8e97
movq -0x1c8(%rbp), %rax
movq 0x38(%rax), %rsi
leaq -0x130(%rbp), %rdi
callq 0x9690
jmp 0x8eb0
movq -0x278(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x31d0
movq %rax, -0x280(%rbp)
jmp 0x8ecc
movq -0x280(%rbp), %rdi
movq 0x80de(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8ee1
leaq -0x130(%rbp), %rdi
callq 0x33c8
movq 0x80e4(%rip), %rdi      # 0x10fd8
leaq 0x35a8(%rip), %rsi      # 0xc4a3
callq 0x31f0
movq %rax, -0x288(%rbp)
jmp 0x8f09
movq -0x1c8(%rbp), %rax
movq 0x40(%rax), %rsi
leaq -0x150(%rbp), %rdi
callq 0x9690
jmp 0x8f22
movq -0x288(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x31d0
movq %rax, -0x290(%rbp)
jmp 0x8f3e
movq -0x290(%rbp), %rdi
movq 0x806c(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8f53
leaq -0x150(%rbp), %rdi
callq 0x33c8
movq 0x8072(%rip), %rdi      # 0x10fd8
leaq 0x3550(%rip), %rsi      # 0xc4bd
callq 0x31f0
movq %rax, -0x298(%rbp)
jmp 0x8f7b
movq -0x1c8(%rbp), %rax
movl 0x48(%rax), %esi
leaq -0x170(%rbp), %rdi
callq 0x9540
jmp 0x8f93
movq -0x298(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x31d0
movq %rax, -0x2a0(%rbp)
jmp 0x8faf
movq -0x2a0(%rbp), %rdi
movq 0x7ffb(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x8fc4
leaq -0x170(%rbp), %rdi
callq 0x33c8
movq 0x8001(%rip), %rdi      # 0x10fd8
leaq 0x34f9(%rip), %rsi      # 0xc4d7
callq 0x31f0
movq %rax, -0x2a8(%rbp)
jmp 0x8fec
movq -0x1c8(%rbp), %rax
movq 0x50(%rax), %rsi
leaq -0x190(%rbp), %rdi
callq 0x9690
jmp 0x9005
movq -0x2a8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x31d0
movq %rax, -0x2b0(%rbp)
jmp 0x9021
movq -0x2b0(%rbp), %rdi
movq 0x7f89(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x9036
leaq -0x190(%rbp), %rdi
callq 0x33c8
movq 0x7f8f(%rip), %rdi      # 0x10fd8
leaq 0x34a1(%rip), %rsi      # 0xc4f1
callq 0x31f0
movq %rax, -0x2b8(%rbp)
jmp 0x905e
movq -0x1c8(%rbp), %rax
movl 0x58(%rax), %esi
leaq -0x1b0(%rbp), %rdi
callq 0x9540
jmp 0x9076
movq -0x2b8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x2c0(%rbp)
jmp 0x9092
movq -0x2c0(%rbp), %rdi
movq 0x7f18(%rip), %rsi      # 0x10fb8
callq 0x3230
jmp 0x90a7
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 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x33c8
jmp 0x91ff
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)