// File: LiGaCu[P]Distributed_System_to_Compute_the_Shortest_Path/serverC.cpp
// Function: searchpath(std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char>>&, int, int, int*, float*)
void searchpath(std::istringstream &tokenStream,int srcVtxid,int dstVtxid, int *path, float *mindistan)
{
    std::string line;
    int lspacepos, rspacepos, fstdgt, secdgt;
    float distan;

    float dist[maxnode_num];
    int prev[maxnode_num];
    float distans[maxnode_num][maxnode_num];
    int node_num = 0, link_num = 0;

    int indextable[maxnode_num];
    int firstidx, secondidx, srcidx = maxnode_num, dstidx = maxnode_num;

    for(int i=1; i<maxnode_num; i++)
        for(int j=1; j<maxnode_num; j++)
            distans[i][j] = inf_dis;
    
    for(int i=1; i<maxnode_num; i++)
        indextable[i] = defaultidx;

    while ( getline (tokenStream,line) )
    {
        lspacepos = line.find(" ");
        rspacepos = line.find(" ",lspacepos+1);
        if(lspacepos != -1 && rspacepos != -1)
        {
            link_num++;
            fstdgt = atoi(line.substr(0,lspacepos).c_str());
            secdgt = atoi(line.substr(lspacepos+1,rspacepos-lspacepos-1).c_str());
            distan = atof(line.substr(rspacepos+1).c_str());

            for(int i=1;i<maxnode_num;i++)
            {
                if(indextable[i] == fstdgt)
                {
                    firstidx = i;
                    break;
                }
                else if(indextable[i] == defaultidx)
                {
                    indextable[i] = fstdgt;
                    firstidx = i;
                    node_num++;
                    break;
                }
            }
            for(int i=1;i<maxnode_num;i++)
            {
                if(indextable[i] == secdgt)
                {
                    secondidx = i;
                    break;
                }
                else if(indextable[i] == defaultidx)
                {
                    indextable[i] = secdgt;
                    secondidx = i;
                    node_num++;
                    break;
                }
            }
            if (distans[firstidx][secondidx] > distan)
            {
                distans[firstidx][secondidx] = distan;
                distans[secondidx][firstidx] = distan;
            }
        }
    }

    for(int i=1; i<maxnode_num; i++)
        dist[i] = inf_dis;

    for(int i=1;i<maxnode_num;i++)
    {
        if(indextable[i] == srcVtxid) {
            srcidx = i; 
            break;
        }
    }
    for(int i=1;i<maxnode_num;i++)
    {
        if(indextable[i] == dstVtxid) {
            dstidx = i;
            break;
        }
    }

    Dijkstra(node_num, srcidx, dist, prev, distans);
    *mindistan = dist[dstidx];
    recoverPath(prev, srcidx, dstidx, indextable, path);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2180
movl $0x0, -0x2a4(%rbp)
movl $0x0, -0x2a8(%rbp)
movl $0xb, -0x2ec(%rbp)
movl $0xb, -0x2f0(%rbp)
movl $0x1, -0x2f4(%rbp)
cmpl $0xb, -0x2f4(%rbp)
jge 0x2d61
movl $0x1, -0x2f8(%rbp)
cmpl $0xb, -0x2f8(%rbp)
jge 0x2d4e
movslq -0x2f4(%rbp), %rcx
leaq -0x2a0(%rbp), %rax
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x2f8(%rbp), %rcx
movss 0x12cc(%rip), %xmm0     # 0x4004
movss %xmm0, (%rax,%rcx,4)
movl -0x2f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2f8(%rbp)
jmp 0x2d0b
jmp 0x2d50
movl -0x2f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2f4(%rbp)
jmp 0x2cf8
movl $0x1, -0x2fc(%rbp)
cmpl $0xb, -0x2fc(%rbp)
jge 0x2d97
movslq -0x2fc(%rbp), %rax
movl $0xc, -0x2e0(%rbp,%rax,4)
movl -0x2fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2fc(%rbp)
jmp 0x2d6b
jmp 0x2d99
movq -0x8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x2050
movq %rax, -0x390(%rbp)
jmp 0x2daf
movq -0x390(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2150
movb %al, -0x391(%rbp)
jmp 0x2dcd
movb -0x391(%rbp), %al
testb $0x1, %al
jne 0x2ddc
jmp 0x30c0
leaq -0x40(%rbp), %rdi
leaq 0x1361(%rip), %rsi      # 0x4148
xorl %eax, %eax
movl %eax, %edx
callq 0x2220
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
leaq -0x40(%rbp), %rdi
leaq 0x1341(%rip), %rsi      # 0x4148
callq 0x2220
movl %eax, -0x48(%rbp)
cmpl $-0x1, -0x44(%rbp)
je 0x30bb
cmpl $-0x1, -0x48(%rbp)
je 0x30bb
movl -0x2a8(%rbp), %eax
incl %eax
movl %eax, -0x2a8(%rbp)
movslq -0x44(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x330(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x20f0
jmp 0x2e4b
leaq -0x330(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x2070
movq %rax, %rdi
callq 0x21c0
movq -0x3a0(%rbp), %rdi
movl %eax, -0x4c(%rbp)
callq 0x2090
movl -0x44(%rbp), %eax
movl %eax, %ecx
incl %ecx
movslq %ecx, %rdx
movl -0x48(%rbp), %ecx
notl %eax
addl %ecx, %eax
movslq %eax, %rcx
leaq -0x350(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x20f0
jmp 0x2e9b
leaq -0x350(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x2070
movq %rax, %rdi
callq 0x21c0
movq -0x3a8(%rbp), %rdi
movl %eax, -0x50(%rbp)
callq 0x2090
movl -0x48(%rbp), %eax
incl %eax
movslq %eax, %rdx
leaq -0x370(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movq $-0x1, %rcx
callq 0x20f0
jmp 0x2ee6
leaq -0x370(%rbp), %rdi
callq 0x2070
movq %rax, %rdi
callq 0x2130
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x2090
movl $0x1, -0x374(%rbp)
cmpl $0xb, -0x374(%rbp)
jge 0x2fbe
movslq -0x374(%rbp), %rax
movl -0x2e0(%rbp,%rax,4), %eax
cmpl -0x4c(%rbp), %eax
jne 0x2f67
movl -0x374(%rbp), %eax
movl %eax, -0x2e4(%rbp)
jmp 0x2fbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x308(%rbp)
movl %eax, -0x30c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2090
jmp 0x31f8
movslq -0x374(%rbp), %rax
cmpl $0xc, -0x2e0(%rbp,%rax,4)
jne 0x2fa6
movl -0x4c(%rbp), %ecx
movslq -0x374(%rbp), %rax
movl %ecx, -0x2e0(%rbp,%rax,4)
movl -0x374(%rbp), %eax
movl %eax, -0x2e4(%rbp)
movl -0x2a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a4(%rbp)
jmp 0x2fbe
jmp 0x2fa8
jmp 0x2faa
movl -0x374(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x374(%rbp)
jmp 0x2f19
movl $0x1, -0x378(%rbp)
cmpl $0xb, -0x378(%rbp)
jge 0x3046
movslq -0x378(%rbp), %rax
movl -0x2e0(%rbp,%rax,4), %eax
cmpl -0x50(%rbp), %eax
jne 0x2ff2
movl -0x378(%rbp), %eax
movl %eax, -0x2e8(%rbp)
jmp 0x3046
movslq -0x378(%rbp), %rax
cmpl $0xc, -0x2e0(%rbp,%rax,4)
jne 0x3031
movl -0x50(%rbp), %ecx
movslq -0x378(%rbp), %rax
movl %ecx, -0x2e0(%rbp,%rax,4)
movl -0x378(%rbp), %eax
movl %eax, -0x2e8(%rbp)
movl -0x2a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a4(%rbp)
jmp 0x3046
jmp 0x3033
jmp 0x3035
movl -0x378(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x378(%rbp)
jmp 0x2fc8
movslq -0x2e4(%rbp), %rcx
leaq -0x2a0(%rbp), %rax
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x2e8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
ucomiss -0x54(%rbp), %xmm0
jbe 0x30b9
movss -0x54(%rbp), %xmm0
movslq -0x2e4(%rbp), %rcx
leaq -0x2a0(%rbp), %rax
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x2e8(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movss -0x54(%rbp), %xmm0
movslq -0x2e8(%rbp), %rcx
leaq -0x2a0(%rbp), %rax
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movslq -0x2e4(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x30bb
jmp 0x2d99
movl $0x1, -0x37c(%rbp)
cmpl $0xb, -0x37c(%rbp)
jge 0x30f9
movslq -0x37c(%rbp), %rax
movss 0xf22(%rip), %xmm0      # 0x4004
movss %xmm0, -0x80(%rbp,%rax,4)
movl -0x37c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x37c(%rbp)
jmp 0x30ca
movl $0x1, -0x380(%rbp)
cmpl $0xb, -0x380(%rbp)
jge 0x3140
movslq -0x380(%rbp), %rax
movl -0x2e0(%rbp,%rax,4), %eax
cmpl -0xc(%rbp), %eax
jne 0x312d
movl -0x380(%rbp), %eax
movl %eax, -0x2ec(%rbp)
jmp 0x3140
jmp 0x312f
movl -0x380(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x380(%rbp)
jmp 0x3103
movl $0x1, -0x384(%rbp)
cmpl $0xb, -0x384(%rbp)
jge 0x3187
movslq -0x384(%rbp), %rax
movl -0x2e0(%rbp,%rax,4), %eax
cmpl -0x10(%rbp), %eax
jne 0x3174
movl -0x384(%rbp), %eax
movl %eax, -0x2f0(%rbp)
jmp 0x3187
jmp 0x3176
movl -0x384(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x384(%rbp)
jmp 0x314a
movl -0x2a4(%rbp), %edi
movl -0x2ec(%rbp), %esi
leaq -0x80(%rbp), %rdx
leaq -0xb0(%rbp), %rcx
leaq -0x2a0(%rbp), %r8
callq 0x3210
jmp 0x31ac
movslq -0x2f0(%rbp), %rax
movss -0x80(%rbp,%rax,4), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, (%rax)
movl -0x2ec(%rbp), %esi
movl -0x2f0(%rbp), %edx
movq -0x18(%rbp), %r8
leaq -0xb0(%rbp), %rdi
leaq -0x2e0(%rbp), %rcx
callq 0x3410
jmp 0x31e6
leaq -0x40(%rbp), %rdi
callq 0x2090
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
movq -0x308(%rbp), %rdi
callq 0x21f0
nopw %cs:(%rax,%rax)