// File: /workspace/github_c_makefile_star2_O3/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, 0x76bc(%rip)     # 0x13720
cmpl $0x2, %edi
jl 0xc218
movq %rsi, %r14
movl %edi, %ebp
xorl %r12d, %r12d
movl $0x1, %r15d
movl 0x750f(%rip), %ebx      # 0x13590
leaq 0x1ce8(%rip), %rdi      # 0xdd70
movl $0x1, %r13d
movslq %r13d, %rax
movq (%r14,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0xc1f8
movzbl 0x1(%rcx), %edx
leal -0x68(%rdx), %esi
cmpl $0x12, %esi
ja 0xc0d7
movslq (%rdi,%rsi,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
incl %r13d
movq 0x8(%r14,%rax,8), %rsi
leaq 0x758e(%rip), %rdi      # 0x13650
callq 0x2160
leaq 0x1ca2(%rip), %rdi      # 0xdd70
orl $0x1, %r12d
jmp 0xc1f8
cmpl $0x64, %edx
jne 0xc1f8
movzbl 0x2(%rcx), %eax
cmpl $0x72, %eax
je 0xc206
cmpl $0x74, %eax
jne 0xc20f
movb $0x1, 0x754c(%rip)      # 0x13649
jmp 0xc1f8
movq 0x8(%r14,%rax,8), %rax
movsbl (%rax), %ebx
addl $-0x30, %ebx
movl %ebx, 0x747d(%rip)      # 0x13590
cmpb $0x0, 0x1(%rax)
je 0xc141
addq $0x2, %rax
addl %ebx, %ebx
leal (%rbx,%rbx,4), %ecx
movl %ecx, 0x7468(%rip)      # 0x13590
movsbl -0x1(%rax), %edx
leal (%rdx,%rcx), %ebx
addl $-0x30, %ebx
movl %ebx, 0x7458(%rip)      # 0x13590
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0xc11d
incl %r13d
orl $0x2, %r12d
jmp 0xc1f8
cmpb $0x73, 0x2(%rcx)
jne 0xc1f8
movb $0x1, 0x74ee(%rip)      # 0x1364c
jmp 0xc1f8
leal 0x1(%r13), %eax
testl %ebx, %ebx
jle 0xc1c4
movq %r12, 0x10(%rsp)
movl %r15d, 0xc(%rsp)
cltq
movl %ebx, %r12d
shlq $0x3, %r12
leaq (%r14,%rax,8), %r15
leal (%rbx,%r13), %eax
incl %eax
movl %eax, 0x8(%rsp)
xorl %r13d, %r13d
movq (%r15,%r13), %rdi
callq 0x2210
leaq 0x7401(%rip), %rax      # 0x135a0
movq %xmm0, (%r13,%rax)
addq $0x8, %r13
cmpq %r13, %r12
jne 0xc18f
movl 0xc(%rsp), %r15d
movq 0x10(%rsp), %r12
leaq 0x1bb0(%rip), %rdi      # 0xdd70
movl 0x8(%rsp), %eax
movb $0x1, 0x7480(%rip)      # 0x1364b
movl %eax, %r13d
jmp 0xc1f8
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
jmp 0xc1f8
incl %r13d
movq 0x8(%r14,%rax,8), %rsi
leaq 0x7534(%rip), %rdi      # 0x13720
callq 0x2160
leaq 0x1b78(%rip), %rdi      # 0xdd70
incl %r13d
cmpl %ebp, %r13d
jl 0xc08e
jmp 0xc221
movb $0x1, 0x743d(%rip)      # 0x1364a
jmp 0xc1f8
movb $0x1, 0x7432(%rip)      # 0x13648
jmp 0xc1f8
xorl %r12d, %r12d
movl $0x1, %r15d
xorl %ebx, %ebx
cmpb $0x1, 0x7422(%rip)      # 0x1364c
jne 0xc243
movl $0x80, %edi
callq 0x2190
movq %rax, %r14
movq %rax, %rdi
callq 0x4e80
jmp 0xc258
movl $0x58, %edi
callq 0x2190
movq %rax, %r14
movq %rax, %rdi
callq 0x693c
movq %r14, 0x7329(%rip)      # 0x13588
testb %bl, %bl
je 0xc382
leaq 0x1b74(%rip), %rdi      # 0xdde2
xorl %eax, %eax
callq 0x2050
leaq 0x1b77(%rip), %rdi      # 0xddf3
leaq 0x3(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21c0
movb (%rbx), %al
andb $-0x21, %al
cmpb $0x4e, %al
jne 0xc29a
movb $0x0, 0x73ae(%rip)      # 0x13648
leaq 0x1b56(%rip), %rdi      # 0xddf7
xorl %eax, %eax
callq 0x2050
leaq 0xea6(%rip), %rbx       # 0xd155
leaq 0x4(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
leaq 0x1b44(%rip), %rdi      # 0xde0c
xorl %eax, %eax
callq 0x2050
leaq 0x1b4f(%rip), %r14      # 0xde25
leaq 0x7373(%rip), %r12      # 0x13650
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x21c0
movq 0x7297(%rip), %rdi      # 0x13588
movzbl 0x7350(%rip), %edx      # 0x13648
movl (%r15), %r8d
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x7334
movq 0x727c(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x726f(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x80(%rax)
leaq 0x1b00(%rip), %rdi      # 0xde29
xorl %eax, %eax
callq 0x2050
leaq 0x7259(%rip), %rsi      # 0x13590
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21c0
leaq 0x1b0c(%rip), %rdi      # 0xde54
xorl %eax, %eax
callq 0x2050
leaq 0x73ca(%rip), %rsi      # 0x13720
movq %r14, %rdi
xorl %eax, %eax
callq 0x21c0
cmpb $0x30, 0x73b9(%rip)     # 0x13720
jne 0xc3ed
cmpb $0x0, 0x73ad(%rip)      # 0x13721
jne 0xc3ed
movq 0x6c3b(%rip), %rax      # 0x12fb8
movq (%rax), %rax
jmp 0xc400
cmpl $0x3, %r12d
jne 0xc4c6
movzbl 0x72b5(%rip), %edx      # 0x13648
leaq 0x72b6(%rip), %rsi      # 0x13650
movq %r14, %rdi
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x7334
movq 0x71da(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x71cd(%rip), %rdi      # 0x13588
movq (%rdi), %rax
callq *0x80(%rax)
cmpb $0x30, 0x7355(%rip)     # 0x13720
jne 0xc4fb
cmpb $0x0, 0x7349(%rip)      # 0x13721
jne 0xc4fb
movq 0x6bd3(%rip), %rax      # 0x12fb8
movq (%rax), %rax
jmp 0xc50e
leaq 0x732c(%rip), %rdi      # 0x13720
leaq 0x19e5(%rip), %rsi      # 0xdde0
callq 0x21d0
movq %rax, 0x73e1(%rip)      # 0x137e8
cmpb $0x0, 0x723d(%rip)      # 0x1364b
jne 0xc515
movslq 0x7175(%rip), %rcx      # 0x13590
testq %rcx, %rcx
jle 0xc515
leal 0x1(%rcx), %eax
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl %eax
shlq $0x4, %rax
movdqa 0xcde(%rip), %xmm1      # 0xd120
xorl %ecx, %ecx
movdqa 0xce4(%rip), %xmm2      # 0xd130
pxor %xmm2, %xmm0
leaq 0x7149(%rip), %rdx      # 0x135a0
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
pcmpeqd %xmm3, %xmm3
movdqa 0xcd3(%rip), %xmm4      # 0xd140
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edi
notl %edi
testb $0x1, %dil
je 0xc4a3
movq %rsi, (%rcx,%rdx)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0xc4b7
movq %rsi, 0x8(%rcx,%rdx)
paddq %xmm4, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0xc46d
jmp 0xc515
movl $0x0, 0x70c0(%rip)      # 0x13590
testl %r12d, %r12d
je 0xc4e1
leaq 0x20c5(%rip), %rdi      # 0xe5a1
callq 0x2270
leaq 0x1ddc(%rip), %rdi      # 0xe2c4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2270
leaq 0x721e(%rip), %rdi      # 0x13720
leaq 0x18d7(%rip), %rsi      # 0xdde0
callq 0x21d0
movq %rax, 0x72d3(%rip)      # 0x137e8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d99(%rip), %rdi      # 0xe2c4
callq 0x2270
movl $0x0, 0x7056(%rip)      # 0x13590
jmp 0xc515
movb $0x1, %bl
jmp 0xc223
movq %rax, %rbx
movl $0x58, %esi
jmp 0xc555
movq %rax, %rbx
movl $0x80, %esi
movq %r14, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x22c0