// File: 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:
subq $0x398, %rsp            # imm = 0x398
movq %rdi, 0x390(%rsp)
movq %rsi, 0x388(%rsp)
movl %edx, 0x384(%rsp)
movq 0x390(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x384(%rsp)
sete %al
andb $0x1, %al
movb %al, 0x383(%rsp)
testb $0x1, 0x383(%rsp)
je 0x5bcf8
movq 0x30(%rsp), %rcx
movq 0x388(%rsp), %rax
cmpq (%rcx), %rax
setb %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5bc88
jmp 0x5bcf3
leaq 0x360a9(%rip), %rsi     # 0x91d38
leaq 0x1f8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movl $0xbf, %edx
movl $0x3, %ecx
callq 0x89860
movq 0x28(%rsp), %rdi
leaq 0x3609f(%rip), %rsi     # 0x91d56
callq 0x41640
jmp 0x5bcbe
leaq 0x1f8(%rsp), %rdi
callq 0x89c20
jmp 0x5bcf3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1f0(%rsp)
movl %eax, 0x1ec(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x89c20
jmp 0x5be9f
jmp 0x5bd78
movq 0x30(%rsp), %rcx
movq 0x388(%rsp), %rax
cmpq 0x8(%rcx), %rax
setb %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5bd14
jmp 0x5bd76
leaq 0x3601d(%rip), %rsi     # 0x91d38
leaq 0x60(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0xc1, %edx
movl $0x3, %ecx
callq 0x89860
movq 0x20(%rsp), %rdi
leaq 0x3602f(%rip), %rsi     # 0x91d6f
callq 0x41640
jmp 0x5bd47
leaq 0x60(%rsp), %rdi
callq 0x89c20
jmp 0x5bd76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1f0(%rsp)
movl %eax, 0x1ec(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x89c20
jmp 0x5be9f
jmp 0x5bd78
movq $0x0, 0x58(%rsp)
testb $0x1, 0x383(%rsp)
je 0x5bda9
movq 0x30(%rsp), %rdi
movq 0x388(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x31bc0
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
jmp 0x5bdc5
movq 0x30(%rsp), %rdi
movq 0x388(%rsp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x31bc0
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x54(%rsp)
testb $0x1, 0x383(%rsp)
je 0x5bde7
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x5bdf4
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0x5be92
testb $0x1, 0x383(%rsp)
je 0x5be3c
movq 0x30(%rsp), %rdi
movq 0x388(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x31bc0
movl (%rax), %eax
movl %eax, 0xc(%rsp)
jmp 0x5be59
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x388(%rsp), %rdx
callq 0x31bc0
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x54(%rsp), %eax
jle 0x5be7d
movl 0x3c(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x58(%rsp)
jmp 0x5be7f
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x5be07
movq 0x58(%rsp), %rax
addq $0x398, %rsp            # imm = 0x398
retq
movq 0x1f0(%rsp), %rdi
callq 0x9700
nopl (%rax)