// File: pfnet-research[P]pml/src/parser.cpp
// Function: parser::impl_formula(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long&)
formula_result_t impl_formula(std::string const& input, size_t& pos) {
    auto head_result = or_formula(input, pos);
    if (head_result.is_error())
        return head_result;
    auto acc = head_result.ok();

    while (true) {
        auto impl_token = next_token(input, pos);
        if (impl_token.kind != token_t::kind_t::FatArrow)
            break;
        pos = impl_token.pos + impl_token.lexime.size();

        auto formula_result = or_formula(input, pos);
        if (formula_result.is_error())
            return formula_result;
        acc = make<logic::impl_formula_t>(acc, formula_result.ok());
    }
    return acc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xd8(%rbp)
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x39220
movq -0xc8(%rbp), %rdi
callq 0x40890
movb %al, -0xb9(%rbp)
jmp 0x39554
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x39560
jmp 0x3958f
movq -0xd8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x40e60
jmp 0x39572
movl $0x1, -0x60(%rbp)
jmp 0x3976a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x39783
leaq -0x50(%rbp), %rdi
callq 0x408f0
movq %rax, -0xe0(%rbp)
jmp 0x395a1
movq -0xe0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x16250
jmp 0x395b3
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x355b0
jmp 0x395cc
cmpl $0xc, -0xa0(%rbp)
je 0x395f2
movl $0x3, -0x60(%rbp)
jmp 0x39700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3975f
movq -0x98(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xa280
movq -0xe8(%rbp), %rcx
movq -0xd8(%rbp), %rdi
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movb $0x0, -0xa1(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39220
jmp 0x3963a
movq -0xd8(%rbp), %rdi
callq 0x40890
movb %al, -0xe9(%rbp)
jmp 0x3964e
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0x3965a
jmp 0x39698
movb $0x1, -0xa1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x396e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3972d
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x40970
jmp 0x3972d
movq -0xd8(%rbp), %rdi
callq 0x408f0
movq %rax, -0xf8(%rbp)
jmp 0x396ad
movq -0xf8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x397a0
jmp 0x396c6
leaq -0x70(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x40fb0
leaq -0xb8(%rbp), %rdi
callq 0x252d0
movl $0x0, -0x60(%rbp)
testb $0x1, -0xa1(%rbp)
jne 0x396fe
movq -0xd8(%rbp), %rdi
callq 0x40970
jmp 0x39700
leaq -0xa0(%rbp), %rdi
callq 0x404f0
movl -0x60(%rbp), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0x39728
jmp 0x3971b
movl -0xfc(%rbp), %eax
subl $0x3, %eax
je 0x3973b
jmp 0x39754
jmp 0x395b1
leaq -0xa0(%rbp), %rdi
callq 0x404f0
jmp 0x3975f
movq -0xd8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x40f50
jmp 0x3974d
movl $0x1, -0x60(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x16150
jmp 0x3976a
leaq -0x70(%rbp), %rdi
callq 0x16150
jmp 0x39783
leaq -0x50(%rbp), %rdi
callq 0x40970
movq -0xd0(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x40970
movq -0x58(%rbp), %rdi
callq 0xa650
nopw %cs:(%rax,%rax)