// File: /workspace/github_cpp_makefile_star2_O2/pfnet-research[P]pml/src/parser.cpp
// Function: parser::primary_formula(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long&)
formula_result_t primary_formula(std::string const& input, size_t& pos) {
    auto token = next_token(input, pos);
    if (token.kind == token_t::kind_t::True) {
        pos = token.pos + token.lexime.size();
        return formula_result_t::ok(make<logic::top_formula_t>());
    } else if (token.kind == token_t::kind_t::False) {
        pos = token.pos + token.lexime.size();
        return formula_result_t::ok(make<logic::bot_formula_t>());
    } else if (token.kind == token_t::kind_t::LParen) {
        EXPECT(lparen_token, LParen);
        auto inner_result = formula(input, pos);
        if (inner_result.is_error())
            return inner_result;
        EXPECT(rparen_token, RParen);
        return inner_result;
    } else {
        auto cmp_result = comparison_terms_formula(input, pos);
        if (cmp_result.is_ok())
            return cmp_result;
        if (token.kind == token_t::kind_t::Ident) {
            pos = token.pos + token.lexime.size();
            return formula_result_t::ok(make<logic::var_formula_t>(token.lexime));
        } else {
            return formula_result_t::error(parser::error_t {
                parser::error_t::kind_t::UnexpectedToken, pos,
                "expected was " + token_kind_to_string(token.kind) + ", but coming is " + token.lexime
            });
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdx), %rdx
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
callq 0x1537c
movl (%r15), %eax
cmpl $0x1f, %eax
je 0x16b8a
cmpl $0x9, %eax
je 0x16b36
cmpl $0x8, %eax
jne 0x16c56
movq 0xc0(%rsp), %rax
addq 0xb0(%rsp), %rax
movq %rax, (%r14)
movq %rsp, %rdi
callq 0x1c1ff
jmp 0x16b51
movq 0xc0(%rsp), %rax
addq 0xb0(%rsp), %rax
movq %rax, (%r14)
movq %rsp, %rdi
callq 0x1c35c
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %r14
andq $0x0, (%rdi)
movb $0x1, 0x30(%rbx)
movaps -0x8(%r14), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x8(%r14)
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
callq 0xa248
movq %r14, %rdi
callq 0xa248
jmp 0x16df2
movq (%r14), %rdx
leaq 0x38(%rsp), %rdi
pushq $0x1f
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0x68(%rsp)
je 0x16c7f
leaq 0x38(%rsp), %rdi
callq 0x1ac66
leaq 0x108(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0x118(%rsp), %r15
movq 0x8(%r15), %rax
addq -0x8(%r15), %rax
movq %rax, (%r14)
movq %rsp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x172a4
cmpb $0x0, 0x30(%rsp)
je 0x16da9
movq (%r14), %rdx
leaq 0x70(%rsp), %rdi
pushq $0x20
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0xa0(%rsp)
je 0x16db6
leaq 0x70(%rsp), %rdi
callq 0x1ac66
leaq 0xd8(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0xe8(%rsp), %r12
movq 0x8(%r12), %rax
addq -0x8(%r12), %rax
movq %rax, (%r14)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x1ae4c
movq %r12, %rdi
callq 0x9130
jmp 0x16dcb
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x16806
cmpb $0x1, 0x68(%rsp)
jne 0x16c99
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x1ae4c
jmp 0x16d9d
leaq 0x38(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1ae1e
jmp 0x16de8
movl 0xa8(%rsp), %esi
cmpl $0xa, %esi
jne 0x16cfb
leaq 0xb8(%rsp), %rsi
movq 0x8(%rsi), %rax
addq -0x8(%rsi), %rax
movq %rax, (%r14)
leaq 0x70(%rsp), %rdi
callq 0x1c4bc
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %r14
andq $0x0, (%rdi)
movb $0x1, 0x30(%rbx)
movaps -0x8(%r14), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x8(%r14)
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
callq 0xa248
movq %r14, %rdi
callq 0xa248
jmp 0x16d9d
movl $0x1, (%rsp)
movq (%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x15120
leaq 0x22904(%rip), %rsi     # 0x39622
leaq 0x108(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0xb97b
leaq 0x2296d(%rip), %rdx     # 0x396a7
leaq 0x70(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0xeb69
leaq 0x10(%rsp), %r14
leaq 0xb8(%rsp), %rdx
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x1abb6
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x1ae0c
movq %r14, %rdi
callq 0x9130
leaq 0x70(%rsp), %rdi
callq 0x9130
leaq 0x108(%rsp), %rdi
callq 0x9130
leaq 0xd8(%rsp), %rdi
callq 0x9130
leaq 0x38(%rsp), %rdi
callq 0x1fba8
jmp 0x16df2
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x1ae4c
jmp 0x16dd8
leaq 0x70(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1ae1e
leaq 0x80(%rsp), %rdi
callq 0x9130
movq %rsp, %rdi
callq 0x1fba8
movq %r15, %rdi
callq 0x9130
leaq 0x48(%rsp), %rdi
callq 0x9130
leaq 0xb8(%rsp), %rdi
callq 0x9130
movq %rbx, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x16e13
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9130
jmp 0x16e44
movq %rax, %rbx
movq %r14, %rdi
callq 0x9130
jmp 0x16e35
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x9130
jmp 0x16e51
movq %rax, %rbx
movq %rsp, %rdi
callq 0x1fba8
jmp 0x16e86
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x9130
jmp 0x16e63
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x9130
jmp 0x16e77
jmp 0x16e74
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1fba8
jmp 0x16eaa
movq %rax, %rbx
movq %r15, %rdi
callq 0x9130
jmp 0x16e95
jmp 0x16e92
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x9130
jmp 0x16eaa
jmp 0x16ea7
jmp 0x16ea7
jmp 0x16ea7
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x9130
movq %rbx, %rdi
callq 0x94d0