// File: /workspace/github_c_makefile_star2_O3/aspone[P]OrderBook/./OrderBook.h
// Function: OrderBook::OrderBook<unsigned int, OrderLevelEntry>::modifyOrder(OrderLevelEntry*)
void modifyOrder(ORDERTYPE* ole) {
      checkCross();

      auto ooit = orders_.find(ole->order_id_);
      if (ooit == orders_.end()) {
         FHErrorTracker::instance()->invalidModify();
         delete ole;
         return;
      }

      OrderListMap &map = ooit->second->order_side_ == eS_Buy ? buy_book_map_ : sell_book_map_;

      if (ole->order_price_ == ooit->second->order_price_) {
         // Cancel reduce, retain time priority
         if (ole->order_qty_ <= ooit->second->order_qty_) {
            typename OrderListMap::iterator pit = map.find(ooit->second->order_price_);
            pit->second.changeNodeQuantity(ooit->second, ole->order_qty_);
            delete ole;
         }
         // Cancel replace, remove and re-add at back of list
         else {
            typename OrderListMap::iterator pit = map.find(ooit->second->order_price_);
            pit->second.removeNode(ooit->second);
            delete ooit->second;
            orders_.erase(ooit);

            pit->second.addNode(ole);
            orders_[ole->order_id_] = ole;
         }
      }
      // Price change - remove from old level and insert in new
      else {
         typename OrderListMap::iterator opit = map.find(ooit->second->order_price_);
         opit->second.removeNode(ooit->second);
         delete ooit->second;
         orders_.erase(ooit);

         if (opit->second.getQuantity() == 0) {
            map.erase(opit);
         }

         std::pair<typename OrderListMap::iterator, bool> ret;
         ret = map.insert(
            std::pair<unsigned long long, CountedOrderList<ORDERTYPE>>(
               ole->order_price_, CountedOrderList<ORDERTYPE>()));
         ret.first->second.addNode(ole);
         orders_[ole->order_id_] = ole;
      }
   }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %rbx
movq %rdi, %r12
callq 0x5286
leaq 0x138(%r12), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x52ec
testq %rax, %rax
je 0x3f40
movq %rax, %r15
movq 0x10(%rax), %rsi
leaq 0x108(%r12), %rax
addq $0xd8, %r12
cmpl $0x1, 0x14(%rsi)
cmovneq %rax, %r12
movq 0x8(%rbx), %rax
movq 0x8(%rsi), %rcx
cmpq %rcx, %rax
jne 0x3f76
movl 0x10(%rbx), %edx
movl 0x10(%rsi), %r8d
leaq 0x8(%r12), %r13
movl %edx, %edi
movq 0x10(%r12), %rcx
subl %r8d, %edi
jbe 0x4029
testq %rcx, %rcx
je 0x3efe
movq %r13, %rdx
xorl %edi, %edi
cmpq %rax, 0x20(%rcx)
setb %dil
cmovaeq %rcx, %rdx
movq 0x10(%rcx,%rdi,8), %rcx
testq %rcx, %rcx
jne 0x3ed9
cmpq %r13, %rdx
je 0x3efe
cmpq 0x20(%rdx), %rax
cmovaeq %rdx, %r13
leaq 0x28(%r13), %rdi
subl %r8d, 0x40(%r13)
callq 0x3170
movq 0x10(%r15), %rdi
callq 0x21c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x3232
movl 0x10(%rbx), %eax
addl %eax, 0x40(%r13)
movq 0x30(%r13), %rax
testq %rax, %rax
je 0x407d
movq %rbx, 0x18(%rax)
movq %rax, 0x20(%rbx)
jmp 0x4081
leaq 0x7279(%rip), %r14      # 0xb1c0
movq (%r14), %rax
testq %rax, %rax
jne 0x3f6e
movl $0x28, %edi
callq 0x21f0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x20(%rax)
movq %rax, (%r14)
incl 0xc(%rax)
jmp 0x405e
movq 0x10(%r12), %rdx
leaq 0x8(%r12), %r13
testq %rdx, %rdx
je 0x3fad
movq %r13, %rax
xorl %edi, %edi
cmpq %rcx, 0x20(%rdx)
setb %dil
cmovaeq %rdx, %rax
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x3f88
cmpq %r13, %rax
je 0x3fad
cmpq 0x20(%rax), %rcx
cmovaeq %rax, %r13
leaq 0x28(%r13), %rdi
movl 0x10(%rsi), %eax
subl %eax, 0x40(%r13)
callq 0x3170
movq 0x10(%r15), %rdi
callq 0x21c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x3232
cmpl $0x0, 0x40(%r13)
jne 0x3fe3
movq %r12, %rdi
movq %r13, %rsi
callq 0x5348
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %rsi
movups %xmm0, 0x10(%rsi)
movq 0x8(%rbx), %rax
movq %rax, (%rsi)
leaq 0x6d7b(%rip), %rax      # 0xad78
movq %rax, 0x8(%rsi)
movl $0x0, 0x20(%rsi)
movq %r12, %rdi
callq 0x5958
movl 0x10(%rbx), %ecx
addl %ecx, 0x40(%rax)
movq 0x30(%rax), %rcx
testq %rcx, %rcx
je 0x4073
movq %rbx, 0x18(%rcx)
movq %rcx, 0x20(%rbx)
jmp 0x4077
testq %rcx, %rcx
je 0x4057
movq %r13, %r8
xorl %r9d, %r9d
cmpq %rax, 0x20(%rcx)
setb %r9b
cmovaeq %rcx, %r8
movq 0x10(%rcx,%r9,8), %rcx
testq %rcx, %rcx
jne 0x4031
cmpq %r13, %r8
je 0x4057
cmpq 0x20(%r8), %rax
cmovaeq %r8, %r13
addl %edi, 0x40(%r13)
movl %edx, 0x10(%rsi)
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x21c0
movq %rbx, 0x38(%rax)
movq %rbx, 0x30(%rax)
jmp 0x4085
movq %rbx, 0x38(%r13)
movq %rbx, 0x30(%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5ab6
movq %rbx, (%rax)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop