// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq (%rsi), %rax
movq 0x8(%rsi), %rsi
cmpq %rax, %rsi
je 0x2cfa
movl %edx, %ebp
xorl %r13d, %r13d
leaq 0x10(%rsp), %r12
xorl %r14d, %r14d
movslq 0x28(%rax,%r13), %rcx
cmpq %rcx, 0x10(%rax,%r13)
jbe 0x2bcd
leaq (%rax,%r13), %rdx
addq $0x8, %rdx
movq (%rdx), %rdi
cmpb %bpl, (%rdi,%rcx)
jne 0x2bcd
addq %r13, %rax
movsbl (%rax), %esi
incl %ecx
movq %r12, %rdi
callq 0x2928
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2d44
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2bc6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
movq (%r15), %rax
movq 0x8(%r15), %rsi
incq %r14
movq %rsi, %rcx
subq %rax, %rcx
sarq $0x4, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
addq $0x30, %r13
cmpq %r14, %rcx
ja 0x2b72
movq (%rbx), %rcx
cmpq %rcx, 0x8(%rbx)
je 0x2cfa
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movq 0x8(%rax), %rax
xorl %r10d, %r10d
leaq 0x10(%rsp), %r12
movq %rax, %rsi
cmpq %rdx, %rsi
je 0x2cd2
movl $0x8, %r13d
movq %r10, 0x40(%rsp)
leaq (%r10,%r10,2), %r15
shlq $0x4, %r15
xorl %r14d, %r14d
movq (%rbx), %rcx
movslq 0x28(%rcx,%r15), %rsi
cmpq %rsi, 0x10(%rcx,%r15)
jbe 0x2c9d
addq %r15, %rcx
movq 0x8(%rcx), %rcx
movb (%rcx,%rsi), %cl
cmpb -0x8(%rdx,%r13), %cl
jne 0x2c9d
addq %r13, %rdx
movsbl %cl, %esi
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x2928
movq %rbx, %rdi
movq %r12, %rbp
movq %r12, %rsi
callq 0x2d44
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2c8e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movq 0x8(%rax), %rax
movq %rbp, %r12
incq %r14
movq %rax, %rcx
subq %rdx, %rcx
sarq $0x4, %rcx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rcx
addq $0x30, %r13
cmpq %r14, %rcx
ja 0x2c34
movq (%rbx), %rcx
movq %rax, %rsi
movq 0x40(%rsp), %r10
jmp 0x2cd5
movq %rdx, %rsi
incq %r10
movq 0x8(%rbx), %r8
subq %rcx, %r8
sarq $0x4, %r8
movabsq $-0x5555555555555555, %r9 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r9, %r8
cmpq %r10, %r8
ja 0x2c15
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2d10
jmp 0x2d31
movq %rax, %r14
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2d34
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x2d34
movq %rax, %r14
movq %rbx, %rdi
callq 0x3190
movq %r14, %rdi
callq 0x22f0