// File: Karunika[P]Taxi_Agency_OODB/./src/TaxiAgency.cpp
// Function: TaxiAgency::book_taxi(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void TaxiAgency::book_taxi(string customer_uuid, string car_id){
    IndexInstance<Taxi> taxi;
    try{
        taxi = this->retrieve_taxi_by_id(car_id);
        if(taxi.data->available_number == 0)
            throw booking_unsuccessful("Taxi demanded Unavailable");
    }catch(invalid_argument e){
        throw booking_unsuccessful("Invalid Taxi id");
    };
    
    IndexInstance<Customer> customer = search_customer_by_uuid(customer_uuid);
    if(customer.data->getStatus() == ONSHIFT)
        throw booking_unsuccessful("Can't Book a Taxi while already ONSHIFT");

    if(customer.data->getBalance() < 12*taxi.data->fare_amount + 12*WaitingCharges)
        throw booking_unsuccessful("Not enough balance to book a Taxi");


    string driver_uuid;
    for(int i = 0; i < driver_db.size(); i++){
        if(driver_db[i].getStatus() == IDLE){
            taxi.data->available_number--;
            customer.data->toggle_customer_status();
            driver_uuid = driver_db[i].getUUID();
            driver_db[i].toggle_driver_status();
            Shift shift(customer_uuid, driver_uuid, car_id, taxi.data->fare_amount, WaitingCharges);
            shift.extend_tenure(12, 12);
            current_shifts.push_back(shift);
            return;
        }
    }
    throw booking_unsuccessful("Running out of drivers.");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq %rdx, -0x210(%rbp)
movq %rsi, %rax
movq -0x210(%rbp), %rsi
movq %rax, -0x208(%rbp)
movq %rsi, -0x200(%rbp)
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4170
jmp 0x27fcc
movq -0x1f8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x23860
movq %rdx, -0x220(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x27feb
movq -0x220(%rbp), %rax
movl -0x214(%rbp), %ecx
movl %ecx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x41f0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jne 0x28123
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x228(%rbp)
leaq 0x9e8b(%rip), %rsi      # 0x31ecf
callq 0x2ab30
jmp 0x2804b
movq -0x228(%rbp), %rdi
leaq 0x1db8f(%rip), %rsi     # 0x45be8
leaq -0x9f30(%rip), %rdx     # 0x1e130
callq 0x44b0
jmp 0x285bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x280a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x41f0
jmp 0x280a7
movq -0x228(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4240
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x285ac
movq -0x60(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x4370
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x1d840
movq -0x238(%rbp), %rdi
callq 0x4150
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x230(%rbp)
leaq 0x9dec(%rip), %rsi      # 0x31ee9
callq 0x2ab30
jmp 0x28104
movq -0x230(%rbp), %rdi
leaq 0x1dad6(%rip), %rsi     # 0x45be8
leaq -0x9fe9(%rip), %rdx     # 0x1e130
callq 0x44b0
jmp 0x285bd
jmp 0x28160
movq -0x230(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4240
jmp 0x2814b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4570
callq 0x4480
jmp 0x2815b
jmp 0x285ac
movq -0x208(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x4170
movq -0x1f8(%rbp), %rdi
movq -0x250(%rbp), %rsi
callq 0x24a20
movq %rdx, -0x248(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x2819c
movq -0x248(%rbp), %rax
movl -0x23c(%rbp), %ecx
movl %ecx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x41f0
movq -0x80(%rbp), %rdi
callq 0x1f0b0
cmpl $0x0, %eax
jne 0x28246
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x258(%rbp)
leaq 0x9d0e(%rip), %rsi      # 0x31ef9
callq 0x2ab30
jmp 0x281f2
movq -0x258(%rbp), %rdi
leaq 0x1d9e8(%rip), %rsi     # 0x45be8
leaq -0xa0d7(%rip), %rdx     # 0x1e130
callq 0x44b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x41f0
jmp 0x285ac
movq -0x258(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4240
jmp 0x285ac
movq -0x80(%rbp), %rdi
callq 0x1f0d0
movq -0x1f8(%rbp), %rdx
movq -0x20(%rbp), %rcx
imull $0xc, 0x48(%rcx), %ecx
imull $0xc, 0x88(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x282c7
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x260(%rbp)
leaq 0x9c98(%rip), %rsi      # 0x31f21
callq 0x2ab30
jmp 0x28290
movq -0x260(%rbp), %rdi
leaq 0x1d94a(%rip), %rsi     # 0x45be8
leaq -0xa175(%rip), %rdx     # 0x1e130
callq 0x44b0
movq -0x260(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4240
jmp 0x285ac
leaq -0xc8(%rbp), %rdi
callq 0x43e0
movl $0x0, -0xcc(%rbp)
movq -0x1f8(%rbp), %rdi
movslq -0xcc(%rbp), %rax
movq %rax, -0x268(%rbp)
addq $0x18, %rdi
callq 0x29570
movq %rax, %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
jae 0x28547
movq -0x1f8(%rbp), %rdi
addq $0x18, %rdi
movslq -0xcc(%rbp), %rsi
callq 0x2a380
movq %rax, %rdi
callq 0x1edc0
movl %eax, -0x26c(%rbp)
jmp 0x28335
movl -0x26c(%rbp), %eax
cmpl $0x1, %eax
jne 0x28531
movq -0x20(%rbp), %rax
movl 0x50(%rax), %ecx
decl %ecx
movl %ecx, 0x50(%rax)
movq -0x80(%rbp), %rdi
callq 0x1f070
jmp 0x2835b
movq -0x1f8(%rbp), %rdi
addq $0x18, %rdi
movslq -0xcc(%rbp), %rsi
callq 0x2a380
movq %rax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x2a0e0
jmp 0x28383
leaq -0xc8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
movq %rsi, -0x278(%rbp)
callq 0x4360
movq -0x278(%rbp), %rdi
callq 0x41f0
movq -0x1f8(%rbp), %rdi
addq $0x18, %rdi
movslq -0xcc(%rbp), %rsi
callq 0x2a380
movq %rax, %rdi
callq 0x1ed40
jmp 0x283ca
movq -0x208(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x4170
jmp 0x283df
leaq -0x1d0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x4170
jmp 0x283f4
movq -0x200(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
callq 0x4170
jmp 0x28409
movq -0x1f8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x48(%rcx), %r8d
movl 0x88(%rax), %r9d
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
leaq -0x1f0(%rbp), %rcx
callq 0x1f130
jmp 0x28442
leaq -0x1f0(%rbp), %rdi
callq 0x41f0
leaq -0x1d0(%rbp), %rdi
callq 0x41f0
leaq -0x1b0(%rbp), %rdi
callq 0x41f0
leaq -0x190(%rbp), %rdi
movl $0xc, %edx
movl %edx, %esi
callq 0x20120
jmp 0x2847b
movq -0x1f8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x190(%rbp), %rsi
callq 0x2aa20
jmp 0x28494
leaq -0x190(%rbp), %rdi
callq 0x2a9d0
leaq -0xc8(%rbp), %rdi
callq 0x41f0
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x285a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x28506
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x284fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x41f0
leaq -0x1d0(%rbp), %rdi
callq 0x41f0
leaq -0x1b0(%rbp), %rdi
callq 0x41f0
jmp 0x285a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x2a9d0
jmp 0x285a0
jmp 0x28533
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x282dd
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x280(%rbp)
leaq 0x99de(%rip), %rsi      # 0x31f43
callq 0x2ab30
jmp 0x2856c
movq -0x280(%rbp), %rdi
leaq 0x1d66e(%rip), %rsi     # 0x45be8
leaq -0xa451(%rip), %rdx     # 0x1e130
callq 0x44b0
jmp 0x285bd
movq -0x280(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4240
leaq -0xc8(%rbp), %rdi
callq 0x41f0
movq -0x60(%rbp), %rdi
callq 0x44f0
movq %rax, %rdi
callq 0x1d350
nopl (%rax)