// File: /workspace/github_cpp_makefile_star2_O3/btbujiangjun[P]abcdl/src/algebra/MatrixAlgebra.cpp
// Function: abcdl::algebra::Matrix<int>::argmax(unsigned long, abcdl::algebra::Axis_type) const
size_t Matrix<T>::argmax(const size_t id, const Axis_type axis_type) const{
    bool is_row = (axis_type == abcdl::algebra::Axis_type::ROW);
	if(is_row){
        CHECK(id < _rows);
    }else{
        CHECK(id < _cols);
    }

    size_t max_idx 	= 0;
	T max 			= is_row ? get_data(id, 0) : get_data(0, id);
	size_t size 	= is_row ? _cols : _rows;
	
	for(size_t i = 0; i != size; i++){
		T value = is_row ? get_data(id, i) : get_data(i, id);
		if(value > max){
			max = value;
			max_idx = i;
		}
	}
	return max_idx;   
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdi, %r15
testl %edx, %edx
je 0x29a3f
movq 0x8(%r15), %rax
cmpq %rsi, %rax
jbe 0x29b70
imulq (%r15), %rax
movq %rsi, %rbx
cmpq %rsi, %rax
ja 0x29a60
movq %rsi, %rbx
movl %edx, %ebp
leaq 0x12a4a(%rip), %rsi     # 0x3c44d
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x44, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x12aff(%rip), %rsi     # 0x3c520
movl $0x1f, %edx
movq %r12, %rdi
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movq %rbx, %rsi
movl %ebp, %edx
jmp 0x29a60
movq (%r15), %rax
cmpq %rsi, %rax
jbe 0x29bbf
movq 0x8(%r15), %rbx
imulq %rbx, %rax
imulq %rsi, %rbx
cmpq %rax, %rbx
jae 0x29c0d
leaq 0x8(%r15), %rax
testl %edx, %edx
cmovneq %r15, %rax
movq (%rax), %r12
testq %r12, %r12
je 0x29b59
movq 0x10(%r15), %rax
movl (%rax,%rbx,4), %r13d
xorl %ebx, %ebx
leaq 0x129c6(%rip), %r8      # 0x3c44d
leaq 0x10(%rsp), %rdi
xorl %ebp, %ebp
movq 0x8(%r15), %r14
movq (%r15), %rcx
imulq %r14, %rcx
testl %edx, %edx
je 0x29adc
imulq %rbx, %r14
addq %rsi, %r14
cmpq %rcx, %r14
jb 0x29ae8
movq %rsi, 0x8(%rsp)
movl %edx, 0x4(%rsp)
movq %r8, %rsi
movl $0x44, %edx
movl $0x3, %ecx
callq 0x387b6
movl $0x1f, %edx
leaq 0x10(%rsp), %rdi
leaq 0x12a4b(%rip), %rsi     # 0x3c520
callq 0x93b0
jmp 0x29b34
imulq %rsi, %r14
addq %rbx, %r14
cmpq %rcx, %r14
jae 0x29b03
leaq (%rax,%r14,4), %rcx
movl (%rcx), %ecx
cmpl %r13d, %ecx
cmovgq %rbx, %rbp
cmovgl %ecx, %r13d
incq %rbx
cmpq %rbx, %r12
jne 0x29a8e
jmp 0x29b5b
movq %rsi, 0x8(%rsp)
movl %edx, 0x4(%rsp)
movq %r8, %rsi
movl $0x44, %edx
movl $0x3, %ecx
callq 0x387b6
movl $0x1f, %edx
leaq 0x10(%rsp), %rdi
leaq 0x129f1(%rip), %rsi     # 0x3c520
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movq 0x10(%r15), %rax
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rsi
leaq 0x128fb(%rip), %r8      # 0x3c44d
leaq 0x10(%rsp), %rdi
jmp 0x29ae8
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movl %edx, %ebx
leaq 0x13c1c(%rip), %rsi     # 0x3d798
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0xc1, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x13c35(%rip), %rsi     # 0x3d7cf
movl $0x18, %edx
movq %r12, %rdi
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movq 0x8(%r15), %rax
movl %ebx, %edx
movq %r14, %rsi
jmp 0x299eb
movq %rsi, %r14
movl %edx, %ebx
leaq 0x13bcd(%rip), %rsi     # 0x3d798
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0xbf, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x13bcd(%rip), %rsi     # 0x3d7b6
movl $0x18, %edx
movq %r12, %rdi
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movq (%r15), %rax
movl %ebx, %edx
movq %r14, %rsi
jmp 0x29a4b
movq %rsi, %r14
movl %edx, %ebp
leaq 0x12834(%rip), %rsi     # 0x3c44d
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x44, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x128e9(%rip), %rsi     # 0x3c520
movl $0x1f, %edx
movq %r12, %rdi
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movl %ebp, %edx
movq %r14, %rsi
jmp 0x29a60
jmp 0x29c62
jmp 0x29c62
jmp 0x29c62
jmp 0x29c62
jmp 0x29c62
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x389de
movq %rbx, %rdi
callq 0x95d0
nop