// File: /workspace/github_cpp_makefile_star2_O3/instance01[P]chromium-snss-parse/examples/parse_print_types.cpp
// Function: main
int main(int argc, char* argv[]) {
    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
        std::cout << "For example on ArchLinux you could try and parse ";
        std::cout << "~/.config/chromium/Default/Current Session" << std::endl;
    }

    std::ifstream f(argv[1], std::ios::binary | std::ios::in);
    if (!f.is_open() || f.fail())
        return 1;

    std::vector<std::shared_ptr<Command>> cmds = read_session_file(f);

    for (auto & x : cmds) {
        std::cout << " Size: " << x->size << " Type: " << static_cast<uint16_t>(x->type) << std::endl;
    }

    f.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rsi, %rbx
cmpl $0x2, %edi
je 0x4be3
movq 0x54c7(%rip), %r14      # 0x9fd0
leaq 0x1624(%rip), %rsi      # 0x6134
movl $0x7, %edx
movq %r14, %rdi
callq 0x3150
movq (%rbx), %r15
testq %r15, %r15
je 0x4b41
movq %r15, %rdi
callq 0x30c0
movq 0x549c(%rip), %rdi      # 0x9fd0
movq %r15, %rsi
movq %rax, %rdx
callq 0x3150
jmp 0x4b59
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x31d0
leaq 0x15dc(%rip), %rsi      # 0x613c
movl $0xb, %edx
movq %r14, %rdi
callq 0x3150
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3120
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
leaq 0x15ad(%rip), %rsi      # 0x6148
movl $0x31, %edx
movq %r14, %rdi
callq 0x3150
leaq 0x15cb(%rip), %rsi      # 0x617a
movl $0x2a, %edx
movq %r14, %rdi
callq 0x3150
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3120
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq 0x8(%rbx), %rsi
leaq -0x248(%rbp), %rdi
movl $0xc, %edx
callq 0x3210
leaq -0x1d0(%rbp), %rdi
callq 0x3050
movl $0x1, %ebx
testb %al, %al
je 0x4cea
movq -0x248(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x228(%rbp,%rax)
jne 0x4cea
leaq -0x40(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x4672
movq -0x40(%rbp), %r13
movq -0x38(%rbp), %r14
cmpq %r14, %r13
je 0x4cd3
movq 0x537e(%rip), %rbx      # 0x9fd0
leaq 0x1554(%rip), %r15      # 0x61ad
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x153d(%rip), %rsi      # 0x61a5
callq 0x3150
movq (%r13), %rax
movzwl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x30e0
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3150
movq (%r13), %rax
movzwl 0xc(%rax), %esi
movq %r12, %rdi
callq 0x30e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3120
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
addq $0x10, %r13
cmpq %r14, %r13
jne 0x4c59
leaq -0x248(%rbp), %rdi
callq 0x3040
leaq -0x40(%rbp), %rdi
callq 0x4d80
xorl %ebx, %ebx
leaq -0x248(%rbp), %rdi
callq 0x3060
movl %ebx, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4d11
movq %rax, %rbx
jmp 0x4d1d
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x4d80
leaq -0x248(%rbp), %rdi
callq 0x3060
movq %rbx, %rdi
callq 0x3200
nop