// File: /workspace/github_cpp_makefile_star2_O3/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 0x22f36
movl 0x54(%r14), %eax
leal -0x1(%rax), %ecx
cmpl %ebx, %ecx
jbe 0x236bb
movl %ebx, %r15d
imulq $0x38, %r15, %rcx
leaq (%rcx,%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 0x236ac
movq (%rdi), %rax
callq *0x10(%rax)
movq %rax, -0x38(%r12)
movl 0x54(%r14), %eax
incq %r15
leal -0x1(%rax), %ecx
addq $0x38, %r12
cmpq %rcx, %r15
jb 0x23667
movl %ecx, 0x54(%r14)
movq 0x758(%r14), %rcx
testq %rcx, %rcx
je 0x236f2
movq 0x30(%rcx), %rax
movq 0x38(%rcx), %rcx
cmpq %rcx, %rax
je 0x236f2
movl (%rax), %edx
cmpl %ebx, %edx
je 0x236ea
jbe 0x236e4
decl %edx
movl %edx, (%rax)
addq $0x4, %rax
jmp 0x236d3
movq %r14, %rdi
callq 0x237ba
movq 0x760(%r14), %rax
movq 0x768(%r14), %rcx
cmpq %rax, %rcx
je 0x2375b
xorl %edx, %edx
xorl %ebp, %ebp
movq (%rax,%rdx,8), %rsi
movq 0x30(%rsi), %rdx
movq 0x38(%rsi), %rdi
cmpq %rdi, %rdx
je 0x23730
movl (%rdx), %r8d
cmpl %ebx, %r8d
je 0x23734
jbe 0x2372a
decl %r8d
movl %r8d, (%rdx)
addq $0x4, %rdx
jmp 0x23715
incl %ebp
jmp 0x2374a
movq %r14, %rdi
callq 0x23846
movq 0x760(%r14), %rax
movq 0x768(%r14), %rcx
movl %ebp, %edx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
cmpq %rdx, %rsi
ja 0x23709
cmpl $0x0, 0x798(%r14)
je 0x237af
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 0x23798
movl (%rax), %edx
cmpl %ebx, %edx
je 0x2379c
jbe 0x23792
decl %edx
movl %edx, (%rax)
addq $0x4, %rax
jmp 0x23781
incl %ebp
jmp 0x237a6
movq %r14, %rdi
movl %ebp, %esi
callq 0x2139c
cmpl 0x798(%r14), %ebp
jb 0x2376e
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq