// File: benjibc[P]json-universal-container/./boost_file/boost/container/vector.hpp
// Function: void boost::container::vector<JSON, std::allocator<JSON>>::priv_assign_aux<JSON*>(JSON*, JSON*, std::forward_iterator_tag)
void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag)
   {
      size_type n = std::distance(first, last);
      if(!n){
         this->prot_destroy_all();
         return;
      }
      //Check if we have enough memory or try to expand current memory
      size_type remaining = this->members_.m_capacity - this->members_.m_size;
      bool same_buffer_start;
      std::pair<pointer, bool> ret;
      size_type real_cap = this->members_.m_capacity;

      if (n <= remaining){
         same_buffer_start = true;
      }
      else{
         //There is not enough memory, allocate a new buffer
         size_type new_cap = this->next_capacity(n);
         ret = this->allocation_command
               (allocate_new | expand_fwd | expand_bwd,
                  this->size() + n, new_cap, real_cap, this->members_.m_start);
         same_buffer_start = ret.second && this->members_.m_start == ret.first;
         if(same_buffer_start){
            this->members_.m_capacity  = real_cap;
         }
      }
     
      if(same_buffer_start){
         T *start = container_detail::to_raw_pointer(this->members_.m_start);
         if (this->size() >= n){
            //There is memory, but there are more old elements than new ones
            //Overwrite old elements with new ones
            std::copy(first, last, start);
            //Destroy remaining old elements
            this->destroy_n(start + n, this->members_.m_size - n);
            this->members_.m_size = n;
         }
         else{
            //There is memory, but there are less old elements than new ones
            //First overwrite some old elements with new ones
            FwdIt mid = first;
            std::advance(mid, this->size());
            // iG T *end = std::copy(first, mid, start);
            T *end = std::copy(first, mid, start);
            //Initialize the remaining new elements in the uninitialized memory
            ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), mid, last, end);
            this->members_.m_size = n;
         }
      }
      else if(!ret.second){
         typename value_traits::ArrayDeallocator scoped_alloc(ret.first, this->alloc(), real_cap);
         ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), first, last, container_detail::to_raw_pointer(ret.first));
         scoped_alloc.release();
         //Destroy and deallocate old buffer
         if(this->members_.m_start != 0){
            this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
            this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
         }
         this->members_.m_start     = ret.first;
         this->members_.m_size      = n;
         this->members_.m_capacity  = real_cap;
      }
      else{
         //Backwards expansion
         //If anything goes wrong, this object will destroy old objects
         T *old_start         = container_detail::to_raw_pointer(this->members_.m_start);
         size_type old_size   = this->members_.m_size;
         typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
         //If something goes wrong size will be 0
         //but holding the whole buffer
         this->members_.m_size  = 0;
         this->members_.m_start = ret.first;
         this->members_.m_capacity = real_cap;
        
         //Backup old buffer data
         size_type old_offset    = old_start - container_detail::to_raw_pointer(ret.first);
         size_type first_count   = container_detail::min_value(n, old_offset);

         FwdIt mid = first;
         std::advance(mid, first_count);
         ::boost::container::uninitialized_copy_or_move_alloc
            (this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));

         if(old_offset > n){
            //All old elements will be destroyed by "old_values_destroyer"
            this->members_.m_size = n;
         }
         else{
            //We have constructed objects from the new begin until
            //the old end so release the rollback destruction
            old_values_destroyer.release();
            this->members_.m_start  = ret.first;
            this->members_.m_size   = first_count + old_size;
            //Now overwrite the old values
            size_type second_count = container_detail::min_value(old_size, n - first_count);
            FwdIt mid2 = mid;
            std::advance(mid2, second_count);
            // iG std::copy(mid, mid2, old_start);
            std::copy(mid, mid2, old_start);
           
            //Check if we still have to append elements in the
            //uninitialized end
            if(second_count == old_size){
               // iG std::copy(mid2, last, old_start + old_size);
               std::copy(mid2, last, old_start + old_size);
            }
            else{
               //We have to destroy some old values
               this->destroy_n
                  (old_start + second_count, old_size - second_count);
               this->members_.m_size = n;
            }
            this->members_.m_size = n;                       
         }
      }
   }

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x168(%rsp)
movq %rsi, 0x160(%rsp)
movq %rdx, 0x158(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x160(%rsp), %rdi
movq 0x158(%rsp), %rsi
callq 0x10650
movq %rax, 0x150(%rsp)
cmpq $0x0, 0x150(%rsp)
jne 0xff93
movq 0x60(%rsp), %rdi
callq 0xe1f0
jmp 0x10639
movq 0x60(%rsp), %rcx
movq 0x10(%rcx), %rax
subq 0x8(%rcx), %rax
movq %rax, 0x148(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x9980
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x128(%rsp)
movq 0x150(%rsp), %rax
cmpq 0x148(%rsp), %rax
ja 0xffe5
movb $0x1, 0x147(%rsp)
jmp 0x100cc
movq 0x60(%rsp), %rdi
movq 0x150(%rsp), %rsi
callq 0x99a0
movq 0x60(%rsp), %rdi
movq %rax, 0x120(%rsp)
callq 0xda20
movq 0x60(%rsp), %r9
movq %rax, %rdx
movq 0x150(%rsp), %rax
addq %rax, %rdx
movq 0x120(%rsp), %rcx
movl $0x7, %esi
leaq 0x128(%rsp), %r8
movq %r9, %rdi
callq 0x99e0
movb %dl, 0x108(%rsp)
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x110(%rsp)
movb 0x108(%rsp), %al
movb %al, 0x118(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x9a50
xorl %eax, %eax
testb $0x1, 0x138(%rsp)
movb %al, 0x5f(%rsp)
je 0x100a2
movq 0x60(%rsp), %rax
movq (%rax), %rax
cmpq 0x130(%rsp), %rax
sete %al
movb %al, 0x5f(%rsp)
movb 0x5f(%rsp), %al
andb $0x1, %al
movb %al, 0x147(%rsp)
testb $0x1, 0x147(%rsp)
je 0x100ca
movq 0x60(%rsp), %rax
movq 0x128(%rsp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x100cc
testb $0x1, 0x147(%rsp)
je 0x101f4
movq 0x60(%rsp), %rax
movq (%rax), %rdi
callq 0x85b0
movq 0x60(%rsp), %rdi
movq %rax, 0xf8(%rsp)
callq 0xda20
cmpq 0x150(%rsp), %rax
jb 0x10160
movq 0x160(%rsp), %rdi
movq 0x158(%rsp), %rsi
movq 0xf8(%rsp), %rdx
callq 0x10690
movq 0x60(%rsp), %rdi
movq 0xf8(%rsp), %rsi
imulq $0x30, 0x150(%rsp), %rax
addq %rax, %rsi
movq 0x8(%rdi), %rdx
subq 0x150(%rsp), %rdx
callq 0xae90
movq 0x60(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x101ef
movq 0x60(%rsp), %rdi
movq 0x160(%rsp), %rax
movq %rax, 0xf0(%rsp)
callq 0xda20
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
callq 0x106e0
movq 0x160(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
callq 0x10690
movq 0x60(%rsp), %rdi
movq %rax, 0xe8(%rsp)
callq 0x85a0
movq %rax, %rdi
movq 0xf0(%rsp), %rsi
movq 0x158(%rsp), %rdx
movq 0xe8(%rsp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x10730
movq 0x60(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x10639
testb $0x1, 0x138(%rsp)
jne 0x10342
movq 0x60(%rsp), %rdi
movq 0x130(%rsp), %rax
movq %rax, 0x38(%rsp)
callq 0x85a0
movq 0x38(%rsp), %rsi
movq %rax, %rdx
movq 0x128(%rsp), %rcx
leaq 0xd0(%rsp), %rdi
callq 0xaff0
movq 0x60(%rsp), %rdi
callq 0x85a0
movq %rax, 0x40(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x130(%rsp), %rdi
callq 0x85b0
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x10730
jmp 0x1028a
leaq 0xd0(%rsp), %rdi
callq 0xb080
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x10308
movq 0x60(%rsp), %rax
movq (%rax), %rdi
callq 0x85b0
movq 0x60(%rsp), %rdi
movq %rax, %rsi
movq 0x8(%rdi), %rdx
callq 0xae90
jmp 0x102c2
movq 0x60(%rsp), %rdi
callq 0x85a0
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xb050
jmp 0x10308
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xb0a0
jmp 0x10641
movq 0x60(%rsp), %rax
movq 0x130(%rsp), %rcx
movq %rcx, (%rax)
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0x128(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0xd0(%rsp), %rdi
callq 0xb0a0
jmp 0x10637
movq 0x60(%rsp), %rax
movq (%rax), %rdi
callq 0x85b0
movq 0x60(%rsp), %rdi
movq %rax, 0xb8(%rsp)
movq 0x8(%rdi), %rax
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0x85a0
movq 0x20(%rsp), %rsi
movq %rax, %rdx
movq 0xb0(%rsp), %rcx
leaq 0x98(%rsp), %rdi
callq 0xadd0
movq 0x60(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x130(%rsp), %rcx
movq %rcx, (%rax)
movq 0x128(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0xb8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x130(%rsp), %rdi
callq 0x85b0
movq %rax, %rcx
movq 0x28(%rsp), %rax
subq %rcx, %rax
sarq $0x4, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
movq %rax, 0x90(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x10770
movq %rax, 0x30(%rsp)
jmp 0x10416
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x88(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x106e0
jmp 0x1044d
movq 0x60(%rsp), %rdi
callq 0x85a0
movq %rax, 0x8(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x130(%rsp), %rdi
callq 0x85b0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x10730
jmp 0x104a1
movq 0x90(%rsp), %rax
cmpq 0x150(%rsp), %rax
jbe 0x104ef
movq 0x60(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x1062a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0x98(%rsp), %rdi
callq 0xaef0
jmp 0x10641
leaq 0x98(%rsp), %rdi
callq 0xae10
movq 0x60(%rsp), %rax
movq 0x130(%rsp), %rcx
movq %rcx, (%rax)
movq 0x88(%rsp), %rcx
movq 0xb0(%rsp), %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq 0x150(%rsp), %rax
movq 0x88(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x70(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x10770
movq %rax, (%rsp)
jmp 0x10553
movq (%rsp), %rax
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x78(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x106e0
jmp 0x1057d
movq 0x80(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0xb8(%rsp), %rdx
callq 0x10690
jmp 0x10599
movq 0x78(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jne 0x105d9
movq 0x68(%rsp), %rdi
movq 0x158(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xb0(%rsp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rax, %rdx
callq 0x10690
jmp 0x105d7
jmp 0x10619
movq 0x60(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0x78(%rsp), %rax
leaq (%rax,%rax,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rsi
movq 0xb0(%rsp), %rdx
subq %rax, %rdx
callq 0xae90
jmp 0x10608
movq 0x60(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x98(%rsp), %rdi
callq 0xaef0
jmp 0x10639
addq $0x178, %rsp            # imm = 0x178
retq
movq 0xc8(%rsp), %rdi
callq 0x33e0
nop