// File: /workspace/github_c_makefile_star2_O3/baileywjohnson[P]mpi-matrix-mult/MyMPI.c
// Function: print_row_striped_matrix
void print_row_striped_matrix (
   void **a,            /* IN - 2D array */
   MPI_Datatype dtype,  /* IN - Matrix element type */
   int m,               /* IN - Matrix rows */
   int n,               /* IN - Matrix cols */
   MPI_Comm comm)       /* IN - Communicator */
{
   MPI_Status  status;          /* Result of receive */
   void       *bstorage;        /* Elements received from
                                   another process */
   void      **b;               /* 2D array indexing into
                                   'bstorage' */
   int         datum_size;      /* Bytes per element */
   int         i;
   int         id;              /* Process rank */
   int         local_rows;      /* This proc's rows */
   int         max_block_size;  /* Most matrix rows held by
                                   any process */
   int         prompt;          /* Dummy variable */
   int         p;               /* Number of processes */

   MPI_Comm_rank (comm, &id);
   MPI_Comm_size (comm, &p);
   local_rows = BLOCK_SIZE(id,p,m);
   if (!id) {
      print_submatrix (a, dtype, local_rows, n);
      if (p > 1) {
         datum_size = get_size (dtype);
         max_block_size = BLOCK_SIZE(p-1,p,m);
         bstorage = my_malloc (id,
            max_block_size * n * datum_size);
         b = (void **) my_malloc (id,
            max_block_size * datum_size);
         b[0] = bstorage;
         for (i = 1; i < max_block_size; i++) {
            b[i] = b[i-1] + n * datum_size;
         }
         for (i = 1; i < p; i++) {
            MPI_Send (&prompt, 1, MPI_INT, i, PROMPT_MSG,
               MPI_COMM_WORLD);
            MPI_Recv (bstorage, BLOCK_SIZE(i,p,m)*n, dtype,
               i, RESPONSE_MSG, MPI_COMM_WORLD, &status);
            print_submatrix (b, dtype, BLOCK_SIZE(i,p,m), n);
         }
         free (b);
         free (bstorage);
      }
      putchar ('\n');
   } else {
      MPI_Recv (&prompt, 1, MPI_INT, 0, PROMPT_MSG,
         MPI_COMM_WORLD, &status);
      MPI_Send (*a, local_rows * n, dtype, 0, RESPONSE_MSG,
         MPI_COMM_WORLD);
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %rbx
movl %ecx, %r14d
movl %edx, %ebp
movq %rsi, 0x18(%rsp)
movq %rdi, %r15
leaq 0x14(%rsp), %r12
movq %r8, %rdi
movq %r12, %rsi
callq 0x1170
leaq 0x10(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1100
movl (%r12), %ecx
leal 0x1(%rcx), %eax
imull %ebp, %eax
movl (%r13), %esi
cltd
idivl %esi
movl %eax, %ebx
movl %ecx, %eax
imull %ebp, %eax
cltd
idivl %esi
subl %eax, %ebx
testl %ecx, %ecx
je 0x3092
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x2f5d(%rip), %rdx      # 0x5fa8
movl %r14d, %r12d
movq 0x2f83(%rip), %r14      # 0x5fd8
leaq 0x24(%rsp), %rdi
movl $0x1, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
movq %r14, %r9
callq 0x1140
movq (%r15), %rdi
imull %r12d, %ebx
movl %ebx, %esi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
movl $0x2, %r8d
movq %r14, %r9
callq 0x1040
jmp 0x3219
movq %r15, %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl %ebx, %edx
movl %r14d, %ecx
callq 0x2ae4
cmpl $0x2, 0x10(%rsp)
jl 0x320f
movl %r14d, %r13d
movq %r15, %rdi
callq 0x1b80
movl %eax, %ebx
movl 0x10(%rsp), %ecx
leal -0x1(%rcx), %eax
imull %ebp, %eax
cltd
idivl %ecx
movq %rbp, %r14
subl %eax, %ebp
movl 0x14(%rsp), %edi
movl %ebx, %r15d
movl %r13d, %r12d
imull %r13d, %r15d
movl %r15d, %esi
imull %ebp, %esi
callq 0x1bf2
movq %rax, %r13
movl 0x14(%rsp), %edi
imull %ebp, %ebx
movl %ebx, %esi
callq 0x1bf2
movq %r13, %rdi
movq %r13, (%rax)
cmpl $0x2, %ebp
jl 0x3125
movslq %r15d, %r8
movl %ebp, %ecx
movq (%rax), %rdx
addq %r8, %rdx
movl $0x1, %esi
movq %rdx, (%rax,%rsi,8)
incq %rsi
addq %r8, %rdx
cmpq %rsi, %rcx
jne 0x3116
cmpl $0x2, 0x10(%rsp)
movq %r14, 0x28(%rsp)
movq %rdi, 0x38(%rsp)
movq %rax, 0x30(%rsp)
jl 0x31fb
movl %r12d, %ebp
movq 0x28(%rsp), %rax
leal (%rax,%rax), %r13d
movl $0x1, %ebx
movl %eax, %r15d
movq 0x18(%rsp), %r12
leaq 0x24(%rsp), %rdi
movl $0x1, %esi
movq 0x2e3f(%rip), %rdx      # 0x5fa8
movl %ebx, %ecx
movl $0x1, %r8d
movq 0x2e60(%rip), %r9       # 0x5fd8
callq 0x1040
leal 0x1(%rbx), %r14d
movl 0x10(%rsp), %ecx
movl %r13d, %eax
cltd
idivl %ecx
movl %eax, %esi
movl %r15d, %eax
cltd
idivl %ecx
subl %eax, %esi
imull %ebp, %esi
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
movq %r12, %rdx
movl %ebx, %ecx
movl $0x2, %r8d
movq 0x2e20(%rip), %r9       # 0x5fd8
callq 0x1140
movl 0x10(%rsp), %esi
movl %r13d, %eax
cltd
idivl %esi
movl %eax, %ecx
movl %r15d, %eax
cltd
idivl %esi
subl %eax, %ecx
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movl %ecx, %edx
movl %ebp, %ecx
callq 0x2ae4
movq 0x28(%rsp), %rax
addl %eax, %r15d
addl %eax, %r13d
movl %r14d, %ebx
cmpl 0x10(%rsp), %r14d
jl 0x3158
movq 0x30(%rsp), %rdi
callq 0x10f0
movq 0x38(%rsp), %rdi
callq 0x10f0
movl $0xa, %edi
callq 0x1090
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq