// File: /workspace/github_cpp_makefile_star2_O3/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 0x1d79c
cmpb $0x0, 0x30(%r12)
je 0x1db79
movq (%r14), %rdx
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x1ba35
movl 0x38(%rsp), %eax
leal -0x15(%rax), %ecx
cmpl $0x4, %ecx
jb 0x1dad5
cmpl $0xd, %eax
jne 0x1dbab
movq 0x50(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, (%r14)
movq %rsp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1d79c
cmpb $0x0, 0x30(%rsp)
je 0x1db93
movl 0x38(%rsp), %eax
addl $-0xd, %eax
cmpl $0xb, %eax
ja 0x1ddd7
leaq 0x2a6ca(%rip), %rcx     # 0x481dc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x68(%rsp), %rdi
callq 0x2495a
movq %rax, %r12
movq %rsp, %rdi
callq 0x2495a
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x426fb(%rip), %rax     # 0x60250
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19002
leaq 0x4272c(%rip), %rax     # 0x602a0
jmp 0x1dd76
leaq 0x68(%rsp), %rdi
callq 0x28156
movq %rbx, %rdi
movq %rax, %rsi
callq 0x249b4
jmp 0x1dda8
movq %rsp, %rdi
callq 0x28156
movq %rbx, %rdi
movq %rax, %rsi
callq 0x249b4
jmp 0x1dd85
leaq 0x10(%rsp), %rdi
movl $0x1, -0x10(%rdi)
movq (%r14), %rax
movq %rax, -0x8(%rdi)
leaq 0x48(%rsp), %rdx
leaq 0x2a75a(%rip), %rsi     # 0x48324
callq 0x11561
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 0x1ddc6
movq %rdx, 0x10(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x20(%rbx)
jmp 0x1ddcc
leaq 0x68(%rsp), %rdi
callq 0x2495a
movq %rax, %r12
movq %rsp, %rdi
callq 0x2495a
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x42890(%rip), %rax     # 0x604d0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19002
leaq 0x428c1(%rip), %rax     # 0x60520
jmp 0x1dd76
leaq 0x68(%rsp), %rdi
callq 0x2495a
movq %rax, %r12
movq %rsp, %rdi
callq 0x2495a
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x42712(%rip), %rax     # 0x603b0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19002
leaq 0x42743(%rip), %rax     # 0x60400
jmp 0x1dd76
leaq 0x68(%rsp), %rdi
callq 0x2495a
movq %rax, %r12
movq %rsp, %rdi
callq 0x2495a
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x42744(%rip), %rax     # 0x60440
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19002
leaq 0x42775(%rip), %rax     # 0x60490
jmp 0x1dd76
leaq 0x68(%rsp), %rdi
callq 0x2495a
movq %rax, %r12
movq %rsp, %rdi
callq 0x2495a
movq %rax, %r13
movl $0x38, %edi
callq 0x92d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x425c9(%rip), %rax     # 0x60320
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x19002
leaq 0x425fa(%rip), %rax     # 0x60370
movq %rax, 0x10(%r14)
movb $0x1, 0x30(%rbx)
movq %r15, (%rbx)
movq %r14, 0x8(%rbx)
movq %rsp, %rdi
callq 0x2809c
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1dda8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x92e0
leaq 0x68(%rsp), %rdi
callq 0x2809c
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 0x1dd8d
movl $0x10, %edi
callq 0x9150
movq %rax, %r14
leaq 0x2a56c(%rip), %rsi     # 0x48357
movq %rax, %rdi
callq 0x93c0
movq 0x441d6(%rip), %rsi     # 0x61fd0
movq 0x441a7(%rip), %rdx     # 0x61fa8
movq %r14, %rdi
callq 0x94b0
movq %rax, %rbx
movq %r14, %rdi
callq 0x9200
jmp 0x1de2a
jmp 0x1de22
jmp 0x1de27
jmp 0x1de27
jmp 0x1de27
jmp 0x1de27
jmp 0x1de27
movq %rax, %rbx
jmp 0x1de32
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2809c
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1de54
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x92e0
jmp 0x1de54
jmp 0x1de51
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2809c
movq %rbx, %rdi
callq 0x94e0