// File: /workspace/github_cpp_makefile_star2_O1/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, 0x50(%rsp)
movq %rcx, 0x58(%rsp)
movl %edx, 0x24(%rsp)
movl %esi, 0x20(%rsp)
movq %rdi, %r13
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x1, %eax
leaq 0x140(%rsp), %rcx
xorl %edx, %edx
movl $0x4cbebc20, (%rcx,%rdx,4) # imm = 0x4CBEBC20
incq %rdx
cmpq $0xa, %rdx
jne 0x2af0
incq %rax
addq $0x2c, %rcx
cmpq $0xb, %rax
jne 0x2aee
movl $0x1, %eax
movl $0xc, 0x80(%rsp,%rax,4)
incq %rax
cmpq $0xb, %rax
jne 0x2b12
movq $0x0, 0x8(%rsp)
leaq 0x60(%rsp), %rbx
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x20c0
movsbl %al, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2d70
movl $0x1, %ecx
movq %rbx, %rdi
leaq 0x5d0(%rip), %r15       # 0x3148
movq %r15, %rsi
xorl %edx, %edx
callq 0x21d0
movq %rax, %r14
movq %rax, %r12
shlq $0x20, %r12
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq (%r12,%rax), %rbp
sarq $0x20, %rbp
movl $0x1, %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x21d0
cmpl $-0x1, %r14d
je 0x2b34
movq %rax, %r15
movl %r15d, %eax
cmpl $-0x1, %eax
je 0x2b34
sarq $0x20, %r12
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x20e0
movq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0x2190
movl %eax, 0x1c(%rsp)
leaq 0x38(%rsp), %rax
cmpq %rax, %r12
je 0x2c0b
movq 0x38(%rsp), %rsi
incq %rsi
movq %r12, %rdi
callq 0x20d0
notl %r14d
addl %r15d, %r14d
movslq %r14d, %rcx
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x20e0
movq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x2190
movl %eax, %ebp
leaq 0x38(%rsp), %rax
cmpq %rax, %r14
je 0x2c4d
movq 0x38(%rsp), %rsi
incq %rsi
movq %r14, %rdi
callq 0x20d0
shlq $0x20, %r15
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r15
sarq $0x20, %r15
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq $-0x1, %rcx
callq 0x20e0
movq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x2110
leaq 0x38(%rsp), %rax
cmpq %rax, %r14
je 0x2cac
movq 0x38(%rsp), %rsi
incq %rsi
movq %r14, %rdi
movsd %xmm0, 0x48(%rsp)
callq 0x20d0
movsd 0x48(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movl $0x1, %eax
movl 0x18(%rsp), %edx
movl 0x1c(%rsp), %esi
movl 0x80(%rsp,%rax,4), %ecx
cmpl %esi, %ecx
je 0x2ceb
cmpl $0xc, %ecx
je 0x2cd8
incq %rax
cmpq $0xb, %rax
jne 0x2cbd
jmp 0x2ced
movl %esi, 0x80(%rsp,%rax,4)
movq 0x8(%rsp), %rcx
incl %ecx
movq %rcx, 0x8(%rsp)
movl %eax, %edx
movl $0x1, %eax
movl 0x80(%rsp,%rax,4), %ecx
cmpl %ebp, %ecx
je 0x2d24
cmpl $0xc, %ecx
je 0x2d11
incq %rax
cmpq $0xb, %rax
jne 0x2cf2
movl 0x14(%rsp), %ecx
jmp 0x2d26
movl %ebp, 0x80(%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), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x2b34
leaq (%rdx,%rcx,4), %rdx
movss %xmm0, (%rdx)
imulq $0x2c, %rcx, %rcx
addq %rsp, %rcx
addq $0x110, %rcx            # imm = 0x110
movss %xmm0, (%rcx,%rax,4)
jmp 0x2b34
movl $0x1, %eax
movl $0x4cbebc20, 0xb0(%rsp,%rax,4) # imm = 0x4CBEBC20
incq %rax
cmpq $0xb, %rax
jne 0x2d75
movl $0x1, %ebx
movl 0x24(%rsp), %eax
movl 0x20(%rsp), %ecx
cmpl %ecx, 0x80(%rsp,%rbx,4)
je 0x2dad
incq %rbx
cmpq $0xb, %rbx
jne 0x2d96
movl $0xb, %ebx
movl $0x1, %r14d
cmpl %eax, 0x80(%rsp,%r14,4)
je 0x2dcc
incq %r14
cmpq $0xb, %r14
jne 0x2db3
movl $0xb, %r14d
leaq 0xb0(%rsp), %rdx
leaq 0xe0(%rsp), %r15
leaq 0x110(%rsp), %r8
movq 0x8(%rsp), %rdi
movl %ebx, %esi
movq %r15, %rcx
callq 0x2e7d
movl %r14d, %eax
movss 0xb0(%rsp,%rax,4), %xmm0
movq 0x50(%rsp), %rax
movss %xmm0, (%rax)
leaq 0x80(%rsp), %rcx
movq %r15, %rdi
movl %ebx, %esi
movl %r14d, %edx
movq 0x58(%rsp), %r8
callq 0x2f89
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2e3e
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x20d0
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e56
jmp 0x2e56
jmp 0x2e56
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2e75
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x20d0
movq %rbx, %rdi
callq 0x21e0