// File: instance01[P]chromium-snss-parse/examples/parse_print_urls.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;
        return 0;
    }

    std::vector<std::shared_ptr<Command>> cmds = read_session_file(std::string(argv[1]));

    for (auto & x : cmds) {
        if (x->type == 6) {
            std::shared_ptr<CommandUpdateTabNavigation> c = std::static_pointer_cast<CommandUpdateTabNavigation>(x);
            std::cout << c->tabid << " " << c->index << " " << c->url << std::endl;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
je 0x58f4
movq 0xd756(%rip), %rdi      # 0x12fd0
leaq 0x68b8(%rip), %rsi      # 0xc139
callq 0x3190
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3190
movq %rax, %rdi
leaq 0x68a2(%rip), %rsi      # 0xc141
callq 0x3190
movq %rax, %rdi
movq 0xd70a(%rip), %rsi      # 0x12fb8
callq 0x31c0
movq 0xd716(%rip), %rdi      # 0x12fd0
leaq 0x688c(%rip), %rsi      # 0xc14d
callq 0x3190
movq 0xd703(%rip), %rdi      # 0x12fd0
leaq 0x68ab(%rip), %rsi      # 0xc17f
callq 0x3190
movq %rax, %rdi
movq 0xd6d5(%rip), %rsi      # 0x12fb8
callq 0x31c0
movl $0x0, -0x4(%rbp)
jmp 0x5af1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3310
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x6c70
jmp 0x592c
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5290
jmp 0x593b
leaq -0x48(%rbp), %rdi
callq 0x3110
leaq -0x49(%rbp), %rdi
callq 0x31e0
leaq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x6d20
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0x6d50
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x6d80
testb $0x1, %al
jne 0x5985
jmp 0x5ae8
leaq -0x70(%rbp), %rdi
callq 0x6dc0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x6750
cmpl $0x6, 0xc(%rax)
jne 0x5ad8
movq -0x80(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x5d30
movq -0xb0(%rbp), %rdi
callq 0x5d80
movl 0x14(%rax), %esi
movq 0xd5fe(%rip), %rdi      # 0x12fd0
callq 0x32e0
movq %rax, -0xa8(%rbp)
jmp 0x59e0
movq -0xa8(%rbp), %rdi
leaq 0x6700(%rip), %rsi      # 0xc0ee
callq 0x3190
movq %rax, -0xb8(%rbp)
jmp 0x59fc
leaq -0x90(%rbp), %rdi
callq 0x5d80
movq -0xb8(%rbp), %rdi
movl 0x18(%rax), %esi
callq 0x32e0
movq %rax, -0xc0(%rbp)
jmp 0x5a20
movq -0xc0(%rbp), %rdi
leaq 0x66c0(%rip), %rsi      # 0xc0ee
callq 0x3190
movq %rax, -0xc8(%rbp)
jmp 0x5a3c
leaq -0x90(%rbp), %rdi
callq 0x5d80
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0x3180
movq %rax, -0xd0(%rbp)
jmp 0x5a64
movq -0xd0(%rbp), %rdi
movq 0xd546(%rip), %rsi      # 0x12fb8
callq 0x31c0
jmp 0x5a79
leaq -0x90(%rbp), %rdi
callq 0x5d10
jmp 0x5ad8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5aaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3110
leaq -0x49(%rbp), %rdi
callq 0x31e0
jmp 0x5afd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5d10
leaq -0x28(%rbp), %rdi
callq 0x6bc0
jmp 0x5afd
jmp 0x5ada
leaq -0x70(%rbp), %rdi
callq 0x6de0
jmp 0x596f
leaq -0x28(%rbp), %rdi
callq 0x6bc0
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x3300
nopw %cs:(%rax,%rax)