// File: pstuifzand[P]magento-tools/src/magento-modules.cpp
// Function: root_end_element_handler(void*, char const*)
void root_end_element_handler(void* udata, const XML_Char* name) {
    user_data* data = (user_data*)udata;

    switch (data->state) {
        case State::ROOT:
            break;
        case State::IN_CONFIG:
            if (strcmp(name, "config") == 0) data->state = State::ROOT;
            data->state = State::ROOT;
            break;
        case State::IN_MODULES:
            if (strcmp(name, "modules") == 0) data->state = State::IN_CONFIG;
            break;
        case State::IN_MODULE:
            // output module info
            std::cout << std::setw(30) << std::left << data->current_name;
            std::cout << std::setw(6) << std::left << (data->active ? "true" : "false");
            std::cout << std::setw(10) << std::left << data->codepool;
            std::cout << data->filename << "\n";
            data->state = State::IN_MODULES;
            break;
        case State::IN_ACTIVE:
            if (strcmp(name, "active") == 0) data->state = State::IN_MODULE;
            data->active = strcmp("true", data->current_text.c_str()) == 0;
            data->current_text.clear();
            break;
        case State::IN_CODEPOOL:
            if (strcmp(name, "codePool") == 0) data->state = State::IN_MODULE;
            data->codepool = data->current_text;
            data->current_text.clear();
            break;
        case State::IN_DEPENDS:
            if (strcmp(name, "depends") == 0) data->state = State::IN_MODULE;
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x6, %eax
ja 0x288f
movq -0x30(%rbp), %rax
leaq 0x199a(%rip), %rcx      # 0x4014
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x288f
movq -0x10(%rbp), %rdi
leaq 0x19e8(%rip), %rsi      # 0x407b
callq 0x22b0
cmpl $0x0, %eax
jne 0x26a7
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0x288f
movq -0x10(%rbp), %rdi
leaq 0x19ee(%rip), %rsi      # 0x40af
callq 0x22b0
cmpl $0x0, %eax
jne 0x26d5
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
jmp 0x288f
movl $0x1e, %edi
callq 0x2a30
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
movq 0x38df(%rip), %rdi      # 0x5fd0
callq 0x2220
movq %rax, %rdi
leaq 0x350(%rip), %rsi       # 0x2a50
callq 0x20a0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
callq 0x2180
movl $0x6, %edi
callq 0x2a30
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %esi
movq 0x38a4(%rip), %rdi      # 0x5fd0
callq 0x2220
movq %rax, %rdi
leaq 0x315(%rip), %rsi       # 0x2a50
callq 0x20a0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movb 0x50(%rax), %cl
leaq 0x194e(%rip), %rsi      # 0x409f
leaq 0x1942(%rip), %rax      # 0x409a
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x21c0
movl $0xa, %edi
callq 0x2a30
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
movq 0x3855(%rip), %rdi      # 0x5fd0
callq 0x2220
movq %rax, %rdi
leaq 0x2c6(%rip), %rsi       # 0x2a50
callq 0x20a0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
addq $0x58, %rsi
callq 0x2180
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x3822(%rip), %rdi      # 0x5fd0
callq 0x21c0
movq %rax, %rdi
leaq 0x18e8(%rip), %rsi      # 0x40a5
callq 0x21c0
movq -0x18(%rbp), %rax
movl $0x3, (%rax)
jmp 0x288f
movq -0x10(%rbp), %rdi
leaq 0x18a6(%rip), %rsi      # 0x4082
callq 0x22b0
cmpl $0x0, %eax
jne 0x27f0
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x20c0
movq %rax, %rsi
leaq 0x1893(%rip), %rdi      # 0x409a
callq 0x22b0
cmpl $0x0, %eax
sete %cl
movq -0x18(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x50(%rax)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x2270
jmp 0x288f
movq -0x10(%rbp), %rdi
leaq 0x1853(%rip), %rsi      # 0x4089
callq 0x22b0
cmpl $0x0, %eax
jne 0x284a
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
callq 0x2030
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x2270
jmp 0x288f
movq -0x10(%rbp), %rdi
leaq 0x1819(%rip), %rsi      # 0x4092
callq 0x22b0
cmpl $0x0, %eax
jne 0x288d
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
jmp 0x288f
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)