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

    std::vector<ptr<ast::expr_t>> args;
    while (true) {
        auto e_result = typed_expr(input, pos);
        if (e_result.is_error())
            break;
        args.push_back(e_result.ok());
    }

    if (args.empty())
        return f;
    else
        return expr_result_t::ok(make<ast::app_expr_t>(f, args));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x100(%rbp)
movq %rdi, %rax
movq %rax, -0xf8(%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, -0xf0(%rbp)
callq 0x3e290
movq -0xf0(%rbp), %rdi
callq 0x41970
movb %al, -0xe1(%rbp)
jmp 0x3e624
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x3e630
jmp 0x3e65f
movq -0x100(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x41990
jmp 0x3e642
movl $0x1, -0x60(%rbp)
jmp 0x3e836
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3e84f
leaq -0x50(%rbp), %rdi
callq 0x419e0
movq %rax, -0x108(%rbp)
jmp 0x3e671
movq -0x108(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x13050
leaq -0x88(%rbp), %rdi
callq 0x41ec0
jmp 0x3e68f
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x3e290
jmp 0x3e6a5
leaq -0xc0(%rbp), %rdi
callq 0x41970
movb %al, -0x109(%rbp)
jmp 0x3e6b9
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x3e6c5
jmp 0x3e6fc
movl $0x3, -0x60(%rbp)
jmp 0x3e72d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3e81f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2ffa0
jmp 0x3e81f
leaq -0xc0(%rbp), %rdi
callq 0x419e0
movq %rax, -0x118(%rbp)
jmp 0x3e711
movq -0x118(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x41ee0
jmp 0x3e726
movl $0x0, -0x60(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2ffa0
movl -0x60(%rbp), %eax
testl %eax, %eax
je 0x3e744
jmp 0x3e742
jmp 0x3e749
jmp 0x3e68d
leaq -0x88(%rbp), %rdi
callq 0x41f50
testb $0x1, %al
jne 0x3e75b
jmp 0x3e779
movq -0x100(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x41f90
jmp 0x3e76d
movl $0x1, -0x60(%rbp)
jmp 0x3e808
leaq -0xe0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x3e870
jmp 0x3e792
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x120(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x41fc0
movq -0x100(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x41a60
jmp 0x3e7c1
leaq -0xd0(%rbp), %rdi
callq 0x13080
leaq -0xe0(%rbp), %rdi
callq 0x41ff0
movl $0x1, -0x60(%rbp)
jmp 0x3e808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x13080
leaq -0xe0(%rbp), %rdi
callq 0x41ff0
jmp 0x3e81f
leaq -0x88(%rbp), %rdi
callq 0x42010
leaq -0x70(%rbp), %rdi
callq 0x13080
jmp 0x3e836
leaq -0x88(%rbp), %rdi
callq 0x42010
leaq -0x70(%rbp), %rdi
callq 0x13080
jmp 0x3e84f
leaq -0x50(%rbp), %rdi
callq 0x2ffa0
movq -0xf8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x2ffa0
movq -0x58(%rbp), %rdi
callq 0xa650
nopw %cs:(%rax,%rax)