// File: /workspace/github_c_makefile_star2_O0/aligusnet[P]morpheus/src/matrix_reduce.c
// Function: morpheus_column_max_index
void morpheus_column_max_index(morpheus_layout_e layout,
                               int nrows, int ncols,
                               const double *x,
                               double *y,
                               int *is) {
  if (layout == morpheus_row_major) {
    for (int j = 0; j < ncols; ++j) {
      is[j] = 0;
      y[j] = x[j];
    }
    for (int i = 1; i < nrows; ++i) {
      const double *row = x + i*ncols;
      for (int j = 0; j < ncols; ++j) {
        if (y[j] < row[j]) {
          y[j] = row[j];
          is[j] = i;
        }
      }
    }
  } else if (layout == morpheus_col_major) {
    for (int j = 0; j < ncols; ++j) {
      const double *column = &x[j*nrows];
      y[j] = column[0];
      is[j] = 0;
      for (int i = 1; i < nrows; ++i) {
        if (y[j] < column[i]) {
          y[j] = column[i];
          is[j] = i;
        }
      }
    }
  } else {
    perror("unkwnown matrix layout");
    assert(0);
  }
}

// Assembly:
subq $0x58, %rsp
movl %edi, 0x54(%rsp)
movl %esi, 0x50(%rsp)
movl %edx, 0x4c(%rsp)
movq %rcx, 0x40(%rsp)
movq %r8, 0x38(%rsp)
movq %r9, 0x30(%rsp)
cmpl $0x15, 0x54(%rsp)
jne 0x2ee6
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x2e28
movq 0x30(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movq 0x40(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x2de2
movl $0x1, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x50(%rsp), %eax
jge 0x2ee1
movq 0x40(%rsp), %rax
movl 0x28(%rsp), %ecx
imull 0x4c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x2ecf
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2ec0
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x28(%rsp), %edx
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2ec2
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x2e63
jmp 0x2ed1
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x2e30
jmp 0x3002
cmpl $0x16, 0x54(%rsp)
jne 0x2fd5
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x2fd3
movq 0x40(%rsp), %rax
movl 0x18(%rsp), %ecx
imull 0x50(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movq 0x38(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl $0x1, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x50(%rsp), %eax
jge 0x2fc1
movq 0x38(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2fb2
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0xc(%rsp), %edx
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2fb4
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x2f55
jmp 0x2fc3
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x2ef9
jmp 0x3000
leaq 0x22cc(%rip), %rdi      # 0x52a8
callq 0x1110
leaq 0x22d7(%rip), %rdi      # 0x52bf
leaq 0x22d2(%rip), %rsi      # 0x52c1
movl $0x61, %edx
leaq 0x23bb(%rip), %rcx      # 0x53b6
callq 0x1070
jmp 0x3002
addq $0x58, %rsp
retq
nopw (%rax,%rax)