// File: Kingsford-Group[P]ghost2/src/writeAlternateDistances.hpp
// Function: writeAlternateDistances(Graph*, Graph*)
void writeAlternateDistances(Graph *G, Graph *H)
{
  ofstream fout((*G).getName()+"_vs_"+(*H).getName()+".df");
  AdjGraph s,t;
  s.init(G);
  t.init(H);
  MatrixXd *A = s.matrix(),
           *B = t.matrix(),
           S(*t.size(), *s.size()),
           P(*t.size(), *s.size());
  S.fill(1); P.fill(1);
  bool flag=false;
  for(int i=0;i<100;i++)
  {
      MatrixXd temp = (*B)*S*(*A);
      double tot=0, diff=0;
      for(int r=0;r<S.rows();r++)
        for(int c=0;c<S.cols();c++)
          tot+=temp(r,c)*S(r,c);
      tot = sqrt(tot);
      for(int r=0;r<S.rows();r++)
        for(int c=0;c<S.cols();c++)
          temp(r,c)/=tot;
      S=temp;
      if(i%2==0) 
      {
        for(int r=0;r<S.rows();r++)
          for(int c=0;c<S.cols();c++)
            diff+=fabs(temp(r,c)-P(r,c));
        P=S;
        if(diff<0.1)
          {cout << i << " iterations\n";flag=true; break;}
      }
      cout << "iter: " << i << "\n";
  }
  for(int r=0;r<S.rows();r++)
    for(int c=0;c<S.cols();c++)
    {
      fout << s.stringOf(c) << "\t" << t.stringOf(r) << 
             "\t" << 1.0-S(r,c) << "\n";
    }
  fout.close();
  if(!flag) cout << "didn't converge :(\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x610, %rsp            # imm = 0x610
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x290(%rbp), %rdi
movq %rdi, -0x4d0(%rbp)
callq 0x23c90
movq -0x4d0(%rbp), %rsi
leaq 0xa2560(%rip), %rdx     # 0xbc948
leaq -0x270(%rbp), %rdi
callq 0x23850
jmp 0x1a3f6
movq -0x10(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0x23c90
jmp 0x1a408
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
leaq -0x2c0(%rbp), %rdx
callq 0x28320
jmp 0x1a424
leaq 0xa2522(%rip), %rdx     # 0xbc94d
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x23850
jmp 0x1a440
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
movl $0x10, %edx
callq 0x10e00
jmp 0x1a45a
leaq -0x230(%rbp), %rdi
callq 0x10460
leaq -0x250(%rbp), %rdi
callq 0x10460
leaq -0x2c0(%rbp), %rdi
callq 0x10460
leaq -0x270(%rbp), %rdi
callq 0x10460
leaq -0x290(%rbp), %rdi
callq 0x10460
leaq -0x328(%rbp), %rdi
callq 0x283f0
jmp 0x1a4a4
leaq -0x390(%rbp), %rdi
callq 0x283f0
jmp 0x1a4b2
movq -0x8(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x1a070
jmp 0x1a4c4
movq -0x10(%rbp), %rsi
leaq -0x390(%rbp), %rdi
callq 0x1a070
jmp 0x1a4d6
leaq -0x328(%rbp), %rdi
callq 0x28430
movq %rax, -0x4d8(%rbp)
jmp 0x1a4eb
movq -0x4d8(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x28430
movq %rax, -0x4e0(%rbp)
jmp 0x1a50e
movq -0x4e0(%rbp), %rax
movq %rax, -0x3a0(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x28450
movq %rax, -0x4e8(%rbp)
jmp 0x1a531
leaq -0x328(%rbp), %rdi
callq 0x28450
movq %rax, -0x4f0(%rbp)
jmp 0x1a546
movq -0x4f0(%rbp), %rdx
movq -0x4e8(%rbp), %rsi
leaq -0x3b8(%rbp), %rdi
callq 0x28460
jmp 0x1a562
leaq -0x390(%rbp), %rdi
callq 0x28450
movq %rax, -0x4f8(%rbp)
jmp 0x1a577
leaq -0x328(%rbp), %rdi
callq 0x28450
movq %rax, -0x500(%rbp)
jmp 0x1a58c
movq -0x500(%rbp), %rdx
movq -0x4f8(%rbp), %rsi
leaq -0x3d0(%rbp), %rdi
callq 0x28460
jmp 0x1a5a8
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x3d8(%rbp)
leaq -0x3b8(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x28170
jmp 0x1a5ce
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x3e0(%rbp)
leaq -0x3d0(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
callq 0x28170
jmp 0x1a5f4
movb $0x0, -0x3e1(%rbp)
movl $0x0, -0x3e8(%rbp)
cmpl $0x64, -0x3e8(%rbp)
jge 0x1acbc
movq -0x3a0(%rbp), %rsi
leaq -0x450(%rbp), %rdi
leaq -0x3b8(%rbp), %rdx
callq 0x284d0
jmp 0x1a62e
movq -0x398(%rbp), %rdx
leaq -0x428(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x28520
jmp 0x1a64a
leaq -0x428(%rbp), %rdi
callq 0x28570
movq %rax, -0x508(%rbp)
jmp 0x1a65f
movq -0x508(%rbp), %rsi
leaq -0x400(%rbp), %rdi
callq 0x285f0
jmp 0x1a674
leaq -0x428(%rbp), %rdi
callq 0x28690
leaq -0x450(%rbp), %rdi
callq 0x286b0
xorps %xmm0, %xmm0
movsd %xmm0, -0x458(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x460(%rbp)
movl $0x0, -0x464(%rbp)
movslq -0x464(%rbp), %rax
movq %rax, -0x518(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x24690
movq %rax, -0x510(%rbp)
jmp 0x1a6cf
movq -0x518(%rbp), %rax
movq -0x510(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1a954
movl $0x0, -0x468(%rbp)
movslq -0x468(%rbp), %rax
movq %rax, -0x528(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x286d0
movq %rax, -0x520(%rbp)
jmp 0x1a713
movq -0x528(%rbp), %rax
movq -0x520(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1a93e
movslq -0x464(%rbp), %rsi
movslq -0x468(%rbp), %rdx
leaq -0x400(%rbp), %rdi
callq 0x246b0
movq %rax, -0x530(%rbp)
jmp 0x1a74d
movq -0x530(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x540(%rbp)
movslq -0x464(%rbp), %rsi
movslq -0x468(%rbp), %rdx
leaq -0x3b8(%rbp), %rdi
callq 0x246b0
movq %rax, -0x538(%rbp)
jmp 0x1a783
movsd -0x540(%rbp), %xmm0
movq -0x538(%rbp), %rax
movsd (%rax), %xmm2
movsd -0x458(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x458(%rbp)
movl -0x468(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x468(%rbp)
jmp 0x1a6f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1a854
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1a848
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1a83c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1a830
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x10460
leaq -0x250(%rbp), %rdi
callq 0x10460
leaq -0x2c0(%rbp), %rdi
callq 0x10460
leaq -0x270(%rbp), %rdi
callq 0x10460
leaq -0x290(%rbp), %rdi
callq 0x10460
jmp 0x1af82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1af76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1af6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1af5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1af52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1af46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1a90a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x28690
leaq -0x450(%rbp), %rdi
callq 0x286b0
jmp 0x1af46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x28720
jmp 0x1af46
jmp 0x1a940
movl -0x464(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x464(%rbp)
jmp 0x1a6ac
movsd -0x458(%rbp), %xmm0
callq 0x10560
movsd %xmm0, -0x458(%rbp)
movl $0x0, -0x46c(%rbp)
movslq -0x46c(%rbp), %rax
movq %rax, -0x550(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x24690
movq %rax, -0x548(%rbp)
jmp 0x1a996
movq -0x550(%rbp), %rax
movq -0x548(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1aa65
movl $0x0, -0x470(%rbp)
movslq -0x470(%rbp), %rax
movq %rax, -0x560(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x286d0
movq %rax, -0x558(%rbp)
jmp 0x1a9da
movq -0x560(%rbp), %rax
movq -0x558(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1aa4f
movsd -0x458(%rbp), %xmm0
movsd %xmm0, -0x570(%rbp)
movslq -0x46c(%rbp), %rsi
movslq -0x470(%rbp), %rdx
leaq -0x400(%rbp), %rdi
callq 0x246b0
movq %rax, -0x568(%rbp)
jmp 0x1aa20
movq -0x568(%rbp), %rax
movsd -0x570(%rbp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x470(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x470(%rbp)
jmp 0x1a9b7
jmp 0x1aa51
movl -0x46c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x46c(%rbp)
jmp 0x1a973
leaq -0x3b8(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x286f0
jmp 0x1aa7a
movl -0x3e8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1ac36
movl $0x0, -0x474(%rbp)
movslq -0x474(%rbp), %rax
movq %rax, -0x580(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x24690
movq %rax, -0x578(%rbp)
jmp 0x1aabe
movq -0x580(%rbp), %rax
movq -0x578(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1abca
movl $0x0, -0x478(%rbp)
movslq -0x478(%rbp), %rax
movq %rax, -0x590(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x286d0
movq %rax, -0x588(%rbp)
jmp 0x1ab02
movq -0x590(%rbp), %rax
movq -0x588(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1abb4
movslq -0x474(%rbp), %rsi
movslq -0x478(%rbp), %rdx
leaq -0x400(%rbp), %rdi
callq 0x246b0
movq %rax, -0x598(%rbp)
jmp 0x1ab3c
movq -0x598(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x5a8(%rbp)
movslq -0x474(%rbp), %rsi
movslq -0x478(%rbp), %rdx
leaq -0x3d0(%rbp), %rdi
callq 0x246b0
movq %rax, -0x5a0(%rbp)
jmp 0x1ab72
movq -0x5a0(%rbp), %rax
movsd -0x5a8(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0xa1594(%rip), %xmm1    # 0xbc120
pand %xmm1, %xmm0
addsd -0x460(%rbp), %xmm0
movsd %xmm0, -0x460(%rbp)
movl -0x478(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x478(%rbp)
jmp 0x1aadf
jmp 0x1abb6
movl -0x474(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x474(%rbp)
jmp 0x1aa9b
leaq -0x3d0(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x286f0
jmp 0x1abdf
movsd 0xa14a9(%rip), %xmm0    # 0xbc090
ucomisd -0x460(%rbp), %xmm0
jbe 0x1ac34
movl -0x3e8(%rbp), %esi
movq 0x11639a(%rip), %rdi    # 0x130f98
callq 0x10ca0
movq %rax, -0x5b0(%rbp)
jmp 0x1ac0c
movq -0x5b0(%rbp), %rdi
leaq 0xa1d37(%rip), %rsi     # 0xbc951
callq 0x106c0
jmp 0x1ac21
movb $0x1, -0x3e1(%rbp)
movl $0x2, -0x47c(%rbp)
jmp 0x1ac8c
jmp 0x1ac36
movq 0x11635b(%rip), %rdi    # 0x130f98
leaq 0xa18e1(%rip), %rsi     # 0xbc525
callq 0x106c0
movq %rax, -0x5b8(%rbp)
jmp 0x1ac52
movq -0x5b8(%rbp), %rdi
movl -0x3e8(%rbp), %esi
callq 0x10ca0
movq %rax, -0x5c0(%rbp)
jmp 0x1ac6d
movq -0x5c0(%rbp), %rdi
leaq 0xa198c(%rip), %rsi     # 0xbc607
callq 0x106c0
jmp 0x1ac82
movl $0x0, -0x47c(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x28720
movl -0x47c(%rbp), %eax
testl %eax, %eax
je 0x1aca6
jmp 0x1aca4
jmp 0x1acbc
jmp 0x1aca8
movl -0x3e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3e8(%rbp)
jmp 0x1a605
movl $0x0, -0x480(%rbp)
movslq -0x480(%rbp), %rax
movq %rax, -0x5d0(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x24690
movq %rax, -0x5c8(%rbp)
jmp 0x1ace9
movq -0x5d0(%rbp), %rax
movq -0x5c8(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1aed3
movl $0x0, -0x484(%rbp)
movslq -0x484(%rbp), %rax
movq %rax, -0x5e0(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x286d0
movq %rax, -0x5d8(%rbp)
jmp 0x1ad2d
movq -0x5e0(%rbp), %rax
movq -0x5d8(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1aebd
movl -0x484(%rbp), %edx
leaq -0x4a8(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x28740
jmp 0x1ad5f
leaq -0x210(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0x10600
movq %rax, -0x5e8(%rbp)
jmp 0x1ad7b
movq -0x5e8(%rbp), %rdi
leaq 0xa1b02(%rip), %rsi     # 0xbc88b
callq 0x106c0
movq %rax, -0x5f0(%rbp)
jmp 0x1ad97
movl -0x480(%rbp), %edx
leaq -0x4c8(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x28740
jmp 0x1adb2
movq -0x5f0(%rbp), %rdi
leaq -0x4c8(%rbp), %rsi
callq 0x10600
movq %rax, -0x5f8(%rbp)
jmp 0x1adce
movq -0x5f8(%rbp), %rdi
leaq 0xa1aaf(%rip), %rsi     # 0xbc88b
callq 0x106c0
movq %rax, -0x600(%rbp)
jmp 0x1adea
movslq -0x480(%rbp), %rsi
movslq -0x484(%rbp), %rdx
leaq -0x3b8(%rbp), %rdi
callq 0x246b0
movq %rax, -0x608(%rbp)
jmp 0x1ae0d
movq -0x600(%rbp), %rdi
movq -0x608(%rbp), %rax
movsd (%rax), %xmm1
movsd 0xa1249(%rip), %xmm0    # 0xbc070
subsd %xmm1, %xmm0
callq 0x10dc0
movq %rax, -0x610(%rbp)
jmp 0x1ae39
movq -0x610(%rbp), %rdi
leaq 0xa17c0(%rip), %rsi     # 0xbc607
callq 0x106c0
jmp 0x1ae4e
leaq -0x4c8(%rbp), %rdi
callq 0x10460
leaq -0x4a8(%rbp), %rdi
callq 0x10460
movl -0x484(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x484(%rbp)
jmp 0x1ad0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x1aeac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x4c8(%rbp), %rdi
callq 0x10460
leaq -0x4a8(%rbp), %rdi
callq 0x10460
jmp 0x1af46
jmp 0x1aebf
movl -0x480(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x480(%rbp)
jmp 0x1acc6
leaq -0x210(%rbp), %rdi
callq 0x10a40
jmp 0x1aee1
testb $0x1, -0x3e1(%rbp)
jne 0x1af01
movq 0x1160a7(%rip), %rdi    # 0x130f98
leaq 0xa1a66(%rip), %rsi     # 0xbc95e
callq 0x106c0
jmp 0x1aeff
jmp 0x1af01
leaq -0x3d0(%rbp), %rdi
callq 0x28720
leaq -0x3b8(%rbp), %rdi
callq 0x28720
leaq -0x390(%rbp), %rdi
callq 0x28790
leaq -0x328(%rbp), %rdi
callq 0x28790
leaq -0x210(%rbp), %rdi
callq 0x10ad0
addq $0x610, %rsp            # imm = 0x610
popq %rbp
retq
leaq -0x3d0(%rbp), %rdi
callq 0x28720
leaq -0x3b8(%rbp), %rdi
callq 0x28720
leaq -0x390(%rbp), %rdi
callq 0x28790
leaq -0x328(%rbp), %rdi
callq 0x28790
leaq -0x210(%rbp), %rdi
callq 0x10ad0
movq -0x298(%rbp), %rdi
callq 0x10cc0
nop