// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rdi, %rbx
movslq %esi, %r15
leaq 0x6581(%rip), %rdi      # 0x91e0
movq %r15, %rsi
callq 0x30bc
movslq (%rax), %r14
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x30(%rsp), %r12
andl $0x0, (%r12)
andl $0x0, 0x70(%rbx)
leaq 0x6526(%rip), %r13      # 0x91b0
movq %r13, %rdi
xorl %esi, %esi
callq 0x30f8
movq %rax, %rdi
xorl %esi, %esi
callq 0x3116
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x30f8
movq %rax, %rdi
movq %r14, %rsi
callq 0x3116
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movslq 0x70(%rbx), %rsi
leaq 0x64af(%rip), %rdi      # 0x9180
callq 0x30f8
movq %rax, %rdi
xorl %esi, %esi
callq 0x3116
leaq 0x8(%rbx), %rbp
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
leaq -0x2(%rax), %rsi
movq %rbp, %rdi
callq 0x30da
movsd (%rsp), %xmm0
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x8(%r12)
leaq 0x6570(%rip), %rax      # 0x9288
addsd (%rax), %xmm0
movsd %xmm0, 0x10(%r12)
movq 0x10(%rbx), %rsi
addq $-0x18, %rsi
movq %rbp, %rdi
movq %r12, %rdx
callq 0x3138
leaq 0x18(%rsp), %r13
movl %r15d, (%r13)
movsd 0x8(%rsp), %xmm0
addsd 0x10(%r12), %xmm0
movsd %xmm0, 0x8(%r13)
leaq 0x63ef(%rip), %rax      # 0x9148
addsd (%rax), %xmm0
movsd %xmm0, 0x10(%r13)
movl %r14d, 0x70(%rbx)
movq 0x10(%rbx), %rsi
addq $-0x18, %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x3138
movslq 0x70(%rbx), %rsi
leaq 0x63fb(%rip), %rdi      # 0x9180
callq 0x30f8
movq %rax, %rdi
movq %r14, %rsi
callq 0x3116
movsd 0x8(%r13), %xmm0
movsd 0x10(%rsp), %xmm3
movapd %xmm3, %xmm1
leaq 0x64e4(%rip), %rcx      # 0x9290
cvtsi2sdl (%rcx), %xmm2
subsd %xmm0, %xmm1
mulsd %xmm1, %xmm2
cmpltsd %xmm3, %xmm0
andpd %xmm2, %xmm0
leaq 0x64d8(%rip), %rcx      # 0x92a0
addsd (%rcx), %xmm0
movupd 0x30(%rbx), %xmm1
movsd (%rax), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
addpd %xmm1, %xmm2
movupd %xmm2, 0x30(%rbx)
movq %rbx, %rdi
callq 0x27ec
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop