// File: /workspace/github_cpp_makefile_star2_O1/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 0x61ea(%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 0x324b
movq %rdi, %rbx
imulq $0x38, %rsi, %rdx
movl (%rcx,%rdx), %eax
movsd 0x28(%rcx,%rdx), %xmm1
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rsp)
xorl %ecx, %ecx
movl %ecx, 0x18(%rsp)
movl %ecx, 0x70(%rdi)
leaq 0x616b(%rip), %rcx      # 0x91c8
movq (%rcx), %rdx
movq 0x8(%rcx), %rcx
subq %rdx, %rcx
je 0x3260
movq (%rdx), %rcx
movq 0x8(%rdx), %rsi
movq %rsi, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rsi
je 0x3286
movslq %eax, %r14
cmpq %r14, %rdx
jbe 0x3254
leaq 0x60fe(%rip), %r13      # 0x9198
movq (%r13), %rdx
movq 0x8(%r13), %rax
subq %rdx, %rax
je 0x3274
movq 0x8(%rdx), %rax
cmpq (%rdx), %rax
je 0x3291
movsd %xmm1, 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 0x329e
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 0x18(%rsp), %r12
movsd %xmm0, 0x8(%r12)
leaq 0x6183(%rip), %rax      # 0x92a0
addsd (%rax), %xmm0
movsd %xmm0, 0x10(%r12)
addq $-0x18, %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x35ea
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movupd %xmm0, 0x8(%rdx)
movl %ebp, (%rdx)
movsd 0x10(%rsp), %xmm0
addsd 0x10(%r12), %xmm0
movsd %xmm0, 0x8(%rdx)
leaq 0x6000(%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 0x35ea
movslq 0x70(%rbx), %rsi
movq (%r13), %rax
movq 0x8(%r13), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x324b
leaq (%rsi,%rsi,2), %rdx
movq (%rax,%rdx,8), %rcx
movq 0x8(%rax,%rdx,8), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x3254
movsd (%rcx,%r14,8), %xmm0
addsd 0x30(%rbx), %xmm0
movsd %xmm0, 0x30(%rbx)
movsd 0x38(%rsp), %xmm1
movsd 0x8(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm1, %xmm2
leaq 0x60b9(%rip), %rax      # 0x92a8
cvtsi2sdl (%rax), %xmm3
mulsd %xmm2, %xmm3
cmpltsd %xmm4, %xmm1
andpd %xmm3, %xmm1
leaq 0x60b1(%rip), %rax      # 0x92b8
addsd (%rax), %xmm1
addsd 0x38(%rbx), %xmm1
movsd %xmm1, 0x38(%rbx)
cmpl $0x1, (%rbx)
jne 0x3223
leaq 0x6037(%rip), %rax      # 0x9258
jmp 0x322a
leaq 0x6036(%rip), %rax      # 0x9260
addsd %xmm1, %xmm0
addsd 0x28(%rbx), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2dda(%rip), %rdi      # 0x602c
jmp 0x32a8
leaq 0x2dd1(%rip), %rdi      # 0x602c
movq %r14, %rsi
jmp 0x32a8
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
jmp 0x3286
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
leaq 0x2d9f(%rip), %rdi      # 0x602c
xorl %esi, %esi
jmp 0x32a8
leaq 0x2d94(%rip), %rdi      # 0x602c
xorl %esi, %esi
xorl %edx, %edx
jmp 0x32a8
leaq 0x2d87(%rip), %rdi      # 0x602c
movq %rax, %rsi
xorl %eax, %eax
callq 0x21e0
nop