// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movl $0x1, 0x4(%rsp)
movw $0x30, 0x782c(%rip)     # 0x13720
xorl %r15d, %r15d
cmpl $0x2, %edi
setge %r14b
jl 0xc09d
movq %rsi, %rbx
movl %edi, %ebp
movl $0x1, %r12d
xorl %r15d, %r15d
movl 0x7677(%rip), %r13d     # 0x13590
movl %edi, 0xc(%rsp)
movslq %r12d, %rax
movq (%rbx,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0xc08d
movzbl 0x1(%rcx), %edx
cmpl $0x64, %edx
je 0xbf40
cmpl $0x68, %edx
jne 0xbf6b
jmp 0xc31c
cmpb $0x74, 0x2(%rcx)
leaq 0x76fe(%rip), %rsi      # 0x13649
je 0xbf68
cmpb $0x64, %dl
jne 0xbf6b
cmpb $0x72, 0x2(%rcx)
leaq 0x76eb(%rip), %rsi      # 0x13648
leaq 0x76e6(%rip), %rdx      # 0x1364a
cmoveq %rdx, %rsi
movb $0x1, (%rsi)
cmpb $0x6c, 0x1(%rcx)
jne 0xbf7e
cmpb $0x73, 0x2(%rcx)
jne 0xbf7e
movb $0x1, 0x76ce(%rip)      # 0x1364c
cmpb $0x7a, 0x1(%rcx)
jne 0xbf8c
movl $0x0, 0x4(%rsp)
movzbl 0x1(%rcx), %ecx
addl $-0x69, %ecx
cmpl $0xa, %ecx
ja 0xc08d
leaq 0x1d99(%rip), %rdx      # 0xdd3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
incl %r12d
movq 0x8(%rbx,%rax,8), %rsi
leaq 0x7695(%rip), %rdi      # 0x13650
callq 0x2160
orl $0x1, %r15d
jmp 0xc08d
incl %r12d
movq 0x8(%rbx,%rax,8), %rsi
leaq 0x7748(%rip), %rdi      # 0x13720
callq 0x2160
jmp 0xc08d
movq 0x8(%rbx,%rax,8), %rax
movsbl (%rax), %r13d
addl $-0x30, %r13d
movl %r13d, 0x759a(%rip)     # 0x13590
cmpb $0x0, 0x1(%rax)
je 0xc02a
addq $0x2, %rax
addl %r13d, %r13d
leal (%r13,%r13,4), %ecx
movl %ecx, 0x7582(%rip)      # 0x13590
movsbl -0x1(%rax), %edx
leal (%rdx,%rcx), %r13d
addl $-0x30, %r13d
movl %r13d, 0x756f(%rip)     # 0x13590
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0xc000
incl %r12d
orl $0x2, %r15d
jmp 0xc08d
leal 0x1(%r12), %r14d
testl %r13d, %r13d
jle 0xc083
movq %r15, 0x10(%rsp)
movslq %r14d, %rax
movl %r13d, %r15d
shlq $0x3, %r15
leaq (%rbx,%rax,8), %rbp
leal (%r12,%r13), %r14d
incl %r14d
xorl %r12d, %r12d
movq (%rbp,%r12), %rdi
callq 0x2210
leaq 0x7535(%rip), %rax      # 0x135a0
movsd %xmm0, (%r12,%rax)
addq $0x8, %r12
cmpq %r12, %r15
jne 0xc05a
movq 0x10(%rsp), %r15
movl 0xc(%rsp), %ebp
movb $0x1, 0x75c1(%rip)      # 0x1364b
movl %r14d, %r12d
incl %r12d
cmpl %ebp, %r12d
setl %r14b
jl 0xbf1d
cmpb $0x1, 0x75a8(%rip)      # 0x1364c
jne 0xc0bd
movl $0x80, %edi
callq 0x2190
movq %rax, %rbx
movq %rax, %rdi
callq 0x4e60
jmp 0xc0d2
movl $0x58, %edi
callq 0x2190
movq %rax, %rbx
movq %rax, %rdi
callq 0x6934
movq %rbx, 0x74af(%rip)      # 0x13588
testb $0x1, %r14b
je 0xc201
leaq 0x1cb8(%rip), %rdi      # 0xdda2
xorl %eax, %eax
callq 0x2050
leaq 0x1cbb(%rip), %rdi      # 0xddb3
leaq 0xb(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21c0
movb (%rbx), %al
andb $-0x21, %al
cmpb $0x4e, %al
jne 0xc116
movb $0x0, 0x7532(%rip)      # 0x13648
leaq 0x1c9a(%rip), %rdi      # 0xddb7
xorl %eax, %eax
callq 0x2050
leaq 0xfee(%rip), %rbx       # 0xd119
leaq 0x4(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
leaq 0x1c88(%rip), %rdi      # 0xddcc
xorl %eax, %eax
callq 0x2050
leaq 0x1c93(%rip), %r14      # 0xdde5
leaq 0x74f7(%rip), %r12      # 0x13650
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x21c0
movq 0x741b(%rip), %rdi      # 0x13588
movzbl 0x74d4(%rip), %edx      # 0x13648
movl (%r15), %r8d
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x731c
movq 0x7400(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x73f3(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x80(%rax)
leaq 0x1c44(%rip), %rdi      # 0xdde9
xorl %eax, %eax
callq 0x2050
leaq 0x73dd(%rip), %rsi      # 0x13590
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21c0
leaq 0x1c50(%rip), %rdi      # 0xde14
xorl %eax, %eax
callq 0x2050
leaq 0x754e(%rip), %rsi      # 0x13720
movq %r14, %rdi
xorl %eax, %eax
callq 0x21c0
cmpb $0x30, 0x753d(%rip)     # 0x13720
jne 0xc26e
cmpb $0x0, 0x7531(%rip)      # 0x13721
jne 0xc26e
movq 0x6dbf(%rip), %rax      # 0x12fb8
movq (%rax), %rax
jmp 0xc281
cmpl $0x3, %r15d
jne 0xc2cb
movzbl 0x7436(%rip), %edx      # 0x13648
movl 0x4(%rsp), %r8d
leaq 0x7432(%rip), %rsi      # 0x13650
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x731c
movq 0x7359(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x734c(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x80(%rax)
cmpb $0x30, 0x74d4(%rip)     # 0x13720
jne 0xc300
cmpb $0x0, 0x74c8(%rip)      # 0x13721
jne 0xc300
movq 0x6d52(%rip), %rax      # 0x12fb8
movq (%rax), %rax
jmp 0xc313
leaq 0x74ab(%rip), %rdi      # 0x13720
leaq 0x1b24(%rip), %rsi      # 0xdda0
callq 0x21d0
movq %rax, 0x7560(%rip)      # 0x137e8
cmpb $0x0, 0x73bc(%rip)      # 0x1364b
jne 0xc332
movslq 0x72f4(%rip), %rax      # 0x13590
testq %rax, %rax
jle 0xc332
shlq $0x3, %rax
xorl %ecx, %ecx
leaq 0x72ee(%rip), %rdx      # 0x135a0
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq %rsi, (%rcx,%rdx)
addq $0x8, %rcx
cmpq %rcx, %rax
jne 0xc2bc
jmp 0xc332
movl $0x0, 0x72bb(%rip)      # 0x13590
testl %r15d, %r15d
je 0xc2e6
leaq 0x2280(%rip), %rdi      # 0xe561
callq 0x2270
leaq 0x1f97(%rip), %rdi      # 0xe284
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2270
leaq 0x7419(%rip), %rdi      # 0x13720
leaq 0x1a92(%rip), %rsi      # 0xdda0
callq 0x21d0
movq %rax, 0x74ce(%rip)      # 0x137e8
jmp 0xc332
leaq 0x1f61(%rip), %rdi      # 0xe284
callq 0x2270
movl $0x0, 0x725e(%rip)      # 0x13590
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0x58, %esi
jmp 0xc353
movq %rax, %r14
movl $0x80, %esi
movq %rbx, %rdi
callq 0x21a0
movq %r14, %rdi
callq 0x22c0