// File: mororo18[P]simplex-method/src/model.cpp
// Function: Model::b_range_calc(std::vector<std::pair<double, double>, std::allocator<std::pair<double, double>>>&)
void Model::b_range_calc(std::vector<std::pair<double, double>> & b_range){
    b_opt_store();    
    
    if(!b_range.empty())
        b_range.clear();

    //std::cout << "inve size " << inverse_matrix.size() << std::endl;
    for(int col = 0; col < inverse_matrix[0].size(); col++){
        double upper_bound = INFINITE; 
        double lower_bound = -INFINITE;


        //if(col == 6)
            //vec_print_dbl(b_opt);
        for(int row = 0; row < inverse_matrix.size(); row++){
            double coef =  inverse_matrix[row][col];
            double coef_inv = 1.0f / coef;
            double value = -1.0 * b_opt[row];

            value = value * coef_inv;

            if(coef_inv < 0 && value < upper_bound){
                upper_bound = value; 

            }else if(value > lower_bound){
                lower_bound = value;
            }

        }

        std::pair<double, double> range;
        range.first = lower_bound;
        range.second = upper_bound;

        b_range.push_back(range);

        //std::cout << "cstr n" << col << "  de " << lower_bound << " a " << upper_bound << std::endl;
    }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x70(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x9a20
movq 0x68(%rsp), %rdi
callq 0x110b0
testb $0x1, %al
jne 0x9b35
movq 0x68(%rsp), %rdi
callq 0x107c0
movl $0x0, 0x64(%rsp)
movq 0x18(%rsp), %rdi
movslq 0x64(%rsp), %rax
movq %rax, 0x10(%rsp)
addq $0x1a8, %rdi            # imm = 0x1A8
xorl %eax, %eax
movl %eax, %esi
callq 0x10780
movq %rax, %rdi
callq 0x6420
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x9cda
movsd 0x11733(%rip), %xmm0    # 0x1b2b0
movsd %xmm0, 0x58(%rsp)
movsd 0x1171d(%rip), %xmm0    # 0x1b2a8
movsd %xmm0, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movq 0x18(%rsp), %rdi
movslq 0x4c(%rsp), %rax
movq %rax, 0x8(%rsp)
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x10760
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x9c99
movq 0x18(%rsp), %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
movslq 0x4c(%rsp), %rsi
callq 0x10780
movq %rax, %rdi
movslq 0x64(%rsp), %rsi
callq 0x109f0
movq 0x18(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x11451(%rip), %xmm0    # 0x1b050
divsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0x118, %rdi            # imm = 0x118
movslq 0x4c(%rsp), %rsi
callq 0x109f0
movsd 0x1167c(%rip), %xmm0    # 0x1b2a0
mulsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x38(%rsp), %xmm0
jbe 0x9c6b
movsd 0x30(%rsp), %xmm1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9c6b
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
jmp 0x9c87
movsd 0x30(%rsp), %xmm0
ucomisd 0x50(%rsp), %xmm0
jbe 0x9c85
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0x9c87
jmp 0x9c89
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x9b99
leaq 0x20(%rsp), %rdi
callq 0x11100
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x68(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x11120
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x9b3d
addq $0x78, %rsp
retq
nop