// File: /workspace/github_cpp_makefile_star2_O1/XuhuiSun95[P]Ticket-Booking-Service/client/UserInterface.cpp
// Function: UserInterface::BuyTickets()
void UserInterface::BuyTickets() {

    std::cout << "Processing..." << std::endl;

    ClientSocket *client = new ClientSocket();

    //  Randomly connect to one server from the list
    std::random_device rd;
    std::mt19937 mt(rd());
    std::uniform_int_distribution<int> dist(0, mServers-1);
    int server = dist(mt);

    client->Init(mServerList[server].first, mServerList[server].second);

    if(client->Valid()) {

        std::string request;
        std::size_t ws;

        std::cout << "Please enter the request in the follow form:" << std::endl;
        std::cout << "<movies, n> or <plays, n>" << std::endl;

        while(true) {

            std::getline(std::cin >> std::ws, request);
            ws = request.find(" ");

            if((request.find("movies")!=std::string::npos
               || request.find("plays")!=std::string::npos)
               && ws!=std::string::npos
               && std::all_of(request.begin()+ws+1, request.end(), ::isdigit)) {
                break;
            } else {
                std::cout << "Invalid input! Please enter the request again." << std::endl;
                request.clear();
            }
        }

        client->RequestTicket(request);
    }
    else {

        std::cout << "Socket Init Error! Please check your environment." << std::endl;
        std::cout << std::endl;

        mServers = -1;
        mServerList.clear();
    }

    delete client;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2748, %rsp           # imm = 0x2748
movq %rdi, %rbx
movq 0x31cc(%rip), %r14      # 0x5fd0
leaq 0x1392(%rip), %rsi      # 0x419d
movl $0xd, %edx
movq %r14, %rdi
callq 0x21b0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl $0x41c, %edi            # imm = 0x41C
callq 0x21a0
movq %rax, -0x30(%rbp)
movq %rax, %rdi
callq 0x243c
leaq -0x2768(%rbp), %r14
movq %r14, %rdi
callq 0x32d8
movq %r14, %rdi
callq 0x21d0
movl %eax, %eax
movq %rax, -0x13e0(%rbp)
movl $0x1, %ecx
movq %rax, %rdx
shrq $0x1e, %rdx
xorl %eax, %edx
imull $0x6c078965, %edx, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, -0x13e0(%rbp,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0x2e7a
leaq -0x13e0(%rbp), %rsi
movq $0x270, 0x1380(%rsi) # imm = 0x270
movl 0x4(%rbx), %eax
decl %eax
leaq -0x58(%rbp), %rdi
movl $0x0, (%rdi)
movl %eax, 0x4(%rdi)
movq %rdi, %rdx
callq 0x3784
cltq
movq 0x8(%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rsi
leaq (%rcx,%rax,8), %rdx
addq $0x20, %rdx
movq -0x30(%rbp), %rdi
callq 0x2476
movq -0x30(%rbp), %rdi
callq 0x256c
testb %al, %al
je 0x3166
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x30bb(%rip), %rbx      # 0x5fd0
leaq 0x128f(%rip), %rsi      # 0x41ab
movl $0x2c, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x3089(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq 0x3075(%rip), %rbx      # 0x5fd0
leaq 0x1276(%rip), %rsi      # 0x41d8
movl $0x19, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x3043(%rip), %r14      # 0x5fd0
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq -0x50(%rbp), %r12
leaq 0x124a(%rip), %rbx      # 0x41f2
leaq 0x1250(%rip), %r15      # 0x41ff
movq 0x302a(%rip), %rdi      # 0x5fe0
callq 0x2150
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x2260
movl $0x1, %ecx
movq %r12, %rdi
leaq 0x1170(%rip), %rsi      # 0x415f
xorl %edx, %edx
callq 0x2230
movq %rax, %r13
movl $0x6, %ecx
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2230
cmpq $-0x1, %rax
je 0x301c
cmpq $-0x1, %r13
jne 0x3046
jmp 0x311b
movl $0x5, %ecx
movq %r12, %rdi
leaq 0x11ce(%rip), %rsi      # 0x41f9
xorl %edx, %edx
callq 0x2230
cmpq $-0x1, %r13
je 0x311b
cmpq $-0x1, %rax
je 0x311b
movq -0x50(%rbp), %rcx
leaq (%rcx,%r13), %rdx
incq %rdx
movq -0x48(%rbp), %rax
addq %rcx, %rax
movq %rax, %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
testq %rsi, %rsi
jle 0x30bb
incq %rsi
addq %r13, %rcx
addq $0x2, %rcx
movsbl -0x1(%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
jb 0x3104
movsbl (%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
jb 0x3112
movsbl 0x1(%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
jb 0x3109
movsbl 0x2(%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
jb 0x310e
decq %rsi
addq $0x4, %rcx
cmpq $0x1, %rsi
jg 0x3071
decq %rcx
movq %rcx, %rdx
movq %rax, %rsi
subq %rdx, %rsi
cmpq $0x1, %rsi
je 0x30f2
cmpq $0x2, %rsi
je 0x30e4
movq %rax, %rcx
cmpq $0x3, %rsi
jne 0x3112
movsbl (%rdx), %ecx
addl $-0x3a, %ecx
cmpl $-0xa, %ecx
jb 0x30ff
incq %rdx
movsbl (%rdx), %ecx
addl $-0x3a, %ecx
cmpl $-0xa, %ecx
jb 0x30ff
incq %rdx
movsbl (%rdx), %ecx
addl $-0x3a, %ecx
cmpl $-0xa, %ecx
cmovaeq %rax, %rdx
movq %rdx, %rcx
jmp 0x3112
decq %rcx
jmp 0x3112
incq %rcx
jmp 0x3112
addq $0x2, %rcx
cmpq %rax, %rcx
je 0x31ef
movl $0x2e, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x21b0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq $0x0, -0x48(%rbp)
movq -0x50(%rbp), %rax
movb $0x0, (%rax)
jmp 0x2faf
movq 0x2e63(%rip), %r14      # 0x5fd0
leaq 0x10ba(%rip), %rsi      # 0x422e
movl $0x31, %edx
movq %r14, %rdi
callq 0x21b0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x2e31(%rip), %r14      # 0x5fd0
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x2e03(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x3348
jmp 0x320e
leaq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x2574
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x320e
callq 0x2180
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x2460
movq %rbx, %rdi
callq 0x2180
leaq -0x2768(%rbp), %rdi
callq 0x2170
addq $0x2748, %rsp           # imm = 0x2748
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3282
jmp 0x3254
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0x2180
jmp 0x327a
jmp 0x3259
movq %rax, %rbx
jmp 0x326e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x326e
callq 0x2180
leaq -0x2768(%rbp), %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x266f