// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x1160
movq -0x20(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x10f0
movl -0x54(%rbp), %eax
addl $0x1, %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
subl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x54(%rbp), %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
movl %eax, %ecx
movl -0x68(%rbp), %eax
subl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x3995
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x58(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x31d0
cmpl $0x1, -0x64(%rbp)
jle 0x3989
movq -0x10(%rbp), %rdi
callq 0x1f70
movl %eax, -0x4c(%rbp)
movl -0x64(%rbp), %eax
subl $0x1, %eax
addl $0x1, %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
subl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x64(%rbp), %eax
subl $0x1, %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
movl %eax, %ecx
movl -0x6c(%rbp), %eax
subl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x54(%rbp), %edi
movl -0x5c(%rbp), %esi
imull -0x18(%rbp), %esi
imull -0x4c(%rbp), %esi
callq 0x2020
movq %rax, -0x40(%rbp)
movl -0x54(%rbp), %edi
movl -0x5c(%rbp), %esi
imull -0x4c(%rbp), %esi
callq 0x2020
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x38b0
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movl -0x18(%rbp), %eax
imull -0x4c(%rbp), %eax
cltq
addq %rax, %rdx
movq -0x48(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x3874
movl $0x1, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x3977
movl -0x50(%rbp), %ecx
leaq -0x60(%rbp), %rdi
movl $0x1, %r8d
movq 0x26d1(%rip), %rdx      # 0x5fa8
movq 0x26fa(%rip), %r9       # 0x5fd8
movl %r8d, %esi
callq 0x1040
movq -0x40(%rbp), %rdi
movl -0x50(%rbp), %eax
addl $0x1, %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
movl %eax, %esi
subl $0x1, %esi
movl -0x50(%rbp), %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
subl %eax, %esi
addl $0x1, %esi
imull -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
movl -0x50(%rbp), %ecx
movl $0x2, %r8d
movq 0x26b3(%rip), %r9       # 0x5fd8
leaq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x1130
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %eax
addl $0x1, %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
subl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x50(%rbp), %eax
imull -0x14(%rbp), %eax
cltd
idivl -0x64(%rbp)
movl -0x70(%rbp), %edx
subl %eax, %edx
addl $0x1, %edx
movl -0x18(%rbp), %ecx
callq 0x31d0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x38b7
movq -0x48(%rbp), %rdi
callq 0x10e0
movq -0x40(%rbp), %rdi
callq 0x10e0
movl $0xa, %edi
callq 0x1080
jmp 0x39e5
leaq -0x60(%rbp), %rdi
movl $0x1, %r8d
movq 0x2602(%rip), %rdx      # 0x5fa8
xorl %ecx, %ecx
movq 0x2629(%rip), %r9       # 0x5fd8
leaq -0x38(%rbp), %rax
movl %r8d, %esi
movq %rax, (%rsp)
callq 0x1130
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x58(%rbp), %esi
imull -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
movl $0x2, %r8d
movq 0x25f8(%rip), %r9       # 0x5fd8
callq 0x1040
addq $0x80, %rsp
popq %rbp
retq
nop