// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %r8, 0x28(%rsp)
movq %rcx, 0x30(%rsp)
movl %edx, 0x24(%rsp)
movl %esi, 0x20(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdi, 0x38(%rsp)
movb $0x0, (%rax)
pushq $0x1
popq %rax
leaq 0x140(%rsp), %rcx
cmpq $0xb, %rax
je 0x2960
xorl %edx, %edx
cmpq $0xa, %rdx
je 0x2957
movl $0x4cbebc20, (%rcx,%rdx,4) # imm = 0x4CBEBC20
incq %rdx
jmp 0x2945
incq %rax
addq $0x2c, %rcx
jmp 0x293d
pushq $0x1
popq %rax
cmpq $0xb, %rax
je 0x2976
movl $0xc, 0x60(%rsp,%rax,4)
incq %rax
jmp 0x2963
movq $0x0, 0x8(%rsp)
leaq 0x90(%rsp), %rbx
leaq 0x7ba(%rip), %r14       # 0x3148
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x2050
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b4c
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2200
movq %rax, %r13
movq %rax, %rbp
shlq $0x20, %rbp
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq (%rax,%rbp), %r12
sarq $0x20, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2200
cmpl $-0x1, %r13d
je 0x298e
movq %rax, %r15
movl %r15d, %eax
cmpl $-0x1, %eax
je 0x298e
sarq $0x20, %rbp
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x20f0
movq 0x40(%rsp), %rdi
callq 0x2190
movl %eax, %ebp
leaq 0x40(%rsp), %rdi
callq 0x2070
notl %r13d
addl %r15d, %r13d
movslq %r13d, %rcx
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x20f0
movq 0x40(%rsp), %rdi
callq 0x2190
movl %eax, %r12d
movq %r13, %rdi
callq 0x2070
shlq $0x20, %r15
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r15
sarq $0x20, %r15
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
pushq $-0x1
popq %rcx
callq 0x20f0
movq 0x40(%rsp), %rdi
callq 0x2120
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x1c(%rsp)
movq %r13, %rdi
callq 0x2070
pushq $0x1
popq %rax
cmpq $0xb, %rax
je 0x2aaf
movl 0x60(%rsp,%rax,4), %ecx
cmpl %ebp, %ecx
je 0x2ac5
cmpl $0xc, %ecx
je 0x2ab5
incq %rax
jmp 0x2a97
movl 0x18(%rsp), %edx
jmp 0x2ac7
movl %ebp, 0x60(%rsp,%rax,4)
movq 0x8(%rsp), %rcx
incl %ecx
movq %rcx, 0x8(%rsp)
movl %eax, %edx
pushq $0x1
popq %rax
cmpq $0xb, %rax
je 0x2ae3
movl 0x60(%rsp,%rax,4), %ecx
cmpl %r12d, %ecx
je 0x2afa
cmpl $0xc, %ecx
je 0x2ae9
incq %rax
jmp 0x2aca
movl 0x14(%rsp), %ecx
jmp 0x2afc
movl %r12d, 0x60(%rsp,%rax,4)
movq 0x8(%rsp), %rcx
incl %ecx
movq %rcx, 0x8(%rsp)
movl %eax, %ecx
movl %edx, 0x18(%rsp)
movslq %edx, %rax
movl %ecx, 0x14(%rsp)
movslq %ecx, %rcx
imulq $0x2c, %rax, %rdx
addq %rsp, %rdx
addq $0x110, %rdx            # imm = 0x110
movss (%rdx,%rcx,4), %xmm0
movss 0x1c(%rsp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x298e
leaq (%rdx,%rcx,4), %rdx
movss %xmm1, (%rdx)
imulq $0x2c, %rcx, %rcx
addq %rsp, %rcx
addq $0x110, %rcx            # imm = 0x110
movss %xmm1, (%rcx,%rax,4)
jmp 0x298e
pushq $0x1
popq %rax
movl 0x24(%rsp), %ecx
cmpq $0xb, %rax
je 0x2b69
movl $0x4cbebc20, 0xb0(%rsp,%rax,4) # imm = 0x4CBEBC20
incq %rax
jmp 0x2b53
pushq $0x1
popq %rbx
pushq $0xb
popq %rbp
movl 0x20(%rsp), %eax
cmpq $0xb, %rbx
je 0x2b84
cmpl %eax, 0x60(%rsp,%rbx,4)
je 0x2b86
incq %rbx
jmp 0x2b73
movl %ebp, %ebx
pushq $0x1
popq %rax
cmpq $0xb, %rax
je 0x2b9c
cmpl %ecx, 0x60(%rsp,%rax,4)
je 0x2b9a
incq %rax
jmp 0x2b89
movl %eax, %ebp
leaq 0xb0(%rsp), %rdx
leaq 0xe0(%rsp), %r14
leaq 0x110(%rsp), %r8
movq 0x8(%rsp), %rdi
movl %ebx, %esi
movq %r14, %rcx
callq 0x2c2a
movl %ebp, %eax
movss 0xb0(%rsp,%rax,4), %xmm0
movq 0x28(%rsp), %rax
movss %xmm0, (%rax)
leaq 0x60(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq 0x30(%rsp), %r8
callq 0x2d31
leaq 0x90(%rsp), %rdi
callq 0x2070
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c12
jmp 0x2c12
jmp 0x2c12
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21c0