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

    if (strcmp(name, "action") == 0) {
        data->in_action = 1;
    }
    else if (strcmp(name, "block") == 0) {
        if (data->in_action) return;

        bool type_found = false;
        bool name_found = false;

        Block block;

        while (*atts) {
            if (strcmp(*atts, "type") == 0) {
                ++atts;
                block.type = *atts;
                type_found = true;
            }
            else if (strcmp(*atts, "name") == 0) {
                ++atts;
                block.name = *atts;
                name_found = true;
            }
            else if (strcmp(*atts, "template") == 0) {
                ++atts;
                block.tmpl = *atts;
            }
            else if (strcmp(*atts, "as") == 0) {
                ++atts;
                block.as = *atts;
            }
            else {
                ++atts;
            }

            ++atts;
        }

        std::cout << block.type << " " << block.name << " " << block.as << " " << block.tmpl << "\n";

        if (!name_found) {
            std::cerr << data->filename << ": No name found in block\n";
        }

        if (!type_found) {
            std::cerr << data->filename << ": No type found in block\n";
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xcba(%rip), %rsi       # 0x2004
callq 0x1160
cmpl $0x0, %eax
jne 0x1364
movq -0x20(%rbp), %rax
movl $0x1, 0x8(%rax)
jmp 0x163b
movq -0x10(%rbp), %rdi
leaq 0xc9c(%rip), %rsi       # 0x200b
callq 0x1160
cmpl $0x0, %eax
jne 0x1639
movq -0x20(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x138c
jmp 0x163b
movb $0x0, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x19f0
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x14e8
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xc55(%rip), %rsi       # 0x2011
callq 0x1160
cmpl $0x0, %eax
jne 0x1413
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x1140
jmp 0x13e7
movb $0x1, -0x21(%rbp)
jmp 0x14d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x1a40
jmp 0x1644
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbf5(%rip), %rsi       # 0x2016
callq 0x1160
cmpl $0x0, %eax
jne 0x1455
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0x88(%rbp), %rdi
callq 0x1140
jmp 0x144c
movb $0x1, -0x22(%rbp)
jmp 0x14d5
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbb8(%rip), %rsi       # 0x201b
callq 0x1160
cmpl $0x0, %eax
jne 0x148d
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0x68(%rbp), %rdi
callq 0x1140
jmp 0x148b
jmp 0x14d3
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb89(%rip), %rsi       # 0x2024
callq 0x1160
cmpl $0x0, %eax
jne 0x14c5
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0x1140
jmp 0x14c3
jmp 0x14d1
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
jmp 0x14d3
jmp 0x14d5
jmp 0x14d7
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
jmp 0x13a0
movq 0x2ae1(%rip), %rdi      # 0x3fd0
leaq -0xa8(%rbp), %rsi
callq 0x10c0
movq %rax, -0xc0(%rbp)
jmp 0x1504
movq -0xc0(%rbp), %rdi
leaq 0xb53(%rip), %rsi       # 0x2065
callq 0x10e0
movq %rax, -0xc8(%rbp)
jmp 0x1520
movq -0xc8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x10c0
movq %rax, -0xd0(%rbp)
jmp 0x153c
movq -0xd0(%rbp), %rdi
leaq 0xb1b(%rip), %rsi       # 0x2065
callq 0x10e0
movq %rax, -0xd8(%rbp)
jmp 0x1558
movq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x10c0
movq %rax, -0xe0(%rbp)
jmp 0x1571
movq -0xe0(%rbp), %rdi
leaq 0xae6(%rip), %rsi       # 0x2065
callq 0x10e0
movq %rax, -0xe8(%rbp)
jmp 0x158d
movq -0xe8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x10c0
movq %rax, -0xf0(%rbp)
jmp 0x15a6
movq -0xf0(%rbp), %rdi
leaq 0xa8b(%rip), %rsi       # 0x203f
callq 0x10e0
jmp 0x15bb
testb $0x1, -0x22(%rbp)
jne 0x15f4
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq 0x2a21(%rip), %rdi      # 0x3ff0
callq 0x10e0
movq %rax, -0xf8(%rbp)
jmp 0x15dd
movq -0xf8(%rbp), %rdi
leaq 0xa3c(%rip), %rsi       # 0x2027
callq 0x10e0
jmp 0x15f2
jmp 0x15f4
testb $0x1, -0x21(%rbp)
jne 0x162d
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq 0x29e8(%rip), %rdi      # 0x3ff0
callq 0x10e0
movq %rax, -0x100(%rbp)
jmp 0x1616
movq -0x100(%rbp), %rdi
leaq 0xa1d(%rip), %rsi       # 0x2041
callq 0x10e0
jmp 0x162b
jmp 0x162d
leaq -0xa8(%rbp), %rdi
callq 0x1a40
jmp 0x163b
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0xb0(%rbp), %rdi
callq 0x11a0