// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x28, %rsp
movslq %esi, %rsi
leaq 0x6745(%rip), %rcx      # 0x91f8
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x2c81
movq %rdi, %rbx
imulq $0x38, %rsi, %rcx
movl (%rax,%rcx), %r8d
movsd 0x28(%rax,%rcx), %xmm1
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsp)
movl %r8d, 0x10(%rsp)
movslq 0x70(%rdi), %rax
leaq 0x66c7(%rip), %rcx      # 0x91c8
movq (%rcx), %r9
movq 0x8(%rcx), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rax, %rdx
jbe 0x2c8a
movslq %r8d, %rsi
leaq (%rax,%rax,2), %r10
movq (%r9,%r10,8), %rdi
movq 0x8(%r9,%r10,8), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x2c81
leaq 0x664b(%rip), %rdx      # 0x9198
movq (%rdx), %r11
movq 0x8(%rdx), %rdx
subq %r11, %rdx
sarq $0x3, %rdx
imulq %rcx, %rdx
cmpq %rax, %rdx
jbe 0x2c8a
movq (%r11,%r10,8), %r9
movq 0x8(%r11,%r10,8), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x2c81
movsd %xmm1, 0x8(%rsp)
movq 0x8(%rbx), %r10
movq 0x10(%rbx), %rax
movq %rax, %rdx
subq %r10, %rdx
sarq $0x3, %rdx
imulq %rcx, %rdx
leaq -0x2(%rdx), %rcx
cmpq $0x1, %rdx
jbe 0x2c96
movsd (%rdi,%rsi,8), %xmm0
movsd (%r9,%rsi,8), %xmm1
movsd %xmm1, (%rsp)
leaq (%rcx,%rcx,2), %rcx
addsd 0x10(%r10,%rcx,8), %xmm0
leaq 0x10(%rsp), %r14
movsd %xmm0, 0x8(%r14)
leaq 0x6588(%rip), %rcx      # 0x9160
addsd (%rcx), %xmm0
leaq 0x8(%rbx), %rdi
movsd %xmm0, 0x10(%r14)
movl %r8d, 0x70(%rbx)
addq $-0x18, %rax
movq %rax, %rsi
movq %r14, %rdx
callq 0x35ea
cmpl $0x1, (%rbx)
leaq 0x666d(%rip), %rax      # 0x9270
cmoveq 0x63a5(%rip), %rax      # 0x8fb0
movsd (%rsp), %xmm0
mulsd (%rax), %xmm0
addsd 0x30(%rbx), %xmm0
movsd %xmm0, 0x30(%rbx)
movapd %xmm0, %xmm4
movsd 0x8(%r14), %xmm0
movsd 0x8(%rsp), %xmm3
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
leaq 0x666b(%rip), %rax      # 0x92a8
cvtsi2sdl (%rax), %xmm2
mulsd %xmm1, %xmm2
cmpltsd %xmm3, %xmm0
andpd %xmm2, %xmm0
addsd 0x38(%rbx), %xmm0
leaq 0x6606(%rip), %rax      # 0x9260
cmoveq 0x637e(%rip), %rax      # 0x8fe0
movsd %xmm0, 0x38(%rbx)
addsd %xmm4, %xmm0
addsd 0x28(%rbx), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r14
retq
leaq 0x33a4(%rip), %rdi      # 0x602c
jmp 0x2ca0
leaq 0x339b(%rip), %rdi      # 0x602c
movq %rax, %rsi
jmp 0x2ca0
leaq 0x338f(%rip), %rdi      # 0x602c
movq %rcx, %rsi
xorl %eax, %eax
callq 0x21e0
nop