// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x10(%rsp)
movl %edx, 0x8(%rsp)
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq (%rsi), %rax
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rax, 0x8(%rsi)
je 0x2d0d
movq %rsi, %r15
movl $0x28, %r12d
xorl %ebp, %ebp
leaq 0x18(%rsp), %r13
movslq (%rax,%r12), %rcx
cmpq %rcx, -0x18(%rax,%r12)
jbe 0x2ceb
leaq (%rax,%r12), %rdx
addq $-0x20, %rdx
movq (%rdx), %rsi
movl 0x8(%rsp), %edi
cmpb %dil, (%rsi,%rcx)
jne 0x2ceb
addq %r12, %rax
movsbl -0x28(%rax), %esi
movl (%rax), %ecx
incl %ecx
movq %r13, %rdi
callq 0x2a2c
movq %rbx, %rdi
movq %r13, %r14
movq %r13, %rsi
callq 0x2e78
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2cde
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21b0
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %r14, %r13
incq %rbp
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
imulq %r8, %rcx
addq $0x30, %r12
cmpq %rbp, %rcx
ja 0x2c81
movq 0x8(%rbx), %rax
cmpq (%rbx), %rax
je 0x2e0c
movq $0x0, 0x8(%rsp)
leaq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rax
movq (%rax), %rdx
cmpq %rdx, 0x8(%rax)
je 0x2de7
movl $0x8, %r12d
movq 0x8(%rsp), %rax
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
xorl %r13d, %r13d
movq (%rbx), %rax
movslq 0x28(%rax,%r15), %rcx
cmpq %rcx, 0x10(%rax,%r15)
jbe 0x2dc0
addq %r15, %rax
movq 0x8(%rax), %rax
movb (%rax,%rcx), %al
cmpb -0x8(%rdx,%r12), %al
jne 0x2dc0
movsbl -0x8(%rdx,%r12), %esi
addq %r12, %rdx
movq %rbp, %rdi
xorl %ecx, %ecx
callq 0x2a2c
movq %rbx, %r14
movq %rbx, %rdi
movq %rbp, %rbx
movq %rbp, %rsi
callq 0x2e78
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2db0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21b0
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %rbx, %rbp
movq %r14, %rbx
incq %r13
movq 0x10(%rsp), %rax
movq (%rax), %rdx
movq 0x8(%rax), %rax
subq %rdx, %rax
sarq $0x4, %rax
imulq %r8, %rax
addq $0x30, %r12
cmpq %r13, %rax
ja 0x2d50
movq 0x8(%rbx), %rax
subq (%rbx), %rax
movq 0x8(%rsp), %rdx
incq %rdx
sarq $0x4, %rax
imulq %r8, %rax
movq %rdx, 0x8(%rsp)
cmpq %rdx, %rax
ja 0x2d28
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2e68
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x2e68
jmp 0x2e65
movq %rax, %r15
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2e60
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r14, %rbx
jmp 0x2e68
movq %rax, %r15
movq %rbx, %rdi
callq 0x32c8
movq %r15, %rdi
callq 0x22f0