// File: /workspace/github_cpp_makefile_star2_O1/ruippeixotog[P]algo-lib/min-cost-max-flow.cpp
// Function: dijkstra(int, int)
int dijkstra(int src, int dest) {
  memset(dist, 0x3f, sizeof(dist));
  memset(parent, -1, sizeof(parent));

  priority_queue<pair<int, int>> q;
  q.push(make_pair(0, src)); dist[src] = 0;

  while(!q.empty()) {
    int curr = q.top().second; q.pop();

    if(parent[curr] >= 0) continue;
    parent[curr] = -parent[curr] - 1;

    for(int adj : adjs[curr]) {
      if(parent[adj] >= 0) continue;

      if(flow[adj][curr] && pot(curr, adj) - cost[adj][curr] < dist[adj]) {
        dist[adj] = pot(curr, adj) - cost[adj][curr];
        parent[adj] = -curr - 1;
        q.push(make_pair(-dist[adj], adj));
      }

      if(flow[curr][adj] < cap[curr][adj] && pot(curr, adj) + cost[curr][adj] < dist[adj]) {
        dist[adj] = pot(curr, adj) + cost[curr][adj];
        parent[adj] = -curr - 1;
        q.push(make_pair(-dist[adj], adj));
      }
    }
  }

  for(int i = 0; i < n; i++) { pi[i] += dist[i]; }
  return dist[dest];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %ebx
movl %edi, %r12d
leaq 0x7a9e1a(%rip), %r14    # 0x7ab050
movl $0xfa0, %edx            # imm = 0xFA0
movq %r14, %rdi
movl $0x3f, %esi
callq 0x1050
leaq 0x7aada1(%rip), %r15    # 0x7abff0
movl $0xfa0, %edx            # imm = 0xFA0
movq %r15, %rdi
movl $0xff, %esi
callq 0x1050
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %r12, %rax
shlq $0x20, %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
callq 0x1620
movl %ebx, 0x1c(%rsp)
movslq %r12d, %rax
movl $0x0, (%r14,%rax,4)
movq 0x20(%rsp), %rdi
cmpq 0x28(%rsp), %rdi
movq %r14, %r8
je 0x142c
movq %r8, %r14
movslq 0x4(%rdi), %r13
leaq 0x20(%rsp), %rdi
callq 0x16b0
movl (%r15,%r13,4), %eax
testl %eax, %eax
movq %r14, %r8
jns 0x141c
notl %eax
movl %eax, (%r15,%r13,4)
leaq (,%r13,2), %rax
addq %r13, %rax
leaq 0x2dae(%rip), %rcx      # 0x4090
movq (%rcx,%rax,8), %r12
movq 0x8(%rcx,%rax,8), %rbx
cmpq %rbx, %r12
je 0x141c
movl %r13d, %eax
notl %eax
movl %eax, 0xc(%rsp)
imulq $0xfa0, %r13, %rcx      # imm = 0xFA0
leaq 0x7acc25(%rip), %rax    # 0x7adf30
addq %rcx, %rax
movq %rax, 0x50(%rsp)
leaq 0x3d9436(%rip), %rax    # 0x3da750
addq %rcx, %rax
movq %rax, 0x48(%rsp)
leaq 0x8b27(%rip), %rax      # 0x9e50
addq %rax, %rcx
movq %rcx, 0x40(%rsp)
movslq (%r12), %rbp
cmpl $0x0, (%r15,%rbp,4)
jns 0x140f
imulq $0xfa0, %rbp, %rcx      # imm = 0xFA0
leaq 0x7acbe2(%rip), %rax    # 0x7adf30
addq %rcx, %rax
cmpl $0x0, (%rax,%r13,4)
je 0x13af
leaq 0x7abc31(%rip), %rdx    # 0x7acf90
movl (%rdx,%r13,4), %eax
movl (%rdx,%rbp,4), %edx
leaq 0x8ae3(%rip), %rsi      # 0x9e50
addq %rsi, %rcx
addl (%r8,%r13,4), %eax
addl (%rcx,%r13,4), %edx
subl %edx, %eax
cmpl (%r8,%rbp,4), %eax
jge 0x13af
movl %eax, (%r8,%rbp,4)
movl 0xc(%rsp), %ecx
movl %ecx, (%r15,%rbp,4)
negl %eax
movq %rbp, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1620
movq %r14, %r8
movq 0x50(%rsp), %rax
movl (%rax,%rbp,4), %eax
movq 0x48(%rsp), %rcx
cmpl (%rcx,%rbp,4), %eax
jge 0x140f
leaq 0x7abbc8(%rip), %rcx    # 0x7acf90
movl (%rcx,%r13,4), %eax
addl (%r8,%r13,4), %eax
subl (%rcx,%rbp,4), %eax
movq 0x40(%rsp), %rcx
addl (%rcx,%rbp,4), %eax
cmpl (%r8,%rbp,4), %eax
jge 0x140f
movl %ebp, %ecx
movl %eax, (%r8,%rbp,4)
movl 0xc(%rsp), %edx
movl %edx, (%r15,%rbp,4)
negl %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1620
movq %r14, %r8
addq $0x4, %r12
cmpq %rbx, %r12
jne 0x1331
movq 0x20(%rsp), %rdi
cmpq 0x28(%rsp), %rdi
jne 0x12aa
movslq 0x2c4d(%rip), %rax      # 0x4080
testq %rax, %rax
jle 0x1455
shlq $0x2, %rax
xorl %ecx, %ecx
leaq 0x7abb4b(%rip), %rdx    # 0x7acf90
movl (%rcx,%r8), %esi
addl %esi, (%rcx,%rdx)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x1445
movslq 0x1c(%rsp), %rax
movl (%r8,%rax,4), %ebx
testq %rdi, %rdi
je 0x1468
callq 0x1080
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x147f
jmp 0x147f
jmp 0x147f
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1491
callq 0x1080
movq %rbx, %rdi
callq 0x10a0