// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
leaq -0xd0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0xf530
leaq -0xe0(%rbp), %rsi
movq %rbx, %rdi
callq 0x12838
movq %rdx, -0x30(%rbp)
movq -0xe0(%rbp), %rdi
cmpq %r15, %rdi
je 0x1695a
callq 0x4280
movq -0x30(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x16c4a
leaq -0xf0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq %r14, -0x40(%rbp)
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %r14
movq %r14, %rdi
callq 0xf530
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1389e
movq %rdx, %r13
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0x169af
callq 0x4280
movq %r13, %rdi
callq 0x1049a
testl %eax, %eax
je 0x16c84
movq %r12, -0x38(%rbp)
movq %r13, %rdi
callq 0x104a4
movl 0x88(%rbx), %ecx
movq -0x30(%rbp), %rdx
addl 0x48(%rdx), %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,2), %ecx
cmpl %ecx, %eax
jl 0x16ca1
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x18(%rbx), %rdi
cmpq %rdi, 0x20(%rbx)
je 0x16a42
xorl %r14d, %r14d
movabsq $-0xf0f0f0f0f0f0f0f, %r15 # imm = 0xF0F0F0F0F0F0F0F1
xorl %r12d, %r12d
addq %r14, %rdi
callq 0x101ac
cmpl $0x1, %eax
je 0x16a7c
incq %r12
movq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r15, %rax
addq $0x88, %r14
cmpq %r12, %rax
ja 0x16a13
movl $0x10, %edi
callq 0x4170
leaq 0xc1bd(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x513d(%rip), %rcx      # 0x1bb9a
movq %rcx, 0x8(%rax)
leaq 0xc180(%rip), %rsi      # 0x22be8
movq 0xc559(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
jmp 0x16dce
movq -0x30(%rbp), %rax
decl 0x50(%rax)
movq %r13, %rdi
callq 0x1047c
movq 0x18(%rbx), %rax
leaq -0x190(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%rax,%r14), %rsi
movq 0x48(%rax,%r14), %rdx
addq %rsi, %rdx
leaq -0x1a0(%rbp), %rdi
callq 0xf530
leaq -0x60(%rbp), %rdi
leaq -0x1a0(%rbp), %r13
movq %r13, %rsi
callq 0x4340
movq (%r13), %rdi
cmpq %r15, %rdi
je 0x16ad4
callq 0x4280
addq 0x18(%rbx), %r14
movq %r14, %rdi
callq 0x1015a
leaq -0xb0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0xf530
leaq -0x90(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0xf530
leaq -0x70(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0xf530
movq -0x30(%rbp), %rax
movl 0x48(%rax), %r8d
movl 0x88(%rbx), %r9d
leaq -0x1a0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0x104c4
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x16b82
callq 0x4280
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x16b93
callq 0x4280
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x16ba4
callq 0x4280
leaq -0x1a0(%rbp), %rdi
movl $0xc, %esi
movl $0xc, %edx
callq 0x10ffa
leaq 0x48(%rbx), %r14
leaq -0x1a0(%rbp), %rsi
movq %r14, %rdi
callq 0x1936a
movq %rax, %rdi
movq %r14, %rsi
callq 0x4070
incq 0x58(%rbx)
leaq -0x138(%rbp), %rbx
movq %rbx, %rdi
callq 0x1103c
movq -0x28(%rbx), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x16c00
callq 0x4280
leaq -0x170(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16c15
callq 0x4280
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
je 0x16c26
callq 0x4280
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x16c38
callq 0x4280
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4170
leaq 0xbfb5(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x4ec1(%rip), %rcx      # 0x1bb26
movq %rcx, 0x8(%rax)
leaq 0xbf78(%rip), %rsi      # 0x22be8
movq 0xc351(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
jmp 0x16dce
movl $0x10, %edi
callq 0x4170
leaq 0xbf7b(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x4eb1(%rip), %rcx      # 0x1bb50
jmp 0x16cbc
movl $0x10, %edi
callq 0x4170
leaq 0xbf5e(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x4ebc(%rip), %rcx      # 0x1bb78
movq %rcx, 0x8(%rax)
leaq 0xbf21(%rip), %rsi      # 0x22be8
movq 0xc2fa(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x16cec
callq 0x4280
jmp 0x16cec
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x16d02
callq 0x4280
jmp 0x16d02
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x16e04
callq 0x4280
jmp 0x16e04
jmp 0x16e01
jmp 0x16e01
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
jne 0x16e11
jmp 0x16e16
jmp 0x16d59
movq %rdx, %r14
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r15, %rdi
je 0x16d5f
callq 0x4280
jmp 0x16d5f
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x16e16
movq %rbx, %rdi
callq 0x4350
leaq -0x1a0(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x4420
movq 0xc1d6(%rip), %rax      # 0x22f60
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x4150
movl $0x10, %edi
callq 0x4170
leaq 0xbe66(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x4d8c(%rip), %rcx      # 0x1bb40
movq %rcx, 0x8(%rax)
leaq 0xbe29(%rip), %rsi      # 0x22be8
movq 0xc202(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x44f0
callq 0x4410
jmp 0x16e16
movq %rax, %rdi
callq 0xf38c
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x17d84
jmp 0x16e04
jmp 0x16e01
jmp 0x16e01
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x16e16
callq 0x4280
movq %rbx, %rdi
callq 0x4490