// File: davidsun[P]TinyCompiler/ItemSet.cpp
// Function: ItemSet::advance(char, std::vector<Item, std::allocator<Item>> const&) const
ItemSet ItemSet::advance(char c, const vector <Item> &rules) const{
    ItemSet ret;
    for (int i = 0; i < _items.size(); i ++){
        const Item &item = _items[i];
        if (item.position < item.right_side.size() && item.right_side[item.position] == c)
            ret.addItem(Item(item.left_side, item.right_side, item.position + 1));
    }
    for (int i = 0; i < ret.getItems().size(); i ++){
        for (int j = 0; j < rules.size(); j ++){
            const Item &item = ret.getItems()[i];
            const Item &rule = rules[j];
            if (item.position < item.right_side.size() && item.right_side[item.position] == rule.left_side)
                ret.addItem(Item(rule.left_side, rule.right_side, 0));
        }
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xd0(%rbp)
movb %dl, %al
movq %rdi, %rdx
movq %rdx, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x3fc0
movl $0x0, -0x28(%rbp)
movq -0xc0(%rbp), %rdi
movslq -0x28(%rbp), %rax
movq %rax, -0xd8(%rbp)
callq 0x48f0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
jae 0x41bb
movq -0xc0(%rbp), %rdi
movslq -0x28(%rbp), %rsi
callq 0x4920
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0x31e0
movq %rax, %rcx
movq -0xe0(%rbp), %rax
cmpq %rcx, %rax
jae 0x41ab
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rsi
callq 0x3300
movsbl (%rax), %eax
movsbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x41ab
movq -0x30(%rbp), %rax
movsbl (%rax), %esi
movq %rax, %rdx
addq $0x8, %rdx
movl 0x28(%rax), %ecx
incl %ecx
leaq -0x60(%rbp), %rdi
callq 0x3bc0
jmp 0x4163
movq -0xd0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4380
jmp 0x4175
leaq -0x60(%rbp), %rdi
callq 0x4940
jmp 0x41ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x4362
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4940
jmp 0x4362
jmp 0x41ad
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x40b8
movl $0x0, -0x70(%rbp)
movq -0xd0(%rbp), %rdi
movslq -0x70(%rbp), %rax
movq %rax, -0xf0(%rbp)
callq 0x4400
movq %rax, -0xe8(%rbp)
jmp 0x41e2
movq -0xe8(%rbp), %rdi
callq 0x48f0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x433c
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x48f0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x432c
movq -0xd0(%rbp), %rdi
callq 0x4400
movq %rax, -0x100(%rbp)
jmp 0x4244
movq -0x100(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x4920
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x74(%rbp), %rsi
callq 0x4920
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movslq 0x28(%rax), %rax
movq %rax, -0x108(%rbp)
movq -0x80(%rbp), %rdi
addq $0x8, %rdi
callq 0x31e0
movq %rax, %rcx
movq -0x108(%rbp), %rax
cmpq %rcx, %rax
jae 0x431c
movq -0x80(%rbp), %rdi
addq $0x8, %rdi
movq -0x80(%rbp), %rax
movslq 0x28(%rax), %rsi
callq 0x3300
movsbl (%rax), %eax
movq -0x88(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x431c
movq -0x88(%rbp), %rdx
movsbl (%rdx), %esi
addq $0x8, %rdx
leaq -0xb8(%rbp), %rdi
xorl %ecx, %ecx
callq 0x3bc0
jmp 0x42df
movq -0xd0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4380
jmp 0x42f4
leaq -0xb8(%rbp), %rdi
callq 0x4940
jmp 0x431c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4940
jmp 0x4362
jmp 0x431e
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x4208
jmp 0x432e
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x41c2
movb $0x1, -0x21(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x4352
movq -0xd0(%rbp), %rdi
callq 0x4960
movq -0xc8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x4960
movq -0x68(%rbp), %rdi
callq 0x3480
nopw (%rax,%rax)