// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %r8, %rbx
movl %ecx, %r14d
movl %edx, %ebp
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
leaq 0xc(%rsp), %r12
movq %r8, %rdi
movq %r12, %rsi
callq 0x1170
leaq 0x8(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1100
movl (%r12), %ecx
movq %rbp, %r12
leal 0x1(%rcx), %eax
imull %r12d, %eax
movl (%r13), %esi
cltd
idivl %esi
movl %eax, %ebx
movl %ecx, %eax
imull %r12d, %eax
cltd
idivl %esi
subl %eax, %ebx
testl %ecx, %ecx
je 0x2f5e
leaq 0x30(%rsp), %rax
movq %rax, (%rsp)
movq 0x308a(%rip), %rdx      # 0x5fa8
movl %r14d, %r12d
movq 0x30b0(%rip), %r14      # 0x5fd8
leaq 0x24(%rsp), %rdi
pushq $0x1
popq %rsi
xorl %ecx, %ecx
movl %esi, %r8d
movq %r14, %r9
callq 0x1140
movq (%r15), %rdi
imull %r12d, %ebx
pushq $0x2
popq %r8
movl %ebx, %esi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
movq %r14, %r9
callq 0x1040
jmp 0x30cd
movq %r15, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
movl %ebx, %edx
movl %r14d, %ecx
callq 0x29ea
cmpl $0x2, 0x8(%rsp)
jl 0x30c5
movq %r15, %rdi
callq 0x1b5c
movl %eax, %ebx
movl 0x8(%rsp), %ecx
leal -0x1(%rcx), %eax
imull %r12d, %eax
cltd
idivl %ecx
movl %r12d, %ebp
subl %eax, %ebp
movl 0xc(%rsp), %edi
movl %ebx, %r15d
imull %r14d, %r15d
movl %r15d, %esi
imull %ebp, %esi
callq 0x1bc5
movq %rax, %r13
movl 0xc(%rsp), %edi
imull %ebp, %ebx
movl %ebx, %esi
callq 0x1bc5
movq %r13, 0x28(%rsp)
movq %rax, 0x18(%rsp)
movq %r13, (%rax)
movslq %r15d, %rax
movslq %ebp, %rcx
pushq $0x1
popq %rdx
movq 0x18(%rsp), %rdi
cmpq %rcx, %rdx
jge 0x2ff3
movq -0x8(%rdi,%rdx,8), %rsi
addq %rax, %rsi
movq %rsi, (%rdi,%rdx,8)
incq %rdx
jmp 0x2fdd
leal (%r12,%r12), %r13d
pushq $0x1
popq %rax
movl %r12d, %r15d
movl %eax, %ebx
cmpl 0x8(%rsp), %eax
jge 0x30b1
leaq 0x24(%rsp), %rdi
pushq $0x1
popq %rsi
movq 0x2f90(%rip), %rdx      # 0x5fa8
movl %ebx, %ecx
movl %esi, %r8d
movq 0x2fb4(%rip), %r9       # 0x5fd8
callq 0x1040
leal 0x1(%rbx), %eax
movl %eax, 0x20(%rsp)
movl 0x8(%rsp), %ecx
movl %r13d, %eax
cltd
idivl %ecx
movl %eax, %esi
movl %r15d, %eax
cltd
idivl %ecx
subl %eax, %esi
imull %r14d, %esi
leaq 0x30(%rsp), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rbp
movl %r14d, %r12d
movq 0x10(%rsp), %r14
movq %r14, %rdx
movl %ebx, %ecx
pushq $0x2
popq %r8
movq 0x2f67(%rip), %r9       # 0x5fd8
callq 0x1140
movl 0x8(%rsp), %esi
movl %r13d, %eax
cltd
idivl %esi
movl %eax, %ecx
movl %r15d, %eax
cltd
idivl %esi
subl %eax, %ecx
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movl %r12d, %r14d
movq %rbp, %r12
movl %ecx, %edx
movl %r14d, %ecx
callq 0x29ea
addl %r12d, %r13d
addl %r12d, %r15d
movl 0x20(%rsp), %eax
jmp 0x2ffd
movq 0x18(%rsp), %rdi
callq 0x10f0
movq 0x28(%rsp), %rdi
callq 0x10f0
pushq $0xa
popq %rdi
callq 0x1090
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq