// File: /workspace/github_c_makefile_star2_O0/kkanellis[P]matvec-sparse/matvec_mpi_p2p.c
// Function: mat_vec_mult_parallel
double* mat_vec_mult_parallel(int rank, int nprocs, proc_info_t *all_proc_info,
                            int *buf_i_idx, int *buf_j_idx, double *buf_values, double *buf_x)
{
    proc_info_t *proc_info; /* info about submatrix; different per process */
    double *res;            /* result of multiplication res = A*x */

    /***** MPI MASTER (root) process only ******/
    int *nz_count, *nz_offset,    /* auxilliary arrays used for Scatterv/Gatherv */
        *row_count, *row_offset;

    /* scatter to processors all info that will be needed */
    if (rank == MASTER)
        proc_info = all_proc_info;
    else
        proc_info = (proc_info_t *)malloc( nprocs * sizeof(proc_info_t) );
    MPI_Bcast(proc_info, nprocs, proc_info_type, MASTER, MPI_COMM_WORLD);

    /* allocate memory for vectors and submatrixes */
    double *y = (double *)calloc_or_exit( proc_info[rank].row_count, sizeof(double) );
    double *x = (double *)malloc_or_exit( proc_info[rank].N * sizeof(double) );
    int *i_idx = (int *)malloc_or_exit( proc_info[rank].nz_count * sizeof(int) );
    int *j_idx = (int *)malloc_or_exit( proc_info[rank].nz_count * sizeof(int) );
    double *values = (double *)malloc_or_exit( proc_info[rank].nz_count * sizeof(double) );
    if (rank == MASTER) {
        res = (double *)malloc_or_exit( proc_info[rank].N * sizeof(double) );
    }
    
    /* process auxilliary arrays for scatterv/gatherv ops */
    if (rank == MASTER) { 
        row_count = (int *)malloc_or_exit( nprocs * sizeof(int) );
        row_offset = (int *)malloc_or_exit( nprocs * sizeof(int) );
        nz_count = (int *)malloc_or_exit( nprocs * sizeof(int) );
        nz_offset = (int *)malloc_or_exit( nprocs * sizeof(int) );

        for (int p = 0; p < nprocs; p++) {
            row_count[p] = proc_info[p].row_count;
            row_offset[p] = proc_info[p].row_start_idx;
            nz_count[p] = proc_info[p].nz_count;
            nz_offset[p] = proc_info[p].nz_start_idx;
        }
    }
        
    /* allocate buffers for requests sending */
    int **send_buf = (int **)malloc_or_exit( nprocs * sizeof(int*) );
    for (int i =0; i < nprocs; i++) {
        if (i != rank && proc_info[i].row_count > 0)
            send_buf[i] = (int *)malloc_or_exit( proc_info[i].row_count * sizeof(int) );
    }

    /* scatter x vector to processes */
    MPI_Scatterv(buf_x, row_count, row_offset, MPI_DOUBLE, &x[ proc_info[rank].row_start_idx ], 
                proc_info[rank].row_count, MPI_DOUBLE, MASTER, MPI_COMM_WORLD);

    /* scatter j_idx elements to processes */
    MPI_Scatterv(buf_j_idx, nz_count, nz_offset, MPI_INT, j_idx, 
                    proc_info[rank].nz_count, MPI_INT, MASTER, MPI_COMM_WORLD);

    int *to_send = (int *)calloc_or_exit( nprocs, sizeof(int) );    /* # of req to each proc */
    char* map = (char *)malloc_or_exit( proc_info[rank].N * sizeof(char) );

    /* build sending blocks to processors */
    int dest, col;
    for (int i = 0; i < proc_info[rank].nz_count; i++) {
        col = j_idx[i];

        /* check whether I need to send a request */
        if ( in_range(col, proc_info[rank].row_start_idx, proc_info[rank].row_count) ||
                map[col] > 0) 
            continue;

        /* search which process has the element
         * NOTE: Due to small number or processes, serial search is faster
         */
        dest = -1;
        for (int p = 0; p < nprocs; p++) {
            if ( in_range(col, proc_info[p].row_start_idx, proc_info[p].row_count) ) {
                dest = p;
                break;
            }
        }
        assert( dest >= 0 );

        /* insert new request */
        send_buf[dest][ to_send[dest]++ ] = col;
        map[col] = 1;
    }

    /* MPI request storage */
    MPI_Request *send_reqs = (MPI_Request*)malloc_or_exit( nprocs * sizeof(MPI_Request) );
    MPI_Request *recv_reqs = (MPI_Request*)malloc_or_exit( nprocs * sizeof(MPI_Request) );

    /* receiving blocks storage */
    double **recv_buf = (double **)malloc_or_exit( nprocs * sizeof(double*) );
    for (int p =0; p < nprocs; p++) {
        if (to_send[p] > 0)
            recv_buf[p] = (double *)malloc_or_exit( to_send[p] * sizeof(double) );
    }

    /* sending requests to processes in blocks */
    int req_made = 0;
    int *expect = (int *)calloc_or_exit( nprocs, sizeof(int) );
    for (int p = 0; p < nprocs; p++) {
        /* need to send to this proc? */
        if (p == rank || to_send[p] == 0) {
            send_reqs[p] = recv_reqs[p] = MPI_REQUEST_NULL;
            continue;
        }
        debug("[%d] Sending requests to process %2d \t[%5d]\n", rank, p, to_send[p]);

        /* logistics */
        expect[p] = 1;
        req_made++;

        /* send the request */
        MPI_Isend(send_buf[p], to_send[p], MPI_INT, p, REQUEST_TAG, 
                    MPI_COMM_WORLD, &send_reqs[p]);
        /* recv the block (when it comes) */
        MPI_Irecv(recv_buf[p], to_send[p], MPI_DOUBLE, p, REPLY_TAG, 
                    MPI_COMM_WORLD, &recv_reqs[p]);
    }
    debug("[%d] Sent all requests! [%4d]\n", rank, req_made);

    /* notify the processes about the number of requests they should expect */
    if (rank == MASTER)
        MPI_Reduce(MPI_IN_PLACE, expect, nprocs, MPI_INT, MPI_SUM, MASTER, MPI_COMM_WORLD);
    else
        MPI_Reduce(expect, expect, nprocs, MPI_INT, MPI_SUM, MASTER, MPI_COMM_WORLD);
    MPI_Scatter(expect, 1, MPI_INT, &expect[rank], 1, MPI_INT, MASTER, MPI_COMM_WORLD);

    /**** reply to requests ****/
    int *reqs = (int *) malloc_or_exit( proc_info[rank].row_count * sizeof(int) ); 
    double **rep_buf = (double **)malloc_or_exit( nprocs * sizeof(double*) ); /* reply blocks storage */

    MPI_Status status;
    int req_count;
    for (int p = 0; p < expect[rank]; p++) {
        /* Wait until a request comes */
        MPI_Probe(MPI_ANY_SOURCE, REQUEST_TAG, MPI_COMM_WORLD, &status);
        MPI_Get_count(&status, MPI_INT, &req_count);
        rep_buf[p] = (double *)malloc_or_exit( req_count * sizeof(double) );

        /* fill rep_buf[p] with requested x elements */
        MPI_Recv(reqs, req_count, MPI_INT, status.MPI_SOURCE, REQUEST_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
        for (int i = 0; i < req_count; i++) {
            rep_buf[p][i] = x[ reqs[i] ];
        }
        
        /* send the requested block */
        MPI_Isend(rep_buf[p], req_count, MPI_DOUBLE, status.MPI_SOURCE, REPLY_TAG, MPI_COMM_WORLD, &send_reqs[0]);
        debug("[%d] Replying requests from process %2d \t[%5d]\n", rank, status.MPI_SOURCE, req_count);
    }
    debug("[%d] Replied to all requests! [%4d]\n", rank, to_send[rank]);
    
    /* scatter j_idx & values to processes */
    MPI_Scatterv(buf_i_idx, nz_count, nz_offset, MPI_INT, i_idx, 
                    proc_info[rank].nz_count, MPI_INT, MASTER, MPI_COMM_WORLD);
    MPI_Scatterv(buf_values, nz_count, nz_offset, MPI_DOUBLE, values, 
                    proc_info[rank].nz_count, MPI_DOUBLE, MASTER, MPI_COMM_WORLD);

    /* Local elements multiplication */
    for (int k = 0 ; k < proc_info[rank].nz_count; k++) {
        if ( in_range( j_idx[k], proc_info[rank].row_start_idx, proc_info[rank].row_count) ) {
            y[ i_idx[k] - proc_info[rank].row_start_idx ] += values[k] * x[ j_idx[k] ];
        }
    }

    /* wait for all blocks to arrive */
    int p;
    debug("[%d] Waiting for %d requests\n", rank, req_made);
    for (int q = 0; q < req_made; q++) {
        MPI_Waitany(nprocs, recv_reqs, &p, MPI_STATUS_IGNORE);
        assert(p != MPI_UNDEFINED);

        /* fill x array with new elements */
        for (int i = 0; i < to_send[p]; i++) 
            x[ send_buf[p][i] ] = recv_buf[p][i];
    }

    /* Global elements multiplication */ 
    for (int k = 0 ; k < proc_info[rank].nz_count; k++) {
        if ( !in_range( j_idx[k], proc_info[rank].row_start_idx, proc_info[rank].row_count) ) {
            y[ i_idx[k] - proc_info[rank].row_start_idx ] += values[k] * x[ j_idx[k] ];
        }
    }

    /* gather y elements from processes and save it to res */
    debug("[%d] Gathering results...\n", rank);
    MPI_Gatherv(y, proc_info[rank].row_count, MPI_DOUBLE, res, row_count, 
                row_offset, MPI_DOUBLE, MASTER, MPI_COMM_WORLD);

    /* return final result */
    return res;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq 0x150(%rsp), %rax
movl %edi, 0x144(%rsp)
movl %esi, 0x140(%rsp)
movq %rdx, 0x138(%rsp)
movq %rcx, 0x130(%rsp)
movq %r8, 0x128(%rsp)
movq %r9, 0x120(%rsp)
cmpl $0x0, 0x144(%rsp)
jne 0x4119
movq 0x138(%rsp), %rax
movq %rax, 0x118(%rsp)
jmp 0x4132
movslq 0x140(%rsp), %rax
imulq $0x18, %rax, %rdi
callq 0x20e0
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
movl 0x140(%rsp), %esi
movq 0x4030(%rip), %rdx      # 0x8178
xorl %ecx, %ecx
movq 0x3e87(%rip), %r8       # 0x7fd8
callq 0x21c0
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x10(%rax), %rdi
movl $0x8, %esi
callq 0x4020
movq %rax, 0xe8(%rsp)
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0xe0(%rsp)
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0xd8(%rsp)
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0xd0(%rsp)
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0xc8(%rsp)
cmpl $0x0, 0x144(%rsp)
jne 0x4267
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0x110(%rsp)
cmpl $0x0, 0x144(%rsp)
jne 0x43c4
movslq 0x140(%rsp), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0xf8(%rsp)
movslq 0x140(%rsp), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0xf0(%rsp)
movslq 0x140(%rsp), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0x108(%rsp)
movslq 0x140(%rsp), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0x100(%rsp)
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
cmpl 0x140(%rsp), %eax
jge 0x43c2
movq 0x118(%rsp), %rax
movslq 0xc4(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
movq 0xf8(%rsp), %rax
movslq 0xc4(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x118(%rsp), %rax
movslq 0xc4(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %edx
movq 0xf0(%rsp), %rax
movslq 0xc4(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x118(%rsp), %rax
movslq 0xc4(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq 0x108(%rsp), %rax
movslq 0xc4(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x118(%rsp), %rax
movslq 0xc4(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %edx
movq 0x100(%rsp), %rax
movslq 0xc4(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x42e4
jmp 0x43c4
movslq 0x140(%rsp), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0xb8(%rsp)
movl $0x0, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
cmpl 0x140(%rsp), %eax
jge 0x447c
movl 0xb4(%rsp), %eax
cmpl 0x144(%rsp), %eax
je 0x4464
movq 0x118(%rsp), %rax
movslq 0xb4(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x10(%rax)
jle 0x4464
movq 0x118(%rsp), %rax
movslq 0xb4(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x10(%rax), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, %rdx
movq 0xb8(%rsp), %rax
movslq 0xb4(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4466
movl 0xb4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb4(%rsp)
jmp 0x43e8
movq 0x150(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
movq 0xe0(%rsp), %r8
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x14(%rax), %rax
shlq $0x3, %rax
addq %rax, %r8
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %r9d
movq 0x3af0(%rip), %r10      # 0x7fd0
xorl %eax, %eax
movq 0x3aef(%rip), %rax      # 0x7fd8
movq %r10, %rcx
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2120
movq 0x128(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0x100(%rsp), %rdx
movq 0xd0(%rsp), %r8
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %r9d
movq 0x3a64(%rip), %r10      # 0x7fa8
xorl %eax, %eax
movq 0x3a8b(%rip), %rax      # 0x7fd8
movq %r10, %rcx
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2120
movslq 0x140(%rsp), %rdi
movl $0x4, %esi
callq 0x4020
movq %rax, 0xa8(%rsp)
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rdi
shlq $0x0, %rdi
callq 0x3fd0
movq %rax, 0xa0(%rsp)
movl $0x0, 0x94(%rsp)
movl 0x94(%rsp), %eax
movq 0x118(%rsp), %rcx
movslq 0x144(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jge 0x4780
movq 0xd0(%rsp), %rax
movslq 0x94(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x98(%rsp)
movl 0x98(%rsp), %edi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %esi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
callq 0x4080
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x4658
movq 0xa0(%rsp), %rax
movslq 0x98(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jle 0x465d
jmp 0x476a
movl $0xffffffff, 0x9c(%rsp) # imm = 0xFFFFFFFF
movl $0x0, 0x90(%rsp)
movl 0x90(%rsp), %eax
cmpl 0x140(%rsp), %eax
jge 0x46ec
movl 0x98(%rsp), %edi
movq 0x118(%rsp), %rax
movslq 0x90(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %esi
movq 0x118(%rsp), %rax
movslq 0x90(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
callq 0x4080
cmpb $0x0, %al
je 0x46d7
movl 0x90(%rsp), %eax
movl %eax, 0x9c(%rsp)
jmp 0x46ec
jmp 0x46d9
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x4673
cmpl $0x0, 0x9c(%rsp)
jl 0x46f8
jmp 0x4717
leaq 0x1c19(%rip), %rdi      # 0x6318
leaq 0x1c1c(%rip), %rsi      # 0x6322
movl $0x6a, %edx
leaq 0x1c21(%rip), %rcx      # 0x6333
callq 0x20b0
movl 0x98(%rsp), %edx
movq 0xb8(%rsp), %rax
movslq 0x9c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa8(%rsp), %rsi
movslq 0x9c(%rsp), %rdi
movl (%rsi,%rdi,4), %ecx
movl %ecx, %r8d
addl $0x1, %r8d
movl %r8d, (%rsi,%rdi,4)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0xa0(%rsp), %rax
movslq 0x98(%rsp), %rcx
movb $0x1, (%rax,%rcx)
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x45b6
movslq 0x140(%rsp), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0x88(%rsp)
movslq 0x140(%rsp), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0x80(%rsp)
movslq 0x140(%rsp), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0x78(%rsp)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0x140(%rsp), %eax
jge 0x482a
movq 0xa8(%rsp), %rax
movslq 0x74(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x481b
movq 0xa8(%rsp), %rax
movslq 0x74(%rsp), %rcx
movslq (%rax,%rcx,4), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, %rdx
movq 0x78(%rsp), %rax
movslq 0x74(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x481d
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x47d0
movl $0x0, 0x70(%rsp)
movslq 0x140(%rsp), %rdi
movl $0x4, %esi
callq 0x4020
movq %rax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x140(%rsp), %eax
jge 0x498d
movl 0x64(%rsp), %eax
cmpl 0x144(%rsp), %eax
je 0x4882
movq 0xa8(%rsp), %rax
movslq 0x64(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x48b7
movq 0x80(%rsp), %rax
movslq 0x64(%rsp), %rcx
movq 0x370a(%rip), %rdx      # 0x7fa0
movq %rdx, (%rax,%rcx,8)
movq 0x88(%rsp), %rax
movslq 0x64(%rsp), %rcx
movq 0x36f2(%rip), %rdx      # 0x7fa0
movq %rdx, (%rax,%rcx,8)
jmp 0x497d
jmp 0x48b9
jmp 0x48bb
movq 0x68(%rsp), %rax
movslq 0x64(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
movq 0xb8(%rsp), %rax
movslq 0x64(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movl 0x64(%rsp), %ecx
movq 0x88(%rsp), %rax
movslq 0x64(%rsp), %rdx
shlq $0x3, %rdx
addq %rdx, %rax
movq 0x3691(%rip), %rdx      # 0x7fa8
xorl %r8d, %r8d
movq 0x36b7(%rip), %r9       # 0x7fd8
movq %rax, (%rsp)
callq 0x20c0
movq 0x78(%rsp), %rax
movslq 0x64(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movl 0x64(%rsp), %ecx
movq 0x80(%rsp), %rax
movslq 0x64(%rsp), %rdx
shlq $0x3, %rdx
addq %rdx, %rax
movq 0x3669(%rip), %rdx      # 0x7fd0
movl $0x1, %r8d
movq 0x3664(%rip), %r9       # 0x7fd8
movq %rax, (%rsp)
callq 0x20a0
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x4851
jmp 0x498f
jmp 0x4991
cmpl $0x0, 0x144(%rsp)
jne 0x49cf
movq 0x68(%rsp), %rsi
movl 0x140(%rsp), %edx
movl $0x1, %edi
movq 0x35f5(%rip), %rcx      # 0x7fa8
movq 0x3626(%rip), %r8       # 0x7fe0
xorl %r9d, %r9d
movq 0x3614(%rip), %rax      # 0x7fd8
movq %rax, (%rsp)
callq 0x21d0
jmp 0x4a01
movq 0x68(%rsp), %rdi
movq 0x68(%rsp), %rsi
movl 0x140(%rsp), %edx
movq 0x35c1(%rip), %rcx      # 0x7fa8
movq 0x35f2(%rip), %r8       # 0x7fe0
xorl %r9d, %r9d
movq 0x35e0(%rip), %rax      # 0x7fd8
movq %rax, (%rsp)
callq 0x21d0
movq 0x68(%rsp), %rdi
movq 0x68(%rsp), %rcx
movslq 0x144(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rcx
movl $0x1, %r8d
movq 0x3581(%rip), %r9       # 0x7fa8
xorl %eax, %eax
movq 0x35a8(%rip), %rax      # 0x7fd8
movl %r8d, %esi
movq %r9, %rdx
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2210
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x10(%rax), %rdi
shlq $0x2, %rdi
callq 0x3fd0
movq %rax, 0x58(%rsp)
movslq 0x140(%rsp), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, 0x50(%rsp)
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
movq 0x68(%rsp), %rcx
movslq 0x144(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x4bc3
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
movq 0x3522(%rip), %rdx      # 0x7fd8
leaq 0x38(%rsp), %rcx
callq 0x2190
leaq 0x38(%rsp), %rdi
movq 0x34dc(%rip), %rsi      # 0x7fa8
leaq 0x34(%rsp), %rdx
callq 0x2050
movslq 0x34(%rsp), %rdi
shlq $0x3, %rdi
callq 0x3fd0
movq %rax, %rdx
movq 0x50(%rsp), %rax
movslq 0x30(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x58(%rsp), %rdi
movl 0x34(%rsp), %esi
movl 0x38(%rsp), %ecx
movq 0x349f(%rip), %rdx      # 0x7fa8
xorl %r8d, %r8d
movq 0x34c5(%rip), %r9       # 0x7fd8
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x21a0
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x34(%rsp), %eax
jge 0x4b74
movq 0xe0(%rsp), %rax
movq 0x58(%rsp), %rcx
movslq 0x2c(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x50(%rsp), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x2c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x4b2a
movq 0x50(%rsp), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movl 0x34(%rsp), %esi
movl 0x38(%rsp), %ecx
movq 0x88(%rsp), %rax
movq 0x3437(%rip), %rdx      # 0x7fd0
movl $0x1, %r8d
movq 0x3432(%rip), %r9       # 0x7fd8
movq %rax, (%rsp)
callq 0x20c0
jmp 0x4bb1
jmp 0x4bb3
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x4a8e
jmp 0x4bc5
jmp 0x4bc7
movq 0x130(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0x100(%rsp), %rdx
movq 0xd8(%rsp), %r8
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %r9d
movq 0x339f(%rip), %r10      # 0x7fa8
xorl %eax, %eax
movq 0x33c6(%rip), %rax      # 0x7fd8
movq %r10, %rcx
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2120
movq 0x120(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0x100(%rsp), %rdx
movq 0xc8(%rsp), %r8
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %r9d
movq 0x3363(%rip), %r10      # 0x7fd0
xorl %eax, %eax
movq 0x3362(%rip), %rax      # 0x7fd8
movq %r10, %rcx
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2120
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
movq 0x118(%rsp), %rcx
movslq 0x144(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jge 0x4d91
movq 0xd0(%rsp), %rax
movslq 0x28(%rsp), %rcx
movl (%rax,%rcx,4), %edi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %esi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
callq 0x4080
cmpb $0x0, %al
je 0x4d7f
movq 0xc8(%rsp), %rax
movslq 0x28(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0xe0(%rsp), %rax
movq 0xd0(%rsp), %rcx
movslq 0x28(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rcx
movslq 0x28(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movq 0x118(%rsp), %rdx
movslq 0x144(%rsp), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rdx
subl 0x14(%rdx), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x4d81
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x4c97
jmp 0x4d93
jmp 0x4d95
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x70(%rsp), %eax
jge 0x4e6f
movl 0x140(%rsp), %edi
movq 0x80(%rsp), %rsi
leaq 0x24(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x2070
cmpl $0xffff8002, 0x24(%rsp) # imm = 0xFFFF8002
je 0x4dd4
jmp 0x4df3
leaq 0x15b1(%rip), %rdi      # 0x638c
leaq 0x1540(%rip), %rsi      # 0x6322
movl $0xc5, %edx
leaq 0x1545(%rip), %rcx      # 0x6333
callq 0x20b0
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0xa8(%rsp), %rcx
movslq 0x24(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x4e5d
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0xe0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movslq 0x24(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x1c(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x4dfb
jmp 0x4e5f
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x4d9d
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
movq 0x118(%rsp), %rcx
movslq 0x144(%rsp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jge 0x4f71
movq 0xd0(%rsp), %rax
movslq 0x18(%rsp), %rcx
movl (%rax,%rcx,4), %edi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %esi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
callq 0x4080
cmpb $0x0, %al
jne 0x4f5f
movq 0xc8(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0xe0(%rsp), %rax
movq 0xd0(%rsp), %rcx
movslq 0x18(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0xe8(%rsp), %rax
movq 0xd8(%rsp), %rcx
movslq 0x18(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movq 0x118(%rsp), %rdx
movslq 0x144(%rsp), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rdx
subl 0x14(%rdx), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x4f61
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x4e77
jmp 0x4f73
jmp 0x4f75
movq 0xe8(%rsp), %rdi
movq 0x118(%rsp), %rax
movslq 0x144(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %esi
movq 0x110(%rsp), %rcx
movq 0xf8(%rsp), %r8
movq 0xf0(%rsp), %r9
movq 0x301a(%rip), %r10      # 0x7fd0
xorl %eax, %eax
movq 0x3019(%rip), %rax      # 0x7fd8
movq %r10, %rdx
movq %r10, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2280
movq 0x110(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
nopl (%rax,%rax)