// File: /workspace/github_cpp_makefile_star2_O3/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 0x332a
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 0x37de
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 0x31ae
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 0x3163
movl $0x5, %ecx
movq %r12, %rdi
leaq 0x11ce(%rip), %rsi      # 0x41f9
xorl %edx, %edx
callq 0x2230
cmpq $-0x1, %r13
je 0x3163
cmpq $-0x1, %rax
je 0x3163
movq -0x50(%rbp), %rsi
leaq (%rsi,%r13), %rdx
incq %rdx
movq -0x48(%rbp), %rax
addq %rsi, %rax
movq %rax, %rdi
subq %rdx, %rdi
sarq $0x2, %rdi
testq %rdi, %rdi
jle 0x30f5
incq %rdi
leaq 0x1(%rsi), %rdx
leaq 0x4(%rsi), %r8
leaq 0x3(%rsi), %r9
addq $0x2, %rsi
movq %rdx, %rcx
movsbl -0x3(%r8,%r13), %r10d
addl $-0x3a, %r10d
cmpl $-0xa, %r10d
jb 0x313f
movsbl -0x2(%r8,%r13), %r10d
addl $-0x3a, %r10d
cmpl $-0xa, %r10d
jb 0x3144
movsbl -0x1(%r8,%r13), %r10d
addl $-0x3a, %r10d
cmpl $-0xa, %r10d
jb 0x314c
movsbl (%r8,%r13), %r10d
addl $-0x3a, %r10d
cmpl $-0xa, %r10d
jb 0x3154
decq %rdi
addq $0x4, %rcx
addq $0x4, %r8
addq $0x4, %r9
addq $0x4, %rsi
addq $0x4, %rdx
cmpq $0x1, %rdi
jg 0x3081
addq %r13, %rdx
addq %r13, %rcx
jmp 0x30f8
movq %rdx, %rcx
movq %rax, %rsi
subq %rdx, %rsi
cmpq $0x1, %rsi
je 0x3130
cmpq $0x2, %rsi
je 0x3122
cmpq $0x3, %rsi
jne 0x3237
movsbl (%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
jb 0x315a
incq %rcx
movsbl (%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
jb 0x315a
incq %rcx
movsbl (%rcx), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
cmovaeq %rax, %rcx
jmp 0x315a
addq %r13, %rcx
jmp 0x315a
addq %r13, %rsi
movq %rsi, %rcx
jmp 0x315a
addq %r13, %r9
movq %r9, %rcx
jmp 0x315a
addq %r13, %r8
movq %r8, %rcx
cmpq %rax, %rcx
je 0x3237
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 0x2e1b(%rip), %r14      # 0x5fd0
leaq 0x1072(%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 0x2de9(%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 0x2dbb(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x339a
jmp 0x3256
leaq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x2574
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3256
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 0x32ca
jmp 0x329c
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0x2180
jmp 0x32c2
jmp 0x32a1
movq %rax, %rbx
jmp 0x32b6
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x32b6
callq 0x2180
leaq -0x2768(%rbp), %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x266f