// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r15
callq 0x4b50
leaq 0x138(%r15), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4be2
testq %rax, %rax
je 0x3919
movq %rax, %r12
movq 0x10(%rax), %rax
leaq 0x108(%r15), %rcx
addq $0xd8, %r15
cmpl $0x1, 0x14(%rax)
cmovneq %rcx, %r15
movq 0x8(%rbx), %rcx
leaq 0x8(%rax), %rsi
cmpq 0x8(%rax), %rcx
jne 0x3926
movl 0x10(%rbx), %ebp
movl 0x10(%rax), %r13d
movq %r15, %rdi
callq 0x4b8c
movq %rax, %r15
cmpl %r13d, %ebp
jbe 0x39b7
addq $0x28, %r15
movq 0x10(%r12), %rsi
movq %r15, %rdi
callq 0x3036
movq 0x10(%r12), %rdi
callq 0x21a0
movq %r14, %rdi
movq %r12, %rsi
callq 0x30fc
movq %r15, %rdi
jmp 0x3992
callq 0x2842
incl 0xc(%rax)
jmp 0x39cb
movq %r15, %rdi
callq 0x4b8c
movq %rax, %r13
leaq 0x28(%rax), %rdi
movq 0x10(%r12), %rsi
callq 0x3036
movq 0x10(%r12), %rdi
callq 0x21a0
movq %r14, %rdi
movq %r12, %rsi
callq 0x30fc
cmpl $0x0, 0x40(%r13)
jne 0x3966
movq %r15, %rdi
movq %r13, %rsi
callq 0x4c5e
xorps %xmm0, %xmm0
movq %rsp, %rsi
movups %xmm0, 0x10(%rsi)
movq 0x8(%rbx), %rax
movq %rax, (%rsi)
leaq 0x63da(%rip), %rax      # 0x9d58
movq %rax, 0x8(%rsi)
andl $0x0, 0x20(%rsi)
movq %r15, %rdi
callq 0x5192
leaq 0x28(%rax), %rdi
movq %rbx, %rsi
callq 0x5170
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5344
movq %rbx, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r12), %rax
movl 0x10(%rbx), %ecx
movl %ecx, %edx
subl 0x10(%rax), %edx
addl %edx, 0x40(%r15)
movl %ecx, 0x10(%rax)
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21a0
nop