// File: LiGaCu[P]Distributed_System_to_Compute_the_Shortest_Path/serverC.cpp
// Function: Dijkstra(int, int, float*, int*, float (*) [11])
void Dijkstra(int node_num, int srcidx, float *dist, int *prev, float distans[maxnode_num][maxnode_num])
{
    bool s[maxnode_num];    
    for(int i=1; i<=node_num; ++i)
    {
        dist[i] = distans[srcidx][i];
        s[i] = 0;     
        if(dist[i] == inf_dis)
            prev[i] = 0;
        else
            prev[i] = srcidx;
    }
    dist[srcidx] = 0;
    s[srcidx] = 1;

    for(int i=2; i<=node_num; ++i)
    {
        int tmp = inf_dis;
        int u = srcidx;
        
        for(int j=1; j<=node_num; ++j)
            if((!s[j]) && dist[j]<tmp)
            {
                u = j;            
                tmp = dist[j];
            }
        s[u] = 1;    

        for(int j=1; j<=node_num; ++j)
            if((!s[j]) && distans[u][j]<inf_dis)
            {
                float newdist = dist[u] + distans[u][j];
                if(newdist < dist[j])
                {
                    dist[j] = newdist;
                    prev[j] = u;
                }
            }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0x32ab
movq -0x20(%rbp), %rax
movslq -0x8(%rbp), %rcx
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movslq -0x30(%rbp), %rax
movb $0x0, -0x2b(%rbp,%rax)
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss 0xd8c(%rip), %xmm1      # 0x4004
ucomiss %xmm1, %xmm0
jne 0x3290
jp 0x3290
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x329e
movl -0x8(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x32a0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x322d
movq -0x10(%rbp), %rax
movslq -0x8(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movslq -0x8(%rbp), %rax
movb $0x1, -0x2b(%rbp,%rax)
movl $0x2, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0x3407
movl $0x5f5e100, -0x38(%rbp) # imm = 0x5F5E100
movl -0x8(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0x3338
movslq -0x40(%rbp), %rax
testb $0x1, -0x2b(%rbp,%rax)
jne 0x332b
movq -0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtsi2ssl -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x332b
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
cvttss2si (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
jmp 0x332d
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x32eb
movslq -0x3c(%rbp), %rax
movb $0x1, -0x2b(%rbp,%rax)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0x33f7
movslq -0x44(%rbp), %rax
testb $0x1, -0x2b(%rbp,%rax)
jne 0x33e7
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x44(%rbp), %rcx
movss 0xc86(%rip), %xmm0      # 0x4004
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x33e7
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x44(%rbp), %rcx
addss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm1
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x33e5
movss -0x48(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x3c(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x33e7
jmp 0x33e9
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3348
jmp 0x33f9
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x32cb
popq %rbp
retq
nopl (%rax)