// File: /workspace/github_cpp_makefile_star2_O1/instance01[P]chromium-snss-parse/examples/../snss-parse-lib.hpp
// Function: read_next_tab_command(std::basic_ifstream<char, std::char_traits<char>>&)
std::shared_ptr<Command> read_next_tab_command(std::ifstream& f) {
    std::shared_ptr<Command> ret;
    int prev = f.tellg();
    uint16_t size = read_arbitrary<uint16_t>(f, 2);
    uint8_t type_id = read_arbitrary<uint8_t>(f, 1);

    if (0 == size) {
        std::cerr << "Error: Encountered command with size 0. This can indicate a corrupt file.";
    }

    switch(type_id) {
        case 1: // CommandUpdateTabNavigation
        {
            // TODO Copied from read_next_session_command
            ret = std::shared_ptr<CommandUpdateTabNavigation>(new CommandUpdateTabNavigation());
            std::shared_ptr<CommandUpdateTabNavigation> ret2 = std::static_pointer_cast<CommandUpdateTabNavigation>(ret);
            ret2->pickle_size = read_arbitrary<uint32_t>(f, 4);
            ret2->tabid = read_arbitrary<int32_t>(f, 4);
            ret2->index = read_arbitrary<int32_t>(f, 4);
            if (read_string(f, ret2->url, true))
                ret2->title = read_string16(f, true);
            // TODO Add missing stuff
            break;
        }
        case 2: // CommandRestoredEntry
        {
            ret = std::shared_ptr<CommandRestoredEntry>(new CommandRestoredEntry());
            std::shared_ptr<CommandRestoredEntry> ret2 = std::static_pointer_cast<CommandRestoredEntry>(ret);
            ret2->entry_id = read_arbitrary<int32_t>(f, 4);
            break;
        }
        case 4: // CommandSelectedNavigationInTab
        {
            ret = std::shared_ptr<CommandSelectedNavigationInTab>(new CommandSelectedNavigationInTab());
            std::shared_ptr<CommandSelectedNavigationInTab> ret2 = std::static_pointer_cast<CommandSelectedNavigationInTab>(ret);
            ret2->tabid = read_arbitrary<int32_t>(f, 4);
            ret2->index = read_arbitrary<int32_t>(f, 4);
            ret2->timestamp = read_arbitrary<int64_t>(f, 8); // TODO First probe for next command
            break;
        }
        case 5: // CommandPinnedState
        {
            std::cout << std::hex << prev << std::dec << size << " " << std::endl;
            ret = std::shared_ptr<CommandPinnedState>(new CommandPinnedState());
            std::shared_ptr<CommandPinnedState> ret2 = std::static_pointer_cast<CommandPinnedState>(ret);
            ret2->pinned = read_arbitrary<bool>(f, 1);
            break;
        }
        default:
        {
            std::cerr << "Warning: Encountered unsupported id " << static_cast<uint16_t>(type_id) << std::endl;
            std::cerr << std::hex << "P: " << prev << std::dec << " S: " << size << " T: " << static_cast<uint16_t>(type_id) << std::endl;
            ret = std::shared_ptr<Command>(new Command());
        }
    }

    ret->size = size;
    ret->type = type_id;

    // Finish reading the command in case we skipped stuff
    prev += size + 2L;
    if (f.tellg() < prev) {
        f.seekg(prev);
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rsi, %rdi
callq 0x31f0
movq %rax, -0x60(%rbp)
leaq -0x50(%rbp), %rsi
movl $0x2, %edx
movq %r14, %rdi
callq 0x3160
leaq -0x50(%rbp), %rsi
movzwl (%rsi), %eax
movw %ax, -0x2a(%rbp)
movl $0x1, %edx
movq %r14, %rdi
callq 0x3160
movzbl -0x50(%rbp), %eax
movq %rax, -0x68(%rbp)
cmpw $0x0, -0x2a(%rbp)
jne 0x4174
movq 0x5e8d(%rip), %rdi      # 0x9ff0
leaq 0x1f2f(%rip), %rsi      # 0x6099
movl $0x49, %edx
callq 0x3150
movzwl -0x2a(%rbp), %eax
movq %rax, -0x58(%rbp)
movq -0x68(%rbp), %rax
decl %eax
cmpl $0x4, %eax
ja 0x4467
leaq 0x1eee(%rip), %rcx      # 0x6080
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x60, %edi
callq 0x3130
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x10(%rax)
leaq 0x50(%rax), %rcx
movq %rax, %rdx
addq $0x30, %rdx
leaq 0x552f(%rip), %rsi      # 0x9700
movq %rsi, (%rax)
movq %rdx, 0x20(%rax)
xorl %edx, %edx
movq %rdx, 0x28(%rax)
movb $0x0, 0x30(%rax)
movq %rcx, 0x40(%rax)
movq %rdx, 0x48(%rax)
movl $0x0, 0x50(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x526e
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r15, (%rbx)
movq 0x8(%rbx), %rdi
movq %r13, 0x8(%rbx)
testq %rdi, %rdi
je 0x4225
callq 0x50a8
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x4233
callq 0x50a8
testq %r13, %r13
je 0x4631
movq 0x5d85(%rip), %rax      # 0x9fc8
cmpb $0x0, (%rax)
je 0x462c
incl 0x8(%r13)
jmp 0x4631
movl $0x20, %edi
callq 0x3130
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
leaq 0x56b8(%rip), %rcx      # 0x9928
movq %rcx, (%rax)
leaq -0x48(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x5982
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r12, (%rbx)
movq 0x8(%rbx), %rdi
movq %r15, 0x8(%rbx)
testq %rdi, %rdi
je 0x42a7
callq 0x50a8
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x42b5
callq 0x50a8
testq %r15, %r15
je 0x45dd
movq 0x5d03(%rip), %rax      # 0x9fc8
cmpb $0x0, (%rax)
je 0x45d8
incl 0x8(%r15)
jmp 0x45dd
movl $0x18, %edi
callq 0x3130
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x55fa(%rip), %rcx      # 0x98f0
movq %rcx, (%rax)
leaq -0x48(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x58ce
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r12, (%rbx)
movq 0x8(%rbx), %rdi
movq %r15, 0x8(%rbx)
testq %rdi, %rdi
je 0x432d
callq 0x50a8
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x433b
callq 0x50a8
testq %r15, %r15
je 0x46dd
movq 0x5c7d(%rip), %rax      # 0x9fc8
cmpb $0x0, (%rax)
je 0x46d8
incl 0x8(%r15)
jmp 0x46dd
movq 0x5c6c(%rip), %rdi      # 0x9fd0
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl 0x18(%rdi,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rdi,%rax)
movq -0x60(%rbp), %rsi
callq 0x31e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x30e0
movq %rax, %r15
leaq 0x1d5d(%rip), %rsi      # 0x610a
movl $0x1, %edx
movq %rax, %rdi
callq 0x3150
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3120
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movl $0x18, %edi
callq 0x3130
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x5560(%rip), %rcx      # 0x9960
movq %rcx, (%rax)
leaq -0x48(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x5a36
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r12, (%rbx)
movq 0x8(%rbx), %rdi
movq %r15, 0x8(%rbx)
testq %rdi, %rdi
je 0x4437
callq 0x50a8
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x4445
callq 0x50a8
testq %r15, %r15
je 0x46fd
movq 0x5b73(%rip), %rax      # 0x9fc8
cmpb $0x0, (%rax)
je 0x46f8
incl 0x8(%r15)
jmp 0x46fd
movq 0x5b82(%rip), %rdi      # 0x9ff0
leaq 0x1c6e(%rip), %rsi      # 0x60e3
movl $0x24, %edx
callq 0x3150
movl -0x68(%rbp), %r13d
movq 0x5b66(%rip), %r15      # 0x9ff0
movq %r15, %rdi
movq %r13, %rsi
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
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r15,%rax)
leaq 0x1c2b(%rip), %rsi      # 0x6108
movl $0x3, %edx
movq %r15, %rdi
callq 0x3150
movq 0x5aff(%rip), %rdi      # 0x9ff0
movq -0x60(%rbp), %rsi
callq 0x31e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%r15,%rax)
leaq 0x1bf1(%rip), %rsi      # 0x610c
movl $0x4, %edx
movq %r15, %rdi
callq 0x3150
movq %r15, %rdi
movq -0x58(%rbp), %rsi
callq 0x30e0
movq %rax, %r15
leaq 0x1b56(%rip), %rsi      # 0x6094
movl $0x4, %edx
movq %rax, %rdi
callq 0x3150
movq %r15, %rdi
movq %r13, %rsi
callq 0x30e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3120
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movl $0x10, %edi
callq 0x3130
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
leaq 0x51b1(%rip), %rcx      # 0x9748
movq %rcx, (%rax)
leaq -0x48(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x581a
movaps -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x50(%rbp)
movq 0x8(%rbx), %rdi
movups %xmm0, (%rbx)
testq %rdi, %rdi
je 0x45c6
callq 0x50a8
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
jne 0x471e
jmp 0x4723
lock
incl 0x8(%r15)
leaq -0x50(%rbp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x3160
leaq -0x50(%rbp), %rsi
movl (%rsi), %eax
movl %eax, 0x10(%r12)
movl $0x4, %edx
movq %r14, %rdi
callq 0x3160
leaq -0x50(%rbp), %rsi
movl (%rsi), %eax
movl %eax, 0x14(%r12)
movl $0x8, %edx
movq %r14, %rdi
callq 0x3160
movq -0x50(%rbp), %rax
movq %rax, 0x18(%r12)
jmp 0x4716
lock
incl 0x8(%r13)
leaq -0x50(%rbp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x3160
leaq -0x50(%rbp), %rsi
movl (%rsi), %eax
movl %eax, 0x10(%r15)
movl $0x4, %edx
movq %r14, %rdi
callq 0x3160
leaq -0x50(%rbp), %rsi
movl (%rsi), %eax
movl %eax, 0x14(%r15)
movl $0x4, %edx
movq %r14, %rdi
callq 0x3160
movl -0x50(%rbp), %eax
movl %eax, 0x18(%r15)
leaq 0x20(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x33bd
testb %al, %al
je 0x46ce
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x3483
addq $0x40, %r15
leaq -0x50(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x3220
movq (%r12), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x46ce
movq -0x40(%rbp), %rax
leaq 0x4(,%rax,4), %rsi
callq 0x3140
testq %r13, %r13
je 0x4723
movq %r13, %rdi
jmp 0x471e
lock
incl 0x8(%r15)
leaq -0x50(%rbp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x3160
movl -0x50(%rbp), %eax
movl %eax, 0x10(%r12)
jmp 0x4716
lock
incl 0x8(%r15)
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
movq %r14, %rdi
callq 0x3160
movb -0x50(%rbp), %al
movb %al, 0x10(%r12)
testq %r15, %r15
je 0x4723
movq %r15, %rdi
callq 0x50a8
movq (%rbx), %rax
movzwl -0x2a(%rbp), %ecx
movw %cx, 0x8(%rax)
movq -0x68(%rbp), %rcx
movl %ecx, 0xc(%rax)
movq %r14, %rdi
callq 0x31f0
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %rdx
addl %edx, %ecx
addl $0x2, %ecx
movslq %ecx, %rsi
cmpq %rsi, %rax
jge 0x475c
movq %r14, %rdi
xorl %edx, %edx
callq 0x3170
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x478b
jmp 0x477e
jmp 0x477e
jmp 0x47a3
jmp 0x47a3
jmp 0x47a3
jmp 0x47a3
jmp 0x47a3
movq %rax, %r14
testq %r15, %r15
je 0x47a6
movq %r15, %rdi
jmp 0x4796
movq %rax, %r14
testq %r13, %r13
je 0x47a6
movq %r13, %rdi
callq 0x50a8
jmp 0x47a6
jmp 0x47a3
jmp 0x47a3
jmp 0x47a3
movq %rax, %r14
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x47b4
callq 0x50a8
movq %r14, %rdi
callq 0x3200