// File: /workspace/github_cpp_makefile_star2_O2/pfnet-research[P]pml/src/parser.cpp
// Function: parser::primary_term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long&)
term_result_t primary_term(std::string const& input, size_t& pos) {
    auto token = next_token(input, pos);
    if (token.kind == token_t::kind_t::Ident) {
        return var_term(input, pos);
    } else if (token.kind == token_t::kind_t::LParen) {
        EXPECT(lparen_token, LParen);
        auto inner_result = term(input, pos);
        if (inner_result.is_error())
            return inner_result;
        EXPECT(rparen_token, RParen);
        return inner_result;
    } else if (token.kind == token_t::kind_t::Prob) {
        EXPECT(prob_token, Prob);
        EXPECT(lparen_token, LParen);
        auto inner_result = formula(input, pos);
        if (inner_result.is_error())
            return inner_result.convert<ptr<logic::term_t>>();
        EXPECT(rparen_token, RParen);
        return term_result_t::ok(make<logic::prob_term_t>(inner_result.ok()));
    } else if (token.kind == token_t::kind_t::Int) {
        EXPECT(int_token, Int);
        pos = int_token.pos + int_token.lexime.size();
        return term_result_t::ok(make<logic::int_term_t>(std::stoi(int_token.lexime)));
    } else {
        return term_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 %r13
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdx), %rdx
leaq 0x130(%rsp), %r15
movq %r15, %rdi
callq 0x1537c
movl (%r15), %esi
cmpl $0x7, %esi
je 0x16090
cmpl $0x23, %esi
je 0x15e58
cmpl $0x1f, %esi
je 0x15fc0
cmpl $0xa, %esi
jne 0x16138
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x15d07
jmp 0x162db
movq (%r14), %rdx
leaq 0x8(%rsp), %rdi
pushq $0x23
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0x38(%rsp)
je 0x161d4
leaq 0x8(%rsp), %rdi
callq 0x1ac66
leaq 0x100(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0x110(%rsp), %r15
movq 0x8(%r15), %rdx
addq -0x8(%r15), %rdx
movq %rdx, (%r14)
leaq 0x40(%rsp), %rdi
pushq $0x1f
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0x70(%rsp)
je 0x16222
leaq 0x40(%rsp), %rdi
callq 0x1ac66
leaq 0x1a0(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0x1b0(%rsp), %r13
movq 0x8(%r13), %rax
addq -0x8(%r13), %rax
movq %rax, (%r14)
leaq 0x78(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x172a4
cmpb $0x0, 0xa8(%rsp)
je 0x16279
movq (%r14), %rdx
leaq 0xb0(%rsp), %rdi
pushq $0x20
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0xe0(%rsp)
je 0x16288
leaq 0xb0(%rsp), %rdi
callq 0x1ac66
leaq 0x170(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0x180(%rsp), %r12
movq 0x8(%r12), %rax
addq -0x8(%r12), %rax
movq %rax, (%r14)
leaq 0x78(%rsp), %rdi
callq 0x1ad12
leaq 0xf0(%rsp), %rdi
movq %rax, %rsi
callq 0x1b6b3
leaq 0x168(%rsp), %rdi
leaq 0xf8(%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
movq %r12, %rdi
callq 0x9130
jmp 0x162a0
movq (%r14), %rdx
leaq 0x8(%rsp), %rdi
pushq $0x1f
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0x38(%rsp)
je 0x161ee
leaq 0x8(%rsp), %rdi
callq 0x1ac66
leaq 0xb0(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0xc0(%rsp), %r15
movq 0x8(%r15), %rax
addq -0x8(%r15), %rax
movq %rax, (%r14)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x16611
cmpb $0x0, 0x70(%rsp)
je 0x1623c
movq (%r14), %rdx
leaq 0x78(%rsp), %rdi
pushq $0x20
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0xa8(%rsp)
je 0x1624b
leaq 0x78(%rsp), %rdi
callq 0x1ac66
leaq 0x100(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0x110(%rsp), %r12
movq 0x8(%r12), %rax
addq -0x8(%r12), %rax
movq %rax, (%r14)
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x1acd2
movq %r12, %rdi
callq 0x9130
jmp 0x16260
movq (%r14), %rdx
leaq 0x8(%rsp), %rdi
pushq $0x7
popq %rcx
movq %r12, %rsi
callq 0x15bc7
cmpb $0x0, 0x38(%rsp)
je 0x16208
leaq 0x8(%rsp), %rdi
callq 0x1ac66
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x1acbe
leaq 0x50(%rsp), %r15
movq 0x8(%r15), %rax
addq -0x8(%r15), %rax
movq %rax, (%r14)
pushq $0xa
popq %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x1ad6a
leaq 0x100(%rsp), %rsi
movl %eax, (%rsi)
leaq 0xb0(%rsp), %rdi
callq 0x1b78c
leaq 0x80(%rsp), %rdi
leaq 0xb8(%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 0x162c9
movl $0x1, 0x8(%rsp)
movq (%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x15120
leaq 0x234c6(%rip), %rsi     # 0x39622
leaq 0x78(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0xb97b
leaq 0x23532(%rip), %rdx     # 0x396a7
leaq 0x40(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xeb69
leaq 0x18(%rsp), %r14
leaq 0x140(%rsp), %rdx
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x1abb6
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x1ad86
movq %r14, %rdi
callq 0x9130
leaq 0x40(%rsp), %rdi
callq 0x9130
leaq 0x78(%rsp), %rdi
callq 0x9130
leaq 0xb0(%rsp), %rdi
jmp 0x162d6
leaq 0x8(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1abe0
jmp 0x162d1
leaq 0x8(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1abe0
jmp 0x162d1
leaq 0x8(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1abe0
jmp 0x162d1
leaq 0x40(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1abe0
jmp 0x162bf
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x1acd2
jmp 0x1626d
leaq 0x78(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1abe0
leaq 0x88(%rsp), %rdi
callq 0x9130
leaq 0x40(%rsp), %rdi
callq 0x1fb90
jmp 0x162c9
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0x1acf6
jmp 0x162ad
leaq 0xb0(%rsp), %rdi
callq 0x1ac0e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1abe0
leaq 0xc0(%rsp), %rdi
callq 0x9130
leaq 0x78(%rsp), %rdi
callq 0x1fba8
movq %r13, %rdi
callq 0x9130
leaq 0x50(%rsp), %rdi
callq 0x9130
movq %r15, %rdi
callq 0x9130
leaq 0x18(%rsp), %rdi
callq 0x9130
leaq 0x140(%rsp), %rdi
callq 0x9130
movq %rbx, %rax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %r12, %rdi
callq 0x9130
jmp 0x1630e
jmp 0x1630b
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x9130
jmp 0x1632f
movq %rax, %rbx
movq %r12, %rdi
callq 0x9130
jmp 0x1634d
jmp 0x1632c
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x1fba8
jmp 0x1633e
movq %rax, %rbx
movq %r13, %rdi
callq 0x9130
jmp 0x16372
jmp 0x1634a
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9130
jmp 0x16361
jmp 0x1635e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x1fb90
jmp 0x16392
jmp 0x1636f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x9130
jmp 0x16392
jmp 0x1638f
jmp 0x1638f
movq %rax, %rbx
movq %r14, %rdi
callq 0x9130
jmp 0x1639f
movq %rax, %rbx
movq %r15, %rdi
callq 0x9130
jmp 0x163c7
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x9130
jmp 0x163ae
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x9130
jmp 0x163d1
jmp 0x163c4
jmp 0x163c4
jmp 0x163c4
jmp 0x163c4
jmp 0x163c4
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x163d9
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x9130
jmp 0x163eb
jmp 0x163e8
jmp 0x163e8
jmp 0x163e8
jmp 0x163e8
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x9130
movq %rbx, %rdi
callq 0x94d0