// File: /workspace/github_c_makefile_star2_O2/ComplexNetworks-DCC-FCUP[P]fase/FaseMain.cpp
// Function: read(int, char**)
void read(int argc, char **argv)
{
  int E, V, i, check = 0, itera = 0;
  int zeroBased = 1;
  ofilename[0] = '0';
  ofilename[1] = '\0';

  for (i = 1; i < argc; i++)
  {
    if (argv[i][0] != '-')
      continue;
    if (argv[i][1] == 'h')
    {
      displayHelp();
      K = 0;
      return;
    }

    if (argv[i][1] == 'd' && argv[i][2] == 't')
      detailed = true;
    else if (argv[i][1] == 'd' && argv[i][2] == 'r')
      draw = true;
    else if (argv[i][1] == 'd')
      dir = true;

    if (argv[i][1] == 'l' && argv[i][2] == 's')
      largeScale = true;

    if (argv[i][1] == 'z')
      zeroBased = 0;

    if (argv[i][1] == 'i')
    {
      i++;
      strcpy(ifilename, argv[i]);
      check |= (1 << 0);
      continue;
    }

    if (argv[i][1] == 's')
    {
      i++;
      K = argv[i][0] - '0';
      int j = 1;
      while (argv[i][j] != '\0')
      {
	K *= 10;
	K += argv[i][j] - '0';
	j++;
      }
      check |= (1 << 1);
      continue;
    }

    if (argv[i][1] == 'o')
    {
      i++;
      strcpy(ofilename, argv[i]);
      continue;
    }

    if (argv[i][1] == 'p')
    {
      int j;
      for (j = 0, i++; j < K; j++, i++)
        sampProb[j] = atof(argv[i]);
      samp = true;
      continue;
    }

    if (argv[i][1] == 'q')
    {
      itera = 1;
      break;
    }
  }

  if (largeScale)
    G = new DynamicGraph();
  else
    G = new GraphMatrix();

  if (!itera)
  {
    if (check != (1 << 2) - 1)
    {
      K = 0;
      if (check != 0)
	printf("Warning: Incorrect number of necessary arguments provided\n");
      displayHelp();
      return;
    }
    GraphUtils::readFileTxt(G, ifilename, dir, false, zeroBased);
    G->sortNeighbours();
    G->makeArrayNeighbours();
    if (ofilename[0] == '0' && ofilename[1] == '\0')
      outFile = stdout;
    else
      outFile = fopen(ofilename, "w");
    return;
  }

  // Direction
  printf("Directed? (Y/n) ");
  char chdir;
  scanf(" %c", &chdir);
  if (chdir == 'n' || chdir == 'N')
    dir = false;

  // Initial
  printf("Input 0 or 1 based: ");
  scanf("%d", &zeroBased);

  // Input filename
  printf("Insert input file name: ");
  scanf(" %s", ifilename);
  GraphUtils::readFileTxt(G, ifilename, dir, false, zeroBased);
  G->sortNeighbours();
  G->makeArrayNeighbours();

  // Subgraph Size
  printf("Input the value K of the subgraph search: ");
  scanf("%d", &K);

  // Input filename
  printf("Insert output file name or 0 to stdout: ");
  scanf(" %s", ofilename);
  if (ofilename[0] == '0' && ofilename[1] == '\0')
    outFile = stdout;
  else
    outFile = fopen(ofilename, "w");

  // Default Sampling probabilities
  if (!samp)
    for (i = 0; i < K; i++)
      sampProb[i] = 1.0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %ebp
movl $0x1, 0x10(%rsp)
movw $0x30, 0x8597(%rip)     # 0x13740
movl 0x8400(%rip), %r15d     # 0x135b0
leaq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
pushq $0x1
popq %rax
leaq 0x1b67(%rip), %r13      # 0xcd2c
movl %eax, 0xc(%rsp)
movl %eax, %r12d
movl %edi, 0x14(%rsp)
cmpl %ebp, %r12d
jge 0xb33c
movslq %r12d, %rax
movq (%r14,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0xb322
movzbl 0x1(%rcx), %edx
leal -0x68(%rdx), %esi
cmpl $0x12, %esi
ja 0xb21b
movslq (%r13,%rsi,4), %rdx
addq %r13, %rdx
jmpq *%rdx
incl %r12d
movq 0x8(%r14,%rax,8), %rsi
leaq 0x8462(%rip), %rdi      # 0x13670
callq 0x2170
orl $0x1, %ebx
jmp 0xb322
cmpl $0x64, %edx
jne 0xb322
movzbl 0x2(%rcx), %eax
cmpl $0x72, %eax
je 0xb32a
cmpl $0x74, %eax
jne 0xb333
movb $0x1, 0x8428(%rip)      # 0x13669
jmp 0xb322
incl %r12d
movq 0x8(%r14,%rax,8), %rax
movsbl (%rax), %r15d
addl $-0x30, %r15d
movl %r15d, 0x8353(%rip)     # 0x135b0
incq %rax
cmpb $0x0, (%rax)
je 0xb27c
imull $0xa, %r15d, %ecx
movl %ecx, 0x8341(%rip)      # 0x135b0
movsbl (%rax), %edx
leal (%rcx,%rdx), %r15d
addl $-0x30, %r15d
jmp 0xb256
orl $0x2, %ebx
jmp 0xb322
cmpb $0x73, 0x2(%rcx)
jne 0xb322
movb $0x1, 0x83d7(%rip)      # 0x1366c
jmp 0xb322
movq %rbx, 0x20(%rsp)
testl %r15d, %r15d
movl $0x0, %ecx
cmovgl %r15d, %ecx
leaq (,%rcx,8), %rbx
movq 0x18(%rsp), %rdx
leaq (%rdx,%rax,8), %r13
addl %ecx, %r12d
incl %r12d
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0xb2e6
movq (%r13,%rbp), %rdi
callq 0x2220
leaq 0x82e6(%rip), %rax      # 0x135c0
movsd %xmm0, (%rbp,%rax)
addq $0x8, %rbp
jmp 0xb2c4
movb $0x1, 0x837e(%rip)      # 0x1366b
movq 0x20(%rsp), %rbx
movl 0x14(%rsp), %ebp
leaq 0x1a2f(%rip), %r13      # 0xcd2c
jmp 0xb322
andl $0x0, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
jmp 0xb322
incl %r12d
movq 0x8(%r14,%rax,8), %rsi
leaq 0x8423(%rip), %rdi      # 0x13740
callq 0x2170
incl %r12d
jmp 0xb1d0
movb $0x1, 0x8339(%rip)      # 0x1366a
jmp 0xb322
movb $0x1, 0x832e(%rip)      # 0x13668
jmp 0xb322
cmpb $0x1, 0x8329(%rip)      # 0x1366c
jne 0xb35c
movl $0x80, %edi
callq 0x21a0
movq %rax, %r14
movq %rax, %rdi
callq 0x469c
jmp 0xb36f
pushq $0x58
popq %rdi
callq 0x21a0
movq %rax, %r14
movq %rax, %rdi
callq 0x6100
movq %r14, 0x8232(%rip)      # 0x135a8
cmpl %ebp, %r12d
jge 0xb49a
leaq 0x1a2c(%rip), %rdi      # 0xcdb2
xorl %eax, %eax
callq 0x2050
leaq 0x1a2f(%rip), %rdi      # 0xcdc3
leaq 0xb(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21d0
movb (%rbx), %al
andb $-0x21, %al
cmpb $0x4e, %al
jne 0xb3b2
movb $0x0, 0x82b6(%rip)      # 0x13668
leaq 0x1a0e(%rip), %rdi      # 0xcdc7
xorl %eax, %eax
callq 0x2050
leaq 0xd52(%rip), %rbx       # 0xc119
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21d0
leaq 0x19fc(%rip), %rdi      # 0xcddc
xorl %eax, %eax
callq 0x2050
leaq 0x1a07(%rip), %r14      # 0xcdf5
leaq 0x827b(%rip), %r12      # 0x13670
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x21d0
movq 0x819f(%rip), %rdi      # 0x135a8
movzbl 0x8258(%rip), %edx      # 0x13668
movl (%r15), %r8d
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x6910
movq 0x8184(%rip), %rdi      # 0x135a8
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x8177(%rip), %rdi      # 0x135a8
movq (%rdi), %rax
callq *0x80(%rax)
leaq 0x19b8(%rip), %rdi      # 0xcdf9
xorl %eax, %eax
callq 0x2050
leaq 0x8161(%rip), %rsi      # 0x135b0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21d0
leaq 0x19c4(%rip), %rdi      # 0xce24
xorl %eax, %eax
callq 0x2050
leaq 0x82d2(%rip), %rsi      # 0x13740
movq %r14, %rdi
xorl %eax, %eax
callq 0x21d0
cmpb $0x30, 0x82c1(%rip)     # 0x13740
jne 0xb506
cmpb $0x0, 0x82b5(%rip)      # 0x13741
jne 0xb506
movq 0x7b23(%rip), %rax      # 0x12fb8
movq (%rax), %rax
jmp 0xb519
cmpl $0x3, %ebx
jne 0xb55a
movzbl 0x81be(%rip), %edx      # 0x13668
leaq 0x81bf(%rip), %rsi      # 0x13670
movq %r14, %rdi
xorl %ecx, %ecx
movl 0xc(%rsp), %r8d
callq 0x6910
movq 0x80e1(%rip), %rdi      # 0x135a8
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x80d4(%rip), %rdi      # 0x135a8
movq (%rdi), %rax
callq *0x80(%rax)
cmpb $0x30, 0x825c(%rip)     # 0x13740
jne 0xb584
cmpb $0x0, 0x8250(%rip)      # 0x13741
jne 0xb584
movq 0x7aba(%rip), %rax      # 0x12fb8
movq (%rax), %rax
jmp 0xb597
leaq 0x8233(%rip), %rdi      # 0x13740
leaq 0x189c(%rip), %rsi      # 0xcdb0
callq 0x21e0
movq %rax, 0x82e8(%rip)      # 0x13808
cmpb $0x0, 0x8144(%rip)      # 0x1366b
jne 0xb59e
movl 0x8081(%rip), %eax      # 0x135b0
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
shlq $0x3, %rax
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
leaq 0x8075(%rip), %rsi      # 0x135c0
cmpq %rcx, %rax
je 0xb59e
movq %rdx, (%rcx,%rsi)
addq $0x8, %rcx
jmp 0xb54b
andl $0x0, 0x804f(%rip)      # 0x135b0
testl %ebx, %ebx
je 0xb571
leaq 0x2005(%rip), %rdi      # 0xd571
callq 0x22a0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb179
leaq 0x81b5(%rip), %rdi      # 0x13740
leaq 0x181e(%rip), %rsi      # 0xcdb0
callq 0x21e0
movq %rax, 0x826a(%rip)      # 0x13808
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xb179
andl $0x0, 0x7ff7(%rip)      # 0x135b0
jmp 0xb59e
movq %rax, %rbx
pushq $0x58
popq %rsi
jmp 0xb5cb
movq %rax, %rbx
movl $0x80, %esi
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0