// File: /workspace/github_cpp_makefile_star2_O3/DivyanshuSaxena[P]green-vrp/Vehicle.cpp
// Function: Vehicle::addCustomerDepot(int)
void Vehicle::addCustomerDepot(int customerId) {
    Customer customer = customers.at(customerId);
    Node depot;
    depot.id = 0;
    this->currentNodeId = 0;
    time_type timeToDepot = travelTimes.at(this->currentNodeId).at(0);
    time_type timeDepotToCustomer = travelTimes.at(0).at(customer.id);
    double travelCostDepot = travelCosts.at(this->currentNodeId).at(0);
    depot.arrival_time = this->route.at(this->route.size()-2).departure_time + timeToDepot;
    depot.departure_time = depot.arrival_time + chargingTimeDepot;
    auto it = this->route.end();
    this->route.insert(--it, depot);

    Node node;
    node.id = customerId;
    node.arrival_time = depot.departure_time + timeDepotToCustomer;
    node.departure_time = node.arrival_time + serviceTime;
    this->currentNodeId = customer.id;
    it = this->route.end();
    this->route.insert(--it, node);

    // Update costs
    double travelCost = travelCosts.at(this->currentNodeId).at(customer.id);
    this->travellingCost += travelCost;
    double waitCost = (customer.timeWindowStarts > node.arrival_time) ? (customer.timeWindowStarts - node.arrival_time)*waiting_factor : 0; 
    this->waitingCost += (waitCost + waitingCostDepot);
    updateTotalCost();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movslq %esi, %rsi
leaq 0x6238(%rip), %rax      # 0x91f8
movq (%rax), %rcx
movq 0x8(%rax), %rax
subq %rcx, %rax
sarq $0x3, %rax
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rdx
cmpq %rsi, %rdx
jbe 0x31f7
movq %rdi, %rbx
imulq $0x38, %rsi, %rdx
movl (%rcx,%rdx), %eax
movsd 0x28(%rcx,%rdx), %xmm0
xorl %ecx, %ecx
movl %ecx, 0x30(%rsp)
movl %ecx, 0x70(%rdi)
leaq 0x61c3(%rip), %rcx      # 0x91c8
movq (%rcx), %rdx
cmpq %rdx, 0x8(%rcx)
je 0x31ea
movq (%rdx), %rcx
movq 0x8(%rdx), %rsi
movq %rsi, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rsi
je 0x320c
movslq %eax, %r14
cmpq %r14, %rdx
jbe 0x3200
leaq 0x6159(%rip), %r13      # 0x9198
movq (%r13), %rax
cmpq %rax, 0x8(%r13)
je 0x31ea
movq 0x8(%rax), %rdx
cmpq (%rax), %rdx
je 0x31ea
movsd %xmm0, 0x8(%rsp)
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq %rsi, %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
leaq -0x2(%rdx), %rax
cmpq $0x1, %rdx
jbe 0x3217
movsd (%rcx), %xmm0
movsd (%rcx,%r14,8), %xmm1
movsd %xmm1, 0x10(%rsp)
leaq (%rax,%rax,2), %rax
addsd 0x10(%rdi,%rax,8), %xmm0
leaq 0x8(%rbx), %r15
leaq 0x30(%rsp), %r12
movsd %xmm0, 0x8(%r12)
leaq 0x61e1(%rip), %rax      # 0x92a0
addsd (%rax), %xmm0
movsd %xmm0, 0x10(%r12)
addq $-0x18, %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x3556
leaq 0x18(%rsp), %rdx
movl %ebp, (%rdx)
movsd 0x10(%rsp), %xmm0
addsd 0x10(%r12), %xmm0
movsd %xmm0, 0x8(%rdx)
leaq 0x6067(%rip), %rax      # 0x9160
addsd (%rax), %xmm0
movsd %xmm0, 0x10(%rdx)
movl %r14d, 0x70(%rbx)
movq 0x10(%rbx), %rsi
addq $-0x18, %rsi
movq %r15, %rdi
callq 0x3556
movslq 0x70(%rbx), %rsi
movq (%r13), %rcx
movq 0x8(%r13), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %rsi, %rdx
jbe 0x31f7
leaq (%rsi,%rsi,2), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x3200
movsd 0x20(%rsp), %xmm1
movsd 0x8(%rsp), %xmm3
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
leaq 0x6130(%rip), %rcx      # 0x92a8
cvtsi2sdl (%rcx), %xmm2
mulsd %xmm0, %xmm2
cmpltsd %xmm3, %xmm1
andpd %xmm2, %xmm1
leaq 0x6128(%rip), %rcx      # 0x92b8
addsd (%rcx), %xmm1
movupd 0x30(%rbx), %xmm2
movsd (%rax,%r14,8), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
addpd %xmm2, %xmm0
movupd %xmm0, 0x30(%rbx)
cmpl $0x1, (%rbx)
jne 0x31ba
leaq 0x60a0(%rip), %rax      # 0x9258
jmp 0x31c1
leaq 0x609f(%rip), %rax      # 0x9260
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x28(%rbx), %xmm1
addsd (%rax), %xmm1
movsd %xmm1, 0x20(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e53(%rip), %rdi      # 0x6044
xorl %esi, %esi
xorl %edx, %edx
jmp 0x3221
leaq 0x2e46(%rip), %rdi      # 0x6044
jmp 0x3221
leaq 0x2e3d(%rip), %rdi      # 0x6044
movq %r14, %rsi
jmp 0x3221
leaq 0x2e31(%rip), %rdi      # 0x6044
xorl %esi, %esi
jmp 0x3221
leaq 0x2e26(%rip), %rdi      # 0x6044
movq %rax, %rsi
xorl %eax, %eax
callq 0x21e0