// File: /workspace/github_cpp_makefile_star2_O2/mororo18[P]simplex-method/src/model.cpp
// Function: Model::tableau_resize(Model::cstr)
void Model::tableau_resize(Model::cstr cstr_new){

    int row_size = tableau[0].size();
    // add new row
    //std::vector<double> row_new = row_vec;
    std::vector<double> row_new = cstr_new.coef_get();

    //if(id == G_EQ){
    if(cstr_new.type_id == G_EQ){
        for(int row = var_qnt; row < tableau[0].size(); row++)
            row_new.push_back(0); 
        row_new.push_back(-1); 
        row_new.push_back(0); 

        //row_new.push_back(value);
        row_new.push_back(cstr_new.value);

        int col_i = row_size - 1;

        for(int row = 0; row < tableau.size(); row++){
            tableau[row].insert(tableau[row].begin() + col_i, 0);
            tableau[row].insert(tableau[row].begin() + col_i, 0);
        }

    }else { 
        for(int row = var_qnt; row < tableau[0].size(); row++)
            row_new.push_back(0); 

        //row_new.push_back(value);
        row_new.push_back(cstr_new.value);

        int col_i = row_size - 1;

        for(int row = 0; row < tableau.size(); row++)
            tableau[row].insert(tableau[row].begin() + col_i, 0);
    }

    // update I_index vec
    I_index.push_back(tableau[0].size() - 2);

    //if(id == G_EQ || id == EQ)
    if(cstr_new.type_id == G_EQ || cstr_new.type_id == EQ)
        vec_add_vec(tableau[0], row_new, -BIG_M);

    int col_i = row_new.size() - 2;
    row_new[col_i] = 1;

    //clean columns of basic vars
    for(int col = 0; col < tableau[0].size() - 1; col++){

        if(tableau[0][col] == 0 && row_new[col] != 0){
            int row_i;
            for(int row = 0; row < tableau.size(); row++){
                if(tableau[row][col] == 1){
                    row_i = row;
                    break;
                }
            }

            double coef = row_new[col];

            vec_add_vec(row_new, tableau[row_i], -coef);

            break;
        }
    }

    tableau.push_back(row_new);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbp
movq %rdi, %r14
leaq 0x88(%rdi), %rbx
movq 0x88(%rdi), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, 0x28(%rsp)
addq $0x30, %rsi
leaq 0x10(%rsp), %rdi
callq 0x3fd8
cmpl $-0x1, 0x20(%rbp)
movslq (%r14), %r15
movq %rbp, 0x30(%rsp)
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
je 0x6def
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0x6ec5
andq $0x0, 0x8(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xa03e
incq %r15
jmp 0x6dae
andq $0x0, 0x8(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xa03e
incq %r15
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x6ddb
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xa03e
leaq 0x8(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xa03e
leaq 0x28(%rbp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x9296
movq 0x28(%rsp), %rax
shlq $0x1d, %rax
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
addq %rax, %r13
sarq $0x20, %r13
xorl %r15d, %r15d
shlq $0x3, %r13
leaq 0x8(%rsp), %r12
xorl %ebp, %ebp
movq 0x88(%r14), %rdi
movq 0x90(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rbp, %rax
jbe 0x6f36
movq (%rdi,%r15), %rsi
addq %r13, %rsi
addq %r15, %rdi
andq $0x0, 0x8(%rsp)
movq %r12, %rdx
callq 0xa806
movq (%rbx), %rdi
movq (%rdi,%r15), %rsi
addq %r13, %rsi
addq %r15, %rdi
andq $0x0, 0x8(%rsp)
movq %r12, %rdx
callq 0xa806
incq %rbp
addq $0x18, %r15
jmp 0x6e67
leaq 0x28(%rbp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x9296
movq 0x28(%rsp), %rax
shlq $0x1d, %rax
movabsq $-0x100000000, %r15     # imm = 0xFFFFFFFF00000000
addq %rax, %r15
sarq $0x1d, %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
xorl %ebp, %ebp
movq 0x88(%r14), %rdi
movq 0x90(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rbp, %rax
jbe 0x6f36
movq (%rdi,%r13), %rsi
addq %r15, %rsi
addq %r13, %rdi
andq $0x0, 0x8(%rsp)
movq %r12, %rdx
callq 0xa806
incq %rbp
addq $0x18, %r13
jmp 0x6ef7
leaq 0x190(%r14), %rax
movq 0x8(%rdi), %rcx
subq (%rdi), %rcx
shrq $0x3, %rcx
addl $-0x2, %ecx
leaq 0x8(%rsp), %rsi
movl %ecx, (%rsi)
movq %rax, %rdi
callq 0xa230
movq 0x30(%rsp), %rax
movl 0x20(%rax), %eax
incl %eax
cmpl $0x1, %eax
ja 0x6f7e
movq (%rbx), %rsi
leaq 0x10(%rsp), %rdx
movsd 0x5347(%rip), %xmm0     # 0xc2c0
callq 0x4c2c
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shlq $0x1d, %rcx
movabsq $-0x200000000, %rdx     # imm = 0xFFFFFFFE00000000
addq %rcx, %rdx
sarq $0x1d, %rdx
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax,%rdx)
movq (%rbx), %rcx
movq (%rcx), %rdx
movq 0x8(%rcx), %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
decq %rdi
xorl %esi, %esi
xorpd %xmm1, %xmm1
cmpq %rsi, %rdi
je 0x7059
movsd (%rdx,%rsi,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x6feb
jp 0x6feb
movsd (%rax,%rsi,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x6ff0
jp 0x6ff0
incq %rsi
jmp 0x6fc8
movq 0x90(%r14), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rdi
idivq %rdi
movq %rax, %rdi
negq %rdi
pushq $-0x1
popq %rdx
movsd 0x503d(%rip), %xmm1     # 0xc050
movq %rcx, %r8
leaq (%rdi,%rdx), %r9
cmpq $-0x1, %r9
je 0x703a
movq (%r8), %r9
movsd (%r9,%rsi,8), %xmm2
incq %rdx
addq $0x18, %r8
ucomisd %xmm1, %xmm2
jne 0x7016
jp 0x7016
jmp 0x703d
movq %rax, %rdx
imulq $0x18, %rdx, %rax
addq %rax, %rcx
xorpd 0x5244(%rip), %xmm0     # 0xc290
leaq 0x10(%rsp), %rsi
movq %rcx, %rdx
callq 0x4c2c
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x926a
leaq 0x10(%rsp), %rdi
callq 0x415a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7091
jmp 0x7091
jmp 0x7091
jmp 0x7091
jmp 0x7091
jmp 0x7091
jmp 0x7091
jmp 0x7091
jmp 0x7091
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x415a
movq %rbx, %rdi
callq 0x22c0