// File: /workspace/github_cpp_makefile_star2_O3/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 0xf492
leaq -0xe0(%rbp), %rsi
movq %rbx, %rdi
callq 0x12776
movq %rdx, -0x30(%rbp)
movq -0xe0(%rbp), %rdi
cmpq %r15, %rdi
je 0x167c8
callq 0x4280
movq -0x30(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x16ab8
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 0xf492
movq %rbx, %rdi
movq %r14, %rsi
callq 0x137ac
movq %rdx, %r13
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0x1681d
callq 0x4280
movq %r13, %rdi
callq 0x10422
testl %eax, %eax
je 0x16af2
movq %r12, -0x38(%rbp)
movq %r13, %rdi
callq 0x1042c
movl 0x88(%rbx), %ecx
movq -0x30(%rbp), %rdx
addl 0x48(%rdx), %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,2), %ecx
cmpl %ecx, %eax
jl 0x16b0f
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x18(%rbx), %rdi
cmpq %rdi, 0x20(%rbx)
je 0x168b0
xorl %r14d, %r14d
movabsq $-0xf0f0f0f0f0f0f0f, %r15 # imm = 0xF0F0F0F0F0F0F0F1
xorl %r12d, %r12d
addq %r14, %rdi
callq 0x10134
cmpl $0x1, %eax
je 0x168ea
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 0x16881
movl $0x10, %edi
callq 0x4170
leaq 0xc34f(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x52cf(%rip), %rcx      # 0x1bb9a
movq %rcx, 0x8(%rax)
leaq 0xc312(%rip), %rsi      # 0x22be8
movq 0xc6eb(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
jmp 0x16c3c
movq -0x30(%rbp), %rax
decl 0x50(%rax)
movq %r13, %rdi
callq 0x10404
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 0xf492
leaq -0x60(%rbp), %rdi
leaq -0x1a0(%rbp), %r13
movq %r13, %rsi
callq 0x4340
movq (%r13), %rdi
cmpq %r15, %rdi
je 0x16942
callq 0x4280
addq 0x18(%rbx), %r14
movq %r14, %rdi
callq 0x100e2
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 0xf492
leaq -0x90(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0xf492
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 0xf492
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 0x1044c
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x169f0
callq 0x4280
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x16a01
callq 0x4280
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x16a12
callq 0x4280
leaq -0x1a0(%rbp), %rdi
movl $0xc, %esi
movl $0xc, %edx
callq 0x10f50
leaq 0x48(%rbx), %r14
leaq -0x1a0(%rbp), %rsi
movq %r14, %rdi
callq 0x19176
movq %rax, %rdi
movq %r14, %rsi
callq 0x4070
incq 0x58(%rbx)
leaq -0x138(%rbp), %rbx
movq %rbx, %rdi
callq 0x10f92
movq -0x28(%rbx), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x16a6e
callq 0x4280
leaq -0x170(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16a83
callq 0x4280
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
je 0x16a94
callq 0x4280
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x16aa6
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 0xc147(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x5053(%rip), %rcx      # 0x1bb26
movq %rcx, 0x8(%rax)
leaq 0xc10a(%rip), %rsi      # 0x22be8
movq 0xc4e3(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
jmp 0x16c3c
movl $0x10, %edi
callq 0x4170
leaq 0xc10d(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x5043(%rip), %rcx      # 0x1bb50
jmp 0x16b2a
movl $0x10, %edi
callq 0x4170
leaq 0xc0f0(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x504e(%rip), %rcx      # 0x1bb78
movq %rcx, 0x8(%rax)
leaq 0xc0b3(%rip), %rsi      # 0x22be8
movq 0xc48c(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x16b5a
callq 0x4280
jmp 0x16b5a
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x16b70
callq 0x4280
jmp 0x16b70
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x16c72
callq 0x4280
jmp 0x16c72
jmp 0x16c6f
jmp 0x16c6f
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
jne 0x16c7f
jmp 0x16c84
jmp 0x16bc7
movq %rdx, %r14
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r15, %rdi
je 0x16bcd
callq 0x4280
jmp 0x16bcd
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x16c84
movq %rbx, %rdi
callq 0x4350
leaq -0x1a0(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x4420
movq 0xc368(%rip), %rax      # 0x22f60
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x4150
movl $0x10, %edi
callq 0x4170
leaq 0xbff8(%rip), %rcx      # 0x22c10
movq %rcx, (%rax)
leaq 0x4f1e(%rip), %rcx      # 0x1bb40
movq %rcx, 0x8(%rax)
leaq 0xbfbb(%rip), %rsi      # 0x22be8
movq 0xc394(%rip), %rdx      # 0x22fc8
movq %rax, %rdi
callq 0x4440
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x44f0
callq 0x4410
jmp 0x16c84
movq %rax, %rdi
callq 0xf2ea
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x17b96
jmp 0x16c72
jmp 0x16c6f
jmp 0x16c6f
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x16c84
callq 0x4280
movq %rbx, %rdi
callq 0x4490