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

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

        auto formula_result = neg_formula(input, pos);
        if (formula_result.is_error())
            return formula_result;
        acc = make<logic::and_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 0x38d20
movq -0xc8(%rbp), %rdi
callq 0x40890
movb %al, -0xb9(%rbp)
jmp 0x38f94
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x38fa0
jmp 0x38fcf
movq -0xd8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x40e60
jmp 0x38fb2
movl $0x1, -0x60(%rbp)
jmp 0x391aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x391c3
leaq -0x50(%rbp), %rdi
callq 0x408f0
movq %rax, -0xe0(%rbp)
jmp 0x38fe1
movq -0xe0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x16250
jmp 0x38ff3
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x355b0
jmp 0x3900c
cmpl $0x22, -0xa0(%rbp)
je 0x39032
movl $0x3, -0x60(%rbp)
jmp 0x39140
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3919f
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 0x38d20
jmp 0x3907a
movq -0xd8(%rbp), %rdi
callq 0x40890
movb %al, -0xe9(%rbp)
jmp 0x3908e
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0x3909a
jmp 0x390d8
movb $0x1, -0xa1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x39129
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3916d
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x40970
jmp 0x3916d
movq -0xd8(%rbp), %rdi
callq 0x408f0
movq %rax, -0xf8(%rbp)
jmp 0x390ed
movq -0xf8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x391e0
jmp 0x39106
leaq -0x70(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x40f20
leaq -0xb8(%rbp), %rdi
callq 0x25230
movl $0x0, -0x60(%rbp)
testb $0x1, -0xa1(%rbp)
jne 0x3913e
movq -0xd8(%rbp), %rdi
callq 0x40970
jmp 0x39140
leaq -0xa0(%rbp), %rdi
callq 0x404f0
movl -0x60(%rbp), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0x39168
jmp 0x3915b
movl -0xfc(%rbp), %eax
subl $0x3, %eax
je 0x3917b
jmp 0x39194
jmp 0x38ff1
leaq -0xa0(%rbp), %rdi
callq 0x404f0
jmp 0x3919f
movq -0xd8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x40f50
jmp 0x3918d
movl $0x1, -0x60(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x16150
jmp 0x391aa
leaq -0x70(%rbp), %rdi
callq 0x16150
jmp 0x391c3
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)