// File: /workspace/github_cpp_makefile_star2_O1/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 0x58(%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 0x5041(%rip), %r15      # 0x9fe0
leaq 0x48(%rsp), %rbx
leaq 0xb8(%rsp), %r13
leaq 0x68(%rsp), %rbp
leaq 0x20(%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 0x52b1
movq %r12, 0xb8(%rsp)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x55de
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4a44
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps (%rsp), %xmm0
movq 0x10(%rsp), %rax
movups 0x68(%rsp), %xmm1
movaps %xmm1, (%rsp)
movq 0x78(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movaps 0x20(%rsp), %xmm1
movaps %xmm0, 0x20(%rsp)
movq %rax, 0x30(%rsp)
movups %xmm1, 0x68(%rsp)
movq $0x0, 0x78(%rsp)
movq %r14, %rdi
callq 0x5582
movq %rbp, %rdi
callq 0x5582
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x5080
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
je 0x4fb6
movq %rsp, %rdi
callq 0x4ba6
testb %al, %al
je 0x528b
movq (%rsp), %rax
movq (%rax), %rbx
callq 0x3050
movq %rax, %r14
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x20(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3340
cmpq %rbx, (%r13)
je 0x5411
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x541d
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x541d
testl %ecx, %ecx
jne 0x50f4
movl %ebp, (%r14)
movq 0x90(%rsp), %rcx
movl %eax, (%rcx)
leaq 0xa8(%rsp), %r14
leaq 0x48(%rsp), %r12
leaq 0x98(%rsp), %r13
leaq 0x68(%rsp), %rbp
leaq 0x20(%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 0x52b1
movq %r14, 0x98(%rsp)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x55de
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4a44
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps (%rsp), %xmm0
movq 0x10(%rsp), %rax
movups 0x68(%rsp), %xmm1
movaps %xmm1, (%rsp)
movq 0x78(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movaps 0x20(%rsp), %xmm1
movaps %xmm0, 0x20(%rsp)
movq %rax, 0x30(%rsp)
movups %xmm1, 0x68(%rsp)
movq $0x0, 0x78(%rsp)
movq %rbx, %rdi
callq 0x5582
movq %rbp, %rdi
callq 0x5582
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x51e7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3280
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
je 0x511d
cmpq $0x1, %rax
jne 0x5299
leaq 0x48(%rsp), %rdi
callq 0x3130
leaq 0x1f12(%rip), %rsi      # 0x712a
leaq 0x48(%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 0x52eb
movq 0x4d86(%rip), %rbx      # 0x9fd0
leaq 0x1edb(%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 0x4d54(%rip), %rdi      # 0x9fd0
callq 0x3040
movq %rax, %rdi
callq 0x3170
jmp 0x52b1
movl $0x1a, %edx
leaq 0x1e5b(%rip), %rsi      # 0x70f2
jmp 0x52a5
movl $0x1c, %edx
leaq 0x1e68(%rip), %rsi      # 0x710d
movq 0x4d24(%rip), %rdi      # 0x9fd0
callq 0x32b0
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x5582
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x52d7
movq 0x58(%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 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rsi
xorl %edx, %edx
callq 0x3290
leaq 0x20(%rsp), %r14
movq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x32f0
movq (%r14), %rdi
leaq 0x30(%rsp), %r14
cmpq %r14, %rdi
movq 0x88(%rsp), %r12
je 0x533a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3280
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbx
sarq $0x20, %rbx
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0x3290
leaq 0x20(%rsp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x32f0
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x5389
movq 0x30(%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 0x55de
leaq 0x1cf8(%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 0x53e7
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3280
cmpq $-0x1, %rbx
je 0x540a
movq 0x4bdc(%rip), %rdi      # 0x9fd0
leaq 0x1d45(%rip), %rsi      # 0x7140
movl $0x15, %edx
callq 0x32b0
jmp 0x52b1
movb $0x1, %bl
jmp 0x52b3
leaq 0x1d43(%rip), %rdi      # 0x715b
callq 0x3150
leaq 0x1d37(%rip), %rdi      # 0x715b
callq 0x3350
jmp 0x5481
jmp 0x5481
jmp 0x5481
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x5484
movl %ebp, (%r14)
jmp 0x5484
jmp 0x5481
jmp 0x5481
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x5484
movq 0xa8(%rsp), %rsi
jmp 0x5475
jmp 0x5481
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x5484
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x5484
jmp 0x5481
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5582
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x54a8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3460