// File: /workspace/github_c_makefile_star2_O0/aligusnet[P]morpheus/src/matrix_reduce.c
// Function: morpheus_row_max_index
void morpheus_row_max_index(morpheus_layout_e layout,
                            int nrows, int ncols,
                            const double *x,
                            double *y,
                            int *is) {
  if (layout == morpheus_row_major) {
    for (int i = 0; i < nrows; ++i) {
      const double *row = x + i*ncols;
      y[i] = row[0];
      is[i] = 0;
      for (int j = 1; j < ncols; ++j) {
        if (y[i] < row[j]) {
          y[i] = row[j];
          is[i] = j;
        }
      }
    }
  } else if (layout == morpheus_col_major) {
    for (int i = 0; i < nrows; ++i) {
      is[i] = 0;
      y[i] = x[i];
    }
    for (int j = 1; j < ncols; ++j) {
      const double *column = x + j*nrows;
      for (int i = 0; i < nrows; ++i) {
        if (y[i] < column[i]) {
          y[i] = column[i];
          is[i] = j;
        }
      }
    }
  } 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 0x3371
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x50(%rsp), %eax
jge 0x336c
movq 0x40(%rsp), %rax
movl 0x2c(%rsp), %ecx
imull 0x4c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl $0x1, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x335a
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x334b
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x1c(%rsp), %edx
movq 0x30(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x334d
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x32ee
jmp 0x335c
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x3292
jmp 0x34b2
cmpl $0x16, 0x54(%rsp)
jne 0x3485
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x50(%rsp), %eax
jge 0x33ca
movq 0x30(%rsp), %rax
movslq 0x18(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movq 0x40(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rax
movslq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x3384
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x3483
movq 0x40(%rsp), %rax
movl 0x14(%rsp), %ecx
imull 0x50(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
cmpl 0x50(%rsp), %eax
jge 0x3471
movq 0x38(%rsp), %rax
movslq 0x4(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x8(%rsp), %rax
movslq 0x4(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3462
movq 0x8(%rsp), %rax
movslq 0x4(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rax
movslq 0x4(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x14(%rsp), %edx
movq 0x30(%rsp), %rax
movslq 0x4(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3464
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x3405
jmp 0x3473
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x33d2
jmp 0x34b0
leaq 0x1e1c(%rip), %rdi      # 0x52a8
callq 0x1110
leaq 0x1e27(%rip), %rdi      # 0x52bf
leaq 0x1e22(%rip), %rsi      # 0x52c1
movl $0xac, %edx
leaq 0x1fc5(%rip), %rcx      # 0x5470
callq 0x1070
jmp 0x34b2
addq $0x58, %rsp
retq
nopw (%rax,%rax)