// File: /workspace/github_cpp_makefile_star2_O3/ChristalC[P]Online-Outlier-Detection/p2_helper.cpp
// Function: readInput(int&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool readInput(int& window_size, string& host, string& port) {
  string holder;
  vector<string> read_input;

  // Neglect all comment lines
  do {
    if (getline(cin, holder)) {
      read_input = splitString(holder);
    }
    else {
      return false;
    }
  } while (read_input.size() == 0);

  // Read the first line as window_size. 
  // If a number is read, update the window_size
  // If it is not a number, return false
  if (isWindowSize(read_input)) {
    window_size = stoi(read_input[0], NULL, 10);
  }
  else {
    cout << "Window size is incorrect!\n";
    return false;
  }

  // Neglect comment lines
  do {
    if (getline(cin, holder)) {
      read_input = splitString(holder);
    }
    else {
      return false;
    }
  } while (read_input.size() == 0);

  // Read the second line as host and port, marked by a ':' in between
  // If correctly read, update host and port
  // If not, return false
  if (read_input.size() != 1) {
    cout << "Input host:port is invalid!\n";
    return false;
  }
  holder = read_input[0];
  int pos_colon = holder.find_first_of(":");
  if (pos_colon == string::npos) {
    cout << "Port not specified!" << endl;
    return false;
  }
  host = holder.substr(0, pos_colon);
  port = holder.substr(pos_colon + 1);

  // Check if port is a number, if not, return false
  if (!isNum(port)) {
    cout << "Invalid port entered\n";
    return false;
  }
  
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdi, 0x90(%rsp)
leaq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0xc8(%rsp), %r12
movq 0x5089(%rip), %r15      # 0x9fe0
leaq 0x20(%rsp), %rbx
leaq 0xb8(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0x40(%rsp), %r14
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x34a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5255
movq %r12, 0xb8(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5584
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4a0c
movq 0x10(%rsp), %rax
movaps 0x60(%rsp), %xmm0
movq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movaps (%rsp), %xmm1
movaps %xmm0, (%rsp)
movaps %xmm1, 0x40(%rsp)
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq %r14, %rdi
callq 0x5526
movq %rbp, %rdi
callq 0x5526
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x502e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
je 0x4f6e
movq %rsp, %rdi
callq 0x4b6e
testb %al, %al
je 0x522f
movq (%rsp), %rax
movq (%rax), %rbx
callq 0x3050
movq %rax, %r14
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x40(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3340
cmpq %rbx, (%r13)
je 0x53b5
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x53c1
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x53c1
testl %ecx, %ecx
jne 0x50a2
movl %ebp, (%r14)
movq 0x90(%rsp), %rcx
movl %eax, (%rcx)
leaq 0xa8(%rsp), %r14
leaq 0x20(%rsp), %r12
leaq 0x98(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0x40(%rsp), %rbx
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x34a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5255
movq %r14, 0x98(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5584
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4a0c
movq 0x10(%rsp), %rax
movaps 0x60(%rsp), %xmm0
movq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movaps (%rsp), %xmm1
movaps %xmm0, (%rsp)
movaps %xmm1, 0x40(%rsp)
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq %rbx, %rdi
callq 0x5526
movq %rbp, %rdi
callq 0x5526
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x518b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3280
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
je 0x50cb
cmpq $0x1, %rax
jne 0x523d
leaq 0x20(%rsp), %rdi
callq 0x3130
leaq 0x1f6e(%rip), %rsi      # 0x712a
leaq 0x20(%rsp), %rdi
movl $0x1, %ecx
xorl %edx, %edx
callq 0x3390
movq %rax, %rbx
shlq $0x20, %rbx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
cmpq %rax, %rbx
jne 0x528f
movq 0x4de2(%rip), %rbx      # 0x9fd0
leaq 0x1f37(%rip), %rsi      # 0x712c
movl $0x13, %edx
movq %rbx, %rdi
callq 0x32b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq 0x4db0(%rip), %rdi      # 0x9fd0
callq 0x3040
movq %rax, %rdi
callq 0x3170
jmp 0x5255
movl $0x1a, %edx
leaq 0x1eb7(%rip), %rsi      # 0x70f2
jmp 0x5249
movl $0x1c, %edx
leaq 0x1ec4(%rip), %rsi      # 0x710d
movq 0x4d80(%rip), %rdi      # 0x9fd0
callq 0x32b0
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x5526
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x527b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3280
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rcx
sarq $0x20, %rcx
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x3290
leaq 0x40(%rsp), %r14
movq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x32f0
movq (%r14), %rdi
leaq 0x50(%rsp), %r14
cmpq %r14, %rdi
movq 0x88(%rsp), %r12
je 0x52de
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3280
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbx
sarq $0x20, %rbx
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0x3290
leaq 0x40(%rsp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x32f0
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x532d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x5584
leaq 0x1d54(%rip), %rsi      # 0x70ad
leaq 0xd8(%rsp), %r14
movl $0xb, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x3430
movq %rax, %rbx
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x538b
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3280
cmpq $-0x1, %rbx
je 0x53ae
movq 0x4c38(%rip), %rdi      # 0x9fd0
leaq 0x1da1(%rip), %rsi      # 0x7140
movl $0x15, %edx
callq 0x32b0
jmp 0x5255
movb $0x1, %bl
jmp 0x5257
leaq 0x1d9f(%rip), %rdi      # 0x715b
callq 0x3150
leaq 0x1d93(%rip), %rdi      # 0x715b
callq 0x3350
jmp 0x5425
jmp 0x5425
jmp 0x5425
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x5428
movl %ebp, (%r14)
jmp 0x5428
jmp 0x5425
jmp 0x5425
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x5428
movq 0xa8(%rsp), %rsi
jmp 0x5419
jmp 0x5425
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x5428
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x5428
jmp 0x5425
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5526
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x544c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3460