// File: /workspace/github_c_makefile_star2_O0/baileywjohnson[P]mpi-matrix-mult/MyMPI.c
// Function: read_block_vector
void read_block_vector (
    char        *s,      /* IN - File name */
    void       **v,      /* OUT - Subvector */
    MPI_Datatype dtype,  /* IN - Element type */
    int         *n,      /* OUT - Vector length */
    MPI_Comm     comm)   /* IN - Communicator */
{
   int        datum_size;   /* Bytes per element */
   int        i;
   FILE      *infileptr;    /* Input file pointer */
   int        local_els;    /* Elements on this proc */
   MPI_Status status;       /* Result of receive */
   int        id;           /* Process rank */
   int        p;            /* Number of processes */
   int        x;            /* Result of read */

   datum_size = get_size (dtype);
   MPI_Comm_size(comm, &p);
   MPI_Comm_rank(comm, &id);

   /* Process p-1 opens file, determines number of vector
      elements, and broadcasts this value to the other
      processes. */

   if (id == (p-1)) {
      infileptr = fopen (s, "r");
      if (infileptr == NULL) *n = 0;
      else fread (n, sizeof(int), 1, infileptr);
   }
   MPI_Bcast (n, 1, MPI_INT, p-1, comm);
   if (! *n) {
      if (!id) {
         printf ("Input file '%s' cannot be opened\n", s);
         fflush (stdout);
      }
   }

   /* Block mapping of vector elements to processes */

   local_els = BLOCK_SIZE(id,p,*n);

   /* Dynamically allocate vector. */

   *v = my_malloc (id, local_els * datum_size);
   if (id == (p-1)) {
      for (i = 0; i < p-1; i++) {
         x = fread (*v, datum_size, BLOCK_SIZE(i,p,*n),
            infileptr);
         MPI_Send (*v, BLOCK_SIZE(i,p,*n), dtype, i, DATA_MSG,
            comm);
      }
      x = fread (*v, datum_size, BLOCK_SIZE(id,p,*n),
             infileptr);
      fclose (infileptr);
   } else {
      MPI_Recv (*v, BLOCK_SIZE(id,p,*n), dtype, p-1, DATA_MSG,
         comm, &status);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1f70
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x10f0
movq -0x28(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x1160
movl -0x5c(%rbp), %eax
movl -0x60(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2e82
movq -0x8(%rbp), %rdi
leaq 0x1351(%rip), %rsi      # 0x419e
callq 0x10b0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x2e69
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2e80
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x1150
jmp 0x2e82
movq -0x20(%rbp), %rdi
movl -0x60(%rbp), %ecx
subl $0x1, %ecx
movq -0x28(%rbp), %r8
movl $0x1, %esi
movq 0x310c(%rip), %rdx      # 0x5fa8
callq 0x1170
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2ed3
cmpl $0x0, -0x5c(%rbp)
jne 0x2ed1
movq -0x8(%rbp), %rsi
leaq 0x12e5(%rip), %rdi      # 0x41a0
movb $0x0, %al
callq 0x1050
movq 0x312f(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
callq 0x1230
jmp 0x2ed3
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
subl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
movl %eax, %ecx
movl -0x68(%rbp), %eax
subl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x5c(%rbp), %edi
movl -0x3c(%rbp), %esi
imull -0x2c(%rbp), %esi
callq 0x2020
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x5c(%rbp), %eax
movl -0x60(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3035
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x60(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2fe1
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movslq -0x2c(%rbp), %rsi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
subl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
movl %eax, %ecx
movl -0x6c(%rbp), %eax
subl %ecx, %eax
addl $0x1, %eax
movslq %eax, %rdx
movq -0x38(%rbp), %rcx
callq 0x1150
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
movl %eax, %esi
subl $0x1, %esi
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
subl %eax, %esi
addl $0x1, %esi
movq -0x18(%rbp), %rdx
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %r9
xorl %r8d, %r8d
callq 0x1040
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2f36
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movslq -0x2c(%rbp), %rsi
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
subl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
movl %eax, %ecx
movl -0x70(%rbp), %eax
subl %ecx, %eax
addl $0x1, %eax
movslq %eax, %rdx
movq -0x38(%rbp), %rcx
callq 0x1150
movl %eax, -0x64(%rbp)
movq -0x38(%rbp), %rdi
callq 0x11b0
jmp 0x3083
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
movl %eax, %esi
subl $0x1, %esi
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
cltd
idivl -0x60(%rbp)
subl %eax, %esi
addl $0x1, %esi
movq -0x18(%rbp), %rdx
movl -0x60(%rbp), %ecx
subl $0x1, %ecx
movq -0x28(%rbp), %r9
xorl %r8d, %r8d
leaq -0x58(%rbp), %rax
movq %rax, (%rsp)
callq 0x1130
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)