// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %rdi, %r14
leaq 0x88(%rdi), %rbx
movq 0x88(%rdi), %rax
movq 0x8(%rax), %rbp
subq (%rax), %rbp
addq $0x30, %rsi
leaq 0x10(%rsp), %rdi
callq 0x4b20
movq 0x88(%r14), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
movq %r15, 0x28(%rsp)
cmpl $-0x1, 0x20(%r15)
movslq (%r14), %r15
movq %rbx, 0x30(%rsp)
je 0x9423
cmpq %r15, %rax
jbe 0x93f4
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x93d3
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x93de
movq %r12, %rdi
movq %r13, %rdx
callq 0xe26c
incq %r15
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x93ac
movq 0x28(%rsp), %rax
leaq 0x28(%rax), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x94aa
movsd (%rdx), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x94b4
cmpq %r15, %rax
jbe 0x947a
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9459
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x9464
movq %r12, %rdi
movq %r13, %rdx
callq 0xe26c
incq %r15
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x9432
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9536
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x9545
leaq 0x10(%rsp), %rdi
callq 0xe388
movq 0x88(%r14), %rdi
cmpq %rdi, 0x90(%r14)
je 0x9651
shlq $0x1d, %rbp
movabsq $-0x100000000, %r15     # imm = 0xFFFFFFFF00000000
addq %rbp, %r15
sarq $0x1d, %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
xorl %ebx, %ebx
movq (%rdi,%r13), %rsi
addq %r15, %rsi
addq %r13, %rdi
movq $0x0, 0x8(%rsp)
movq %r12, %rdx
callq 0xe8ae
incq %rbx
movq 0x88(%r14), %rdi
movq 0x90(%r14), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %rbp, %rax
addq $0x18, %r13
cmpq %rbx, %rax
ja 0x94f1
jmp 0x9651
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xe26c
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x956c
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x957b
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xe26c
movq 0x28(%rsp), %rax
leaq 0x28(%rax), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x95a3
movsd (%rdx), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x95ad
leaq 0x10(%rsp), %rdi
callq 0xe388
movq 0x88(%r14), %rdi
cmpq %rdi, 0x90(%r14)
je 0x9651
shlq $0x1d, %rbp
movabsq $-0x100000000, %r15     # imm = 0xFFFFFFFF00000000
addq %rbp, %r15
sarq $0x20, %r15
xorl %r13d, %r13d
shlq $0x3, %r15
leaq 0x8(%rsp), %r12
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
xorl %ebp, %ebp
movq (%rdi,%r13), %rsi
addq %r15, %rsi
addq %r13, %rdi
movq $0x0, 0x8(%rsp)
movq %r12, %rdx
callq 0xe8ae
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq (%rdi,%r13), %rsi
addq %r15, %rsi
addq %r13, %rdi
movq $0x0, 0x8(%rsp)
movq %r12, %rdx
callq 0xe8ae
incq %rbp
movq 0x88(%r14), %rdi
movq 0x90(%r14), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %rbx, %rax
addq $0x18, %r13
cmpq %rbp, %rax
ja 0x95ee
movq 0x88(%r14), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x3, %rax
addl $-0x2, %eax
movl %eax, 0x8(%rsp)
movq 0x198(%r14), %rsi
cmpq 0x1a0(%r14), %rsi
je 0x968e
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x198(%r14)
movq 0x30(%rsp), %rdi
jmp 0x96a4
leaq 0x190(%r14), %rdi
leaq 0x8(%rsp), %rdx
callq 0xe460
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rax
movl 0x20(%rax), %eax
incl %eax
cmpl $0x1, %eax
ja 0x96f8
movq (%rdi), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
je 0x96f8
sarq $0x3, %rcx
movq 0x10(%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movsd 0x6bfb(%rip), %xmm0     # 0x102d8
movsd (%rdx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%rax,%rsi,8), %xmm1
movsd %xmm1, (%rax,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x96dd
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
movq %rdx, %rcx
subq %rax, %rcx
movq %rcx, %rsi
shlq $0x1d, %rsi
movabsq $-0x200000000, %r8      # imm = 0xFFFFFFFE00000000
addq %rsi, %r8
sarq $0x1d, %r8
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq %rsi, (%rax,%r8)
movq (%rdi), %rsi
movq (%rsi), %r8
movq 0x8(%rsi), %r9
subq %r8, %r9
sarq $0x3, %r9
decq %r9
je 0x980d
sarq $0x3, %rcx
xorl %ebx, %ebx
xorpd %xmm1, %xmm1
movsd (%r8,%rbx,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x976d
jp 0x976d
movsd (%rax,%rbx,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x977a
jp 0x977a
incq %rbx
cmpq %rbx, %r9
jne 0x9752
jmp 0x980d
movq 0x90(%r14), %r8
subq %rsi, %r8
je 0x97d0
sarq $0x3, %r8
movabsq $-0x5555555555555555, %r9 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r8, %r9
cmpq $0x1, %r9
adcq $0x0, %r9
xorl %r8d, %r8d
movsd 0x68a5(%rip), %xmm1     # 0x10050
movq %rsi, %r10
movq (%r10), %r11
movsd (%r11,%rbx,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x97bf
jnp 0x97d3
incq %r8
addq $0x18, %r10
cmpq %r8, %r9
jne 0x97ae
movq %r9, %r8
jmp 0x97d3
xorl %r8d, %r8d
cmpq %rax, %rdx
je 0x980d
xorpd 0x6ad0(%rip), %xmm0     # 0x102b0
leaq (%r8,%r8,2), %rdx
movq (%rsi,%rdx,8), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%rax,%rsi,8), %xmm1
movsd %xmm1, (%rax,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x97f2
leaq 0x10(%rsp), %rsi
callq 0xd4a6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9826
callq 0x21c0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9847
jmp 0x9847
jmp 0x9847
jmp 0x9847
jmp 0x9847
jmp 0x9847
jmp 0x9847
jmp 0x9847
jmp 0x9847
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9859
callq 0x21c0
movq %rbx, %rdi
callq 0x2310
nop