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

  FILE *f = fopen(s, "r");
  if (!f) Error::msg(NULL);

  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);
    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 $0xd0, %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)
movq -0x10(%rbp), %rdi
leaq 0x16003(%rip), %rsi     # 0x20ae0
callq 0x3310
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xaaf8
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0xfb80
leaq -0x50(%rbp), %rdi
callq 0x8670
leaq -0x68(%rbp), %rdi
callq 0x8670
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x16022(%rip), %rsi     # 0x20b45
xorl %eax, %eax
leaq -0x28(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
callq 0x34a0
movl %eax, -0x78(%rbp)
jmp 0xab37
movl -0x78(%rbp), %eax
cmpl $0x2, %eax
jne 0xabd7
testb $0x1, -0x12(%rbp)
je 0xab8f
movq -0x20(%rbp), %rdi
leaq 0x15ff4(%rip), %rsi     # 0x20b48
xorl %eax, %eax
leaq -0x30(%rbp), %rdx
callq 0x34a0
movl %eax, -0x7c(%rbp)
jmp 0xab64
movl -0x7c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xab8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x85f0
leaq -0x50(%rbp), %rdi
callq 0x85f0
jmp 0xae19
leaq -0x50(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x8690
jmp 0xab9e
leaq -0x68(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x8690
jmp 0xabad
movl -0x28(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0xabbb
movl -0x28(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0xabc9
movl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xab18
movq -0x20(%rbp), %rdi
callq 0x3260
jmp 0xabe2
testb $0x1, -0x11(%rbp)
je 0xabfe
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %edx, %edx
callq *%rax
jmp 0xabfc
jmp 0xac17
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movl $0x1, %edx
callq *%rax
jmp 0xac15
jmp 0xac17
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xadec
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8720
movl (%rax), %eax
movl %eax, -0x80(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x8720
movq %rax, %rcx
movl -0x80(%rbp), %eax
cmpl (%rcx), %eax
jne 0xac8d
movq 0x2037e(%rip), %rax     # 0x2afd8
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8720
movq -0x88(%rbp), %rdi
movl (%rax), %edx
leaq 0x15eca(%rip), %rsi     # 0x20b4b
movb $0x0, %al
callq 0x33a0
jmp 0xadde
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8720
movl (%rax), %eax
decl %eax
movl %eax, -0x90(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x8720
movq -0x98(%rbp), %rdi
movl -0x90(%rbp), %esi
movl (%rax), %edx
decl %edx
movq (%rdi), %rax
movq 0x50(%rax), %rax
callq *%rax
movb %al, -0x89(%rbp)
jmp 0xacde
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0xacea
jmp 0xad3c
movq 0x202e7(%rip), %rax     # 0x2afd8
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8720
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x8720
movq -0xa8(%rbp), %rdi
movl -0x9c(%rbp), %edx
movl (%rax), %ecx
leaq 0x15e31(%rip), %rsi     # 0x20b64
movb $0x0, %al
callq 0x33a0
jmp 0xad89
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8720
movl (%rax), %eax
decl %eax
movl %eax, -0xac(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x8720
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %esi
movl (%rax), %edx
decl %edx
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
jmp 0xad87
jmp 0xad89
testb $0x1, -0x11(%rbp)
jne 0xaddc
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x8720
movl (%rax), %eax
decl %eax
movl %eax, -0xbc(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x8720
movq -0xc8(%rbp), %rdi
movl -0xbc(%rbp), %esi
movl (%rax), %edx
decl %edx
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
jmp 0xadda
jmp 0xaddc
jmp 0xadde
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xac1e
leaq -0x50(%rbp), %rdi
callq 0x8650
leaq -0x68(%rbp), %rdi
callq 0x8650
leaq -0x68(%rbp), %rdi
callq 0x85f0
leaq -0x50(%rbp), %rdi
callq 0x85f0
addq $0xd0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)