// File: DivyanshuSaxena[P]green-vrp/Vehicle.cpp
// Function: Vehicle::addCustomer(int)
void Vehicle::addCustomer(int customerId) {
    Customer customer = customers.at(customerId);
    Node node;
    node.id = customer.id;
    time_type timeTaken = travelTimes.at(this->currentNodeId).at(customer.id);
    double travelCost = travelCosts.at(this->currentNodeId).at(customer.id);
    
    node.arrival_time = this->route.at(this->route.size()-2).departure_time + timeTaken;
    node.departure_time = node.arrival_time + serviceTime;
    this->currentNodeId = customer.id;
    auto it = this->route.end();
    this->route.insert(--it, node);
    // Update costs
    double factor = this->type == 1 ? unitTransCost1 : unitTransCost2;
    this->travellingCost += (travelCost * factor);
    double waitCost = (customer.timeWindowStarts > node.arrival_time) ? (customer.timeWindowStarts - node.arrival_time)*waiting_factor : 0; 
    this->waitingCost += waitCost;
    updateTotalCost();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movslq -0xc(%rbp), %rsi
leaq 0xe560(%rip), %rdi      # 0x11248
callq 0x3a20
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
movl $0x38, %edx
callq 0x2150
leaq -0x60(%rbp), %rdi
callq 0x3920
movq -0xa0(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, -0x60(%rbp)
movslq 0x70(%rax), %rsi
leaq 0xe4f9(%rip), %rdi      # 0x11218
callq 0x3ad0
movq %rax, %rdi
movslq -0x48(%rbp), %rsi
callq 0x3b10
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, -0x68(%rbp)
movslq 0x70(%rax), %rsi
leaq 0xe49a(%rip), %rdi      # 0x111e8
callq 0x3ad0
movq %rax, %rdi
movslq -0x48(%rbp), %rsi
callq 0x3b10
movq -0xa0(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0xb0(%rbp)
addq $0x8, %rdi
callq 0x3aa0
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
subq $0x2, %rsi
callq 0x3a60
movq -0xa0(%rbp), %rdi
movsd 0x10(%rax), %xmm0
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
leaq 0xe3f5(%rip), %rax      # 0x111b0
addsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x48(%rbp), %eax
movl %eax, 0x70(%rdi)
addq $0x8, %rdi
callq 0x3b90
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, -0x78(%rbp)
addq $0x8, %rax
movq %rax, -0xa8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3dc0
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x3de0
movq -0xa8(%rbp), %rdi
movq -0x80(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x3bc0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, -0x88(%rbp)
cmpl $0x1, (%rax)
jne 0x2e40
leaq 0xe486(%rip), %rax      # 0x112b8
movsd (%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
jmp 0x2e53
leaq 0xe479(%rip), %rax      # 0x112c0
movsd (%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0xa0(%rbp), %rax
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0x90(%rbp), %xmm2
movsd 0x30(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rax)
movsd -0x20(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x2eb8
movsd -0x20(%rbp), %xmm0
subsd -0x58(%rbp), %xmm0
leaq 0xe452(%rip), %rax      # 0x112f8
cvtsi2sdl (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
jmp 0x2ec5
xorps %xmm0, %xmm0
movsd %xmm0, -0xc0(%rbp)
jmp 0x2ec5
movq -0xa0(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
addsd 0x38(%rdi), %xmm0
movsd %xmm0, 0x38(%rdi)
callq 0x2b20
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)