// File: /workspace/github_cpp_makefile_star2_O1/pfnet-research[P]pml/src/parser.cpp
// Function: parser::comparison_terms_formula(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long&)
formula_result_t comparison_terms_formula(std::string const& input, size_t& pos) {
    auto lhs_result = term(input, pos);
    if (lhs_result.is_error())
        return lhs_result.convert<ptr<logic::formula_t>>();
    auto token = next_token(input, pos);
    if (token.kind != token_t::kind_t::Eq &&
            token.kind != token_t::kind_t::Less &&
            token.kind != token_t::kind_t::Leq &&
            token.kind != token_t::kind_t::Geq &&
            token.kind != token_t::kind_t::Greater) {
        return formula_result_t::error(error_t {
                error_t::kind_t::UnexpectedToken, pos,
                "expected was comparison operation, but comming is " + token.lexime
                });

    }
    pos = token.pos + token.lexime.size();
    auto rhs_result = term(input, pos);
    if (rhs_result.is_error())
        return rhs_result.convert<ptr<logic::formula_t>>();

    switch (token.kind) {
    case token_t::kind_t::Eq:
        return formula_result_t::ok(make<logic::eq_formula_t>(lhs_result.ok(), rhs_result.ok()));
    case token_t::kind_t::Less:
        return formula_result_t::ok(make<logic::less_formula_t>(lhs_result.ok(), rhs_result.ok()));
    case token_t::kind_t::Leq:
        return formula_result_t::ok(make<logic::leq_formula_t>(lhs_result.ok(), rhs_result.ok()));
    case token_t::kind_t::Geq:
        return formula_result_t::ok(make<logic::geq_formula_t>(lhs_result.ok(), rhs_result.ok()));
    case token_t::kind_t::Greater:
        return formula_result_t::ok(make<logic::greater_formula_t>(lhs_result.ok(), rhs_result.ok()));
    default:
        throw std::logic_error{"must be unreachable"};
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa0, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0x1da9b
cmpb $0x0, 0x30(%r12)
je 0x1dec4
movq (%r14), %rdx
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x1bcc7
movl 0x38(%rsp), %eax
leal -0x15(%rax), %ecx
cmpl $0x4, %ecx
jb 0x1de20
cmpl $0xd, %eax
jne 0x1def6
movq 0x50(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, (%r14)
movq %rsp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1da9b
cmpb $0x0, 0x30(%rsp)
je 0x1dede
movl 0x38(%rsp), %eax
addl $-0xd, %eax
cmpl $0xb, %eax
ja 0x1e122
leaq 0x2a37f(%rip), %rcx     # 0x481dc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x68(%rsp), %rdi
callq 0x24a92
movq %rax, %r12
movq %rsp, %rdi
callq 0x24a92
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x43388(%rip), %rax     # 0x61228
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19222
leaq 0x433b9(%rip), %rax     # 0x61278
jmp 0x1e0c1
leaq 0x68(%rsp), %rdi
callq 0x282ee
movq %rbx, %rdi
movq %rax, %rsi
callq 0x24aec
jmp 0x1e0f3
movq %rsp, %rdi
callq 0x282ee
movq %rbx, %rdi
movq %rax, %rsi
callq 0x24aec
jmp 0x1e0d0
leaq 0x10(%rsp), %rdi
movl $0x1, -0x10(%rdi)
movq (%r14), %rax
movq %rax, -0x8(%rdi)
leaq 0x48(%rsp), %rdx
leaq 0x2a40f(%rip), %rsi     # 0x48324
callq 0x116cf
movb $0x0, 0x30(%rbx)
leaq 0x20(%rsp), %rax
movups -0x20(%rax), %xmm0
movups %xmm0, (%rbx)
leaq 0x20(%rbx), %rcx
movq %rcx, 0x10(%rbx)
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x1e111
movq %rdx, 0x10(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x20(%rbx)
jmp 0x1e117
leaq 0x68(%rsp), %rdi
callq 0x24a92
movq %rax, %r12
movq %rsp, %rdi
callq 0x24a92
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4351d(%rip), %rax     # 0x614a8
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19222
leaq 0x4354e(%rip), %rax     # 0x614f8
jmp 0x1e0c1
leaq 0x68(%rsp), %rdi
callq 0x24a92
movq %rax, %r12
movq %rsp, %rdi
callq 0x24a92
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x4339f(%rip), %rax     # 0x61388
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19222
leaq 0x433d0(%rip), %rax     # 0x613d8
jmp 0x1e0c1
leaq 0x68(%rsp), %rdi
callq 0x24a92
movq %rax, %r12
movq %rsp, %rdi
callq 0x24a92
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x433d1(%rip), %rax     # 0x61418
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19222
leaq 0x43402(%rip), %rax     # 0x61468
jmp 0x1e0c1
leaq 0x68(%rsp), %rdi
callq 0x24a92
movq %rax, %r12
movq %rsp, %rdi
callq 0x24a92
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x43256(%rip), %rax     # 0x612f8
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19222
leaq 0x43287(%rip), %rax     # 0x61348
movq %rax, 0x10(%r14)
movb $0x1, 0x30(%rbx)
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movq %rsp, %rdi
callq 0x28234
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e0f3
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x92e0
leaq 0x68(%rsp), %rdi
callq 0x28234
movq %rbx, %rax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x18(%rsp), %rax
movq %rax, 0x18(%rbx)
jmp 0x1e0d8
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x2a221(%rip), %rsi     # 0x48357
movq %rax, %rdi
callq 0x93c0
movq 0x44e8b(%rip), %rsi     # 0x62fd0
movq 0x44e5c(%rip), %rdx     # 0x62fa8
movq %r14, %rdi
callq 0x94b0
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x1e175
jmp 0x1e16d
jmp 0x1e172
jmp 0x1e172
jmp 0x1e172
jmp 0x1e172
jmp 0x1e172
movq %rax, %rbx
jmp 0x1e17d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x28234
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e19f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x1e19f
jmp 0x1e19c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x28234
movq %rbx, %rdi
callq 0x94e0