// File: /workspace/github_cpp_makefile_star2_O1/Konano[P]UselessDatabase/Table.cpp
// Function: Table::removeColumn(unsigned int)
int Table::removeColumn(uint col_id) {
    // if (col_ty[col_id].key == Primary) {
    //     printf("Need to remove primary key \"%s\" first.", p_key->name.c_str());
    //     return -1;
    // }
    // for (auto it: f_key) for (auto _i: it->v) if (_i == col_id) {
    //     printf("Need to remove foreign key \"%s\" first.", it->name.c_str());
    //     return -2;
    // }
    // for (uint i = 0; i < index_num; i++) for (auto _i: index[i].key) if (_i == col_id) {
    //     printf("Need to remove index \"%s\" first.", index[i].name);
    //     return -3;
    // }
    rebuild(0, col_id);
    for (uint i = col_id; i < col_num - 1; i++) col_ty[i] = col_ty[i + 1];
    col_num -= 1;

    if (p_key) {
        for (auto it = p_key->v.begin(); it != p_key->v.end(); it++) if (*it == col_id) {
            removePrimaryKey();
            break;
        } else if (*it > col_id) *it -= 1;
    }
    if (f_key.size()) for (uint i = 0; i < f_key.size(); i++) {
        for (auto it = f_key[i]->v.begin(); it != f_key[i]->v.end(); it++) if (*it == col_id) {
            removeForeignKey(f_key[i--]);
            break;
        } else if (*it > col_id) *it -= 1;
    }
    for (uint i = 0; i < index_num; i++) {
        for (auto it = index[i].key.begin(); it != index[i].key.end(); it++) if (*it == col_id) {
            removeIndex(i--);
            break;
        } else if (*it > col_id) *it -= 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
xorl %esi, %esi
movl %ebx, %edx
callq 0x234e6
movl 0x54(%r14), %eax
decl %eax
cmpl %ebx, %eax
jbe 0x23c57
movl %ebx, %r15d
imulq $0x38, %r15, %rax
leaq (%rax,%r14), %r12
addq $0xc0, %r12
movups -0x30(%r12), %xmm0
movups -0x20(%r12), %xmm1
movups -0x10(%r12), %xmm2
movups %xmm2, -0x48(%r12)
movups %xmm1, -0x58(%r12)
movups %xmm0, -0x68(%r12)
movq $0x0, -0x38(%r12)
movq (%r12), %rdi
testq %rdi, %rdi
je 0x23c45
movq (%rdi), %rax
callq *0x10(%rax)
movq %rax, -0x38(%r12)
incq %r15
movl 0x54(%r14), %eax
decl %eax
addq $0x38, %r12
cmpq %rax, %r15
jb 0x23c04
movl %eax, 0x54(%r14)
movq 0x758(%r14), %rcx
testq %rcx, %rcx
je 0x23c8e
movq 0x30(%rcx), %rax
movq 0x38(%rcx), %rcx
cmpq %rcx, %rax
je 0x23c8e
movl (%rax), %edx
cmpl %ebx, %edx
je 0x23c86
jbe 0x23c80
decl %edx
movl %edx, (%rax)
addq $0x4, %rax
jmp 0x23c6f
movq %r14, %rdi
callq 0x23d5c
movq 0x768(%r14), %rax
cmpq 0x760(%r14), %rax
je 0x23cfd
movq 0x760(%r14), %rax
cmpq %rax, 0x768(%r14)
je 0x23cfd
xorl %ecx, %ecx
xorl %ebp, %ebp
movq (%rax,%rcx,8), %rsi
movq 0x30(%rsi), %rax
movq 0x38(%rsi), %rcx
cmpq %rcx, %rax
je 0x23cd5
movl (%rax), %edx
cmpl %ebx, %edx
je 0x23cd9
jbe 0x23ccf
decl %edx
movl %edx, (%rax)
addq $0x4, %rax
jmp 0x23cbe
incl %ebp
jmp 0x23ce1
movq %r14, %rdi
callq 0x23de8
movl %ebp, %ecx
movq 0x760(%r14), %rax
movq 0x768(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
ja 0x23cb2
cmpl $0x0, 0x798(%r14)
je 0x23d51
leaq 0x7a0(%r14), %r15
xorl %ebp, %ebp
movl %ebp, %eax
imulq $0x98, %rax, %rcx
movq 0x30(%r15,%rcx), %rax
movq 0x38(%r15,%rcx), %rcx
cmpq %rcx, %rax
je 0x23d3a
movl (%rax), %edx
cmpl %ebx, %edx
je 0x23d3e
jbe 0x23d34
decl %edx
movl %edx, (%rax)
addq $0x4, %rax
jmp 0x23d23
incl %ebp
jmp 0x23d48
movq %r14, %rdi
movl %ebp, %esi
callq 0x21942
cmpl 0x798(%r14), %ebp
jb 0x23d10
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq