// File: /workspace/github_c_makefile_star2_O0/ComplexNetworks-DCC-FCUP[P]fase/GraphUtils.cpp
// Function: GraphUtils::readFileTxt(Graph*, char const*, bool, bool, int)
void GraphUtils::readFileTxt(Graph *g, const char *s, bool dir, bool weight, int base) {

  FILE *f = fopen(s, "r");
  if (!f)
    exit(EXIT_FAILURE);

  int i, a, b, c, size, max;
  vector<int> va, vb;

  size = max = 0;
  while (fscanf(f,"%d %d", &a, &b)==2) {
    if (weight) i=fscanf(f,"%d", &c);
    a += 1 - base; b += 1 - base;
    va.push_back(a);
    vb.push_back(b);
    if (a>max) max=a;
    if (b>max) max=b;
    size++;
  }
    
  fclose(f);

  if (dir) g->createGraph(max, DIRECTED);
  else     g->createGraph(max, UNDIRECTED);

  for (i=0; i<size; i++) {
    if (va[i]==vb[i]) {
//      fprintf(stderr, "Self-Loop on %d ignored\n", va[i]);
      continue; // discard self loops!
    }
    if (g->hasEdge(va[i]-1, vb[i]-1));
//      fprintf(stderr,"Repeated connection! %d %d\n", va[i], vb[i]);
    else 
      g->addEdge(va[i]-1, vb[i]-1);
    if (!dir) g->addEdge(vb[i]-1, va[i]-1);
  } 
  va.clear();
  vb.clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %cl
movb %cl, -0x11(%rbp)
andb $0x1, %al
movb %al, -0x12(%rbp)
movl %r8d, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7cdb(%rip), %rsi      # 0x1907c
callq 0x3290
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x113bb
movl $0x1, %edi
callq 0x32b0
leaq -0x50(%rbp), %rdi
callq 0xbeb0
leaq -0x68(%rbp), %rdi
callq 0xbeb0
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x7c98(%rip), %rsi      # 0x1907e
xorl %eax, %eax
leaq -0x28(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
callq 0x33c0
movl %eax, -0x78(%rbp)
jmp 0x113fa
movl -0x78(%rbp), %eax
cmpl $0x2, %eax
jne 0x114b4
testb $0x1, -0x12(%rbp)
je 0x11452
movq -0x20(%rbp), %rdi
leaq 0x7c6a(%rip), %rsi      # 0x19081
xorl %eax, %eax
leaq -0x30(%rbp), %rdx
callq 0x33c0
movl %eax, -0x7c(%rbp)
jmp 0x11427
movl -0x7c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x11452
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xbe30
leaq -0x50(%rbp), %rdi
callq 0xbe30
jmp 0x11671
movl -0x18(%rbp), %ecx
movl -0x28(%rbp), %eax
subl %ecx, %eax
incl %eax
movl %eax, -0x28(%rbp)
movl -0x18(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
incl %eax
movl %eax, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xc1b0
jmp 0x1147b
leaq -0x68(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0xc1b0
jmp 0x1148a
movl -0x28(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x11498
movl -0x28(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x114a6
movl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x113db
movq -0x20(%rbp), %rdi
callq 0x3200
jmp 0x114bf
testb $0x1, -0x11(%rbp)
je 0x114db
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movq (%rdi), %rax
movq 0x10(%rax), %rax
xorl %edx, %edx
callq *%rax
jmp 0x114d9
jmp 0x114f4
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movq (%rdi), %rax
movq 0x10(%rax), %rax
movl $0x1, %edx
callq *%rax
jmp 0x114f2
jmp 0x114f4
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x11644
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xc130
movl (%rax), %eax
movl %eax, -0x80(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xc130
movq %rax, %rcx
movl -0x80(%rbp), %eax
cmpl (%rcx), %eax
jne 0x11535
jmp 0x11636
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xc130
movl (%rax), %eax
decl %eax
movl %eax, -0x88(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xc130
movq -0x90(%rbp), %rdi
movl -0x88(%rbp), %esi
movl (%rax), %edx
decl %edx
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
movb %al, -0x81(%rbp)
jmp 0x11586
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x11592
jmp 0x11594
jmp 0x115e1
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xc130
movl (%rax), %eax
decl %eax
movl %eax, -0x94(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xc130
movq -0xa0(%rbp), %rdi
movl -0x94(%rbp), %esi
movl (%rax), %edx
decl %edx
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
jmp 0x115df
jmp 0x115e1
testb $0x1, -0x11(%rbp)
jne 0x11634
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xc130
movl (%rax), %eax
decl %eax
movl %eax, -0xa4(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xc130
movq -0xb0(%rbp), %rdi
movl -0xa4(%rbp), %esi
movl (%rax), %edx
decl %edx
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
jmp 0x11632
jmp 0x11634
jmp 0x11636
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x114fb
leaq -0x50(%rbp), %rdi
callq 0xbe90
leaq -0x68(%rbp), %rdi
callq 0xbe90
leaq -0x68(%rbp), %rdi
callq 0xbe30
leaq -0x50(%rbp), %rdi
callq 0xbe30
addq $0xb0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x3380
nopw (%rax,%rax)