// File: /workspace/github_c_makefile_star2_O1/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 0x54d8
leaq 0x138(%r12), %r14
movl (%rbx), %ecx
xorl %r15d, %r15d
movq %rcx, %rax
xorl %edx, %edx
divq 0x140(%r12)
movq %r14, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
callq 0x553e
testq %rax, %rax
je 0x3f82
movq (%rax), %r15
testq %r15, %r15
je 0x404b
movq 0x10(%r15), %rsi
leaq 0x108(%r12), %rax
addq $0xd8, %r12
cmpl $0x1, 0x14(%rsi)
cmovneq %rax, %r12
movq 0x8(%rsi), %rax
cmpq %rax, 0x8(%rbx)
jne 0x4082
movl 0x10(%rbx), %edx
movl 0x10(%rsi), %r8d
leaq 0x8(%r12), %r13
movl %edx, %edi
movq 0x10(%r12), %rcx
subl %r8d, %edi
jbe 0x4141
movq %r13, %rdx
testq %rcx, %rcx
je 0x3ff3
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 0x3fdb
cmpq %r13, %rdx
je 0x4000
cmpq 0x20(%rdx), %rax
cmovaeq %rdx, %r13
leaq 0x28(%r13), %rdi
subl %r8d, 0x40(%r13)
callq 0x3206
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x401b
callq 0x21c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x32c8
movl 0x10(%rbx), %eax
addl %eax, 0x40(%r13)
movq 0x30(%r13), %rax
testq %rax, %rax
je 0x419b
addq $0x30, %r13
movq %rbx, 0x18(%rax)
movq %rax, 0x20(%rbx)
jmp 0x41a3
leaq 0x716e(%rip), %r14      # 0xb1c0
cmpq $0x0, (%r14)
jne 0x4077
movl $0x28, %edi
callq 0x21f0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x20(%rax)
movq %rax, (%r14)
movq (%r14), %rax
incl 0xc(%rax)
jmp 0x4179
movq 0x10(%r12), %rdx
leaq 0x8(%r12), %r13
movq %r13, %rcx
testq %rdx, %rdx
je 0x40af
movq %r13, %rcx
xorl %edi, %edi
cmpq %rax, 0x20(%rdx)
setb %dil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x4097
cmpq %r13, %rcx
je 0x40bc
cmpq 0x20(%rcx), %rax
cmovaeq %rcx, %r13
leaq 0x28(%r13), %rdi
movl 0x10(%rsi), %eax
subl %eax, 0x40(%r13)
callq 0x3206
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x40da
callq 0x21c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x32c8
cmpl $0x0, 0x40(%r13)
jne 0x40f7
movq %r12, %rdi
movq %r13, %rsi
callq 0x5584
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %rsi
movups %xmm0, 0x10(%rsi)
movq 0x8(%rbx), %rax
movq %rax, (%rsi)
leaq 0x6c47(%rip), %rax      # 0xad58
movq %rax, 0x8(%rsi)
movl $0x0, 0x20(%rsi)
movq %r12, %rdi
callq 0x5b96
movl 0x10(%rbx), %ecx
addl %ecx, 0x40(%rax)
movq 0x30(%rax), %rcx
testq %rcx, %rcx
je 0x418e
addq $0x30, %rax
movq %rbx, 0x18(%rcx)
movq %rcx, 0x20(%rbx)
jmp 0x4196
movq %r13, %r8
testq %rcx, %rcx
je 0x4165
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 0x414c
cmpq %r13, %r8
je 0x4172
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, 0x30(%rax)
addq $0x38, %rax
movq %rbx, (%rax)
jmp 0x41a7
movq %rbx, 0x30(%r13)
addq $0x38, %r13
movq %rbx, (%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5d04
movq %rbx, (%rax)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop