// File: pstuifzand[P]magento-tools/src/position.cpp
// Function: main
int main(int argc, char** argv)
{
    // remove program name
    argc--;
    argv++;

    // no arguments
    if (!argc) return 0;

    int line = 0;
    int col  = 0;

    if (argc >= 2) {
        line = std::stoi(argv[0]);
        col = std::stoi(argv[1]);
        argc -= 2;
        argv += 2;
    }

    // create parser
    xml_parser parser;

    while (argc) {
        user_data data;
        data.filename = *argv;
        data.parser = &parser;
        data.line = line;
        data.col = col;
        data.state = State::NOT_FOUND;

        XML_SetUserData(parser.handle(), &data);
        XML_SetElementHandler(parser.handle(), root_start_element_handler, root_end_element_handler);
        XML_SetCharacterDataHandler(parser.handle(), character_data_handler);

        std::ifstream in{data.filename};
        if (in) parse_xml(parser, in, &data);
        parser.reset();

        argc--;
        argv++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x28f0
movl $0x0, -0x4(%rbp)
jmp 0x2c0c
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x2, -0x8(%rbp)
jl 0x2a5a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x2d0(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x2320
movq -0x2d0(%rbp), %rsi
movq -0x2c8(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x2d80
jmp 0x293f
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
movl $0xa, %edx
callq 0x2f80
movl %eax, -0x2d4(%rbp)
jmp 0x2959
movl -0x2d4(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2110
leaq -0x39(%rbp), %rdi
callq 0x2220
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x2320
movq -0x2e8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x2d80
jmp 0x29ac
xorl %eax, %eax
movl %eax, %esi
leaq -0x70(%rbp), %rdi
movl $0xa, %edx
callq 0x2f80
movl %eax, -0x2ec(%rbp)
jmp 0x29c6
movl -0x2ec(%rbp), %eax
movl %eax, -0x18(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2110
leaq -0x71(%rbp), %rdi
callq 0x2220
movl -0x8(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rbp)
jmp 0x2a5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2a1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2110
leaq -0x39(%rbp), %rdi
callq 0x2220
jmp 0x2c18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2a4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2110
leaq -0x71(%rbp), %rdi
callq 0x2220
jmp 0x2c18
leaq -0x80(%rbp), %rdi
callq 0x2fc0
cmpl $0x0, -0x8(%rbp)
je 0x2c03
leaq -0xb8(%rbp), %rdi
callq 0x2ff0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x98(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl $0x0, -0x88(%rbp)
callq 0x2e30
movq %rax, -0x2f8(%rbp)
jmp 0x2abc
movq -0x2f8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2050
jmp 0x2ad1
leaq -0x80(%rbp), %rdi
callq 0x2e30
movq %rax, -0x300(%rbp)
jmp 0x2ae3
movq -0x300(%rbp), %rdi
leaq -0x541(%rip), %rsi      # 0x25b0
leaq -0x3e8(%rip), %rdx      # 0x2710
callq 0x21b0
jmp 0x2aff
leaq -0x80(%rbp), %rdi
callq 0x2e30
movq %rax, -0x308(%rbp)
jmp 0x2b11
movq -0x308(%rbp), %rdi
leaq -0x33f(%rip), %rsi      # 0x27e0
callq 0x2260
jmp 0x2b26
movq -0xb8(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
movl $0x8, %edx
callq 0x2350
jmp 0x2b40
movq -0x2c0(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2c0(%rbp,%rax), %rdi
callq 0x2280
movb %al, -0x309(%rbp)
jmp 0x2b60
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x2b6c
jmp 0x2baf
leaq -0x80(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x3010
jmp 0x2b85
jmp 0x2baf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x2080
jmp 0x2bec
leaq -0x80(%rbp), %rdi
callq 0x3190
jmp 0x2bba
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x2080
leaq -0xb8(%rbp), %rdi
callq 0x31c0
jmp 0x2a63
leaq -0xb8(%rbp), %rdi
callq 0x31c0
leaq -0x80(%rbp), %rdi
callq 0x31e0
jmp 0x2c18
leaq -0x80(%rbp), %rdi
callq 0x31e0
movl -0x4(%rbp), %eax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)