// File: /workspace/github_cpp_makefile_star2_O2/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 $0xc8, %rsp
movq %rdx, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdi, %r15
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movq %rsp, %r12
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
movq 0x51ea(%rip), %rbx      # 0x8fe0
leaq 0x18(%rsp), %r13
leaq 0xa8(%rsp), %rbp
leaq 0x48(%rsp), %r14
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2070
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3f70
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2300
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3a58
movq %r12, %rdi
movq %r14, %rsi
callq 0x461e
movq %r14, %rdi
callq 0x4134
movq %rbp, %rdi
callq 0x20f0
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
je 0x3e08
movq %rsp, %rdi
callq 0x3b55
testb %al, %al
je 0x3f54
movq (%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x4190
movl %eax, (%r15)
movq 0x5157(%rip), %r15      # 0x8fe0
leaq 0x18(%rsp), %r12
leaq 0x88(%rsp), %r13
leaq 0x48(%rsp), %rbp
movq %rsp, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2070
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3f70
movq %r13, %rdi
movq %r12, %rsi
callq 0x2300
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3a58
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x461e
movq %rbp, %rdi
callq 0x4134
movq %r13, %rdi
callq 0x20f0
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
je 0x3e9e
cmpq $0x1, %rax
jne 0x3f5d
leaq 0x18(%rsp), %rdi
callq 0x2140
leaq 0x1212(%rip), %rsi      # 0x5127
leaq 0x18(%rsp), %rdi
xorl %edx, %edx
callq 0x2110
movq %rax, %rbx
shlq $0x20, %rbx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
cmpq %rax, %rbx
jne 0x3f98
movq 0x508a(%rip), %rdi      # 0x8fc8
leaq 0x11e4(%rip), %rsi      # 0x5129
callq 0x2230
movq %rax, %rdi
callq 0x2100
jmp 0x3f70
leaq 0x1194(%rip), %rsi      # 0x50ef
jmp 0x3f64
leaq 0x11a6(%rip), %rsi      # 0x510a
movq 0x505d(%rip), %rdi      # 0x8fc8
callq 0x2230
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x4134
leaq 0x18(%rsp), %rdi
callq 0x20f0
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rcx
sarq $0x20, %rcx
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x2260
leaq 0x48(%rsp), %r14
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x22b0
movq %r14, %rdi
callq 0x20f0
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbx
sarq $0x20, %rbx
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
pushq $-0x1
popq %rcx
movq %rbx, %rdx
callq 0x2260
leaq 0x48(%rsp), %rbx
movq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22b0
movq %rbx, %rdi
callq 0x20f0
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x2300
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0x3b99
movl %eax, %ebp
movq %rbx, %rdi
callq 0x20f0
movb $0x1, %bl
testb %bpl, %bpl
jne 0x3f72
movq 0x4f85(%rip), %rdi      # 0x8fc8
leaq 0x10f3(%rip), %rsi      # 0x513d
callq 0x2230
jmp 0x3f70
jmp 0x4081
jmp 0x4081
jmp 0x4081
jmp 0x4081
jmp 0x4081
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x4078
jmp 0x4081
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x20f0
jmp 0x4084
jmp 0x4081
movq %rax, %rbx
movq %rsp, %rdi
callq 0x4134
leaq 0x18(%rsp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x23f0