// File: /workspace/github_cpp_makefile_star2_O3/yhirose[P]fizzbuzzlang/fzbz.cc
// Function: parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::ostream&)
shared_ptr<Ast> parse(const string& source, ostream& out) {
  parser parser(R"(
    # Syntax Rules
    EXPRESSION              ← TERNARY
    TERNARY                 ← CONDITION ('?' EXPRESSION ':' EXPRESSION)?
    CONDITION               ← MULTIPLICATIVE (ConditionOperator MULTIPLICATIVE)?
    MULTIPLICATIVE          ← CALL (MultiplicativeOperator CALL)*
    CALL                    ← PRIMARY (EXPRESSION)?
    PRIMARY                 ← FOR / Identifier / '(' EXPRESSION ')' / String / Number
    FOR                     ← 'for' Identifier 'from' Number 'to' Number EXPRESSION

    # Token Rules
    ConditionOperator       ← '=='
    MultiplicativeOperator  ← '%'
    Identifier              ← !Keyword < [a-zA-Z][a-zA-Z0-9_]* >
    String                  ← "'" < ([^'] .)* > "'"
    Number                  ← < [0-9]+ >

    Keyword                 ← ('for' / 'from' / 'to') ![a-zA-Z]
    %whitespace             ← [ \t\r\n]*
  )");

  parser.enable_ast();

  parser.set_logger([&](size_t ln, size_t col, const auto& msg) {
    out << ln << ":" << col << ": " << msg << endl;
  });

  shared_ptr<Ast> ast;
  if (parser.parse_n(source.data(), source.size(), ast)) {
    return parser.optimize_ast(ast);
  }

  return nullptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa0, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x39a49(%rip), %rdx     # 0x42287
leaq -0xb8(%rbp), %r12
movl $0x372, %esi            # imm = 0x372
movq %r12, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xd854
movq %r12, %rdi
callq 0xd8c4
leaq -0x60(%rbp), %rsi
movq $0x0, 0x8(%rsi)
movq %r15, (%rsi)
leaq 0x1165(%rip), %rax      # 0x99da
movq %rax, 0x18(%rsi)
leaq 0x11f2(%rip), %rax      # 0x9a72
movq %rax, 0x10(%rsi)
leaq -0xb8(%rbp), %rdi
callq 0xd902
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x88a7
leaq -0x60(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rcx
movaps %xmm0, (%rcx)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq -0xb8(%rbp), %rdi
xorl %r8d, %r8d
callq 0xd978
testb %al, %al
je 0x88f1
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x88fd
movq 0x55689(%rip), %rcx     # 0x5df70
cmpb $0x0, (%rcx)
je 0x88f9
incl 0x8(%rax)
jmp 0x88fd
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
jmp 0x8923
lock
incl 0x8(%rax)
leaq -0xb8(%rbp), %rsi
leaq -0x40(%rbp), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0xdae4
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x8923
callq 0x123fc
movq -0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x8931
callq 0x123fc
movq -0x70(%rbp), %rax
testq %rax, %rax
je 0x8948
leaq -0x80(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8967
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x82b0
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x8978
callq 0x123fc
movq %rbx, %rax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x89a5
callq 0x123fc
jmp 0x89a5
jmp 0x89d1
jmp 0x89d1
movq %rax, %rbx
movq -0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x89dc
callq 0x123fc
jmp 0x89dc
movq %rax, %rbx
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x89dc
leaq -0x60(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x89dc
movq %rax, %rdi
callq 0xe032
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0xdbe0
movq %rbx, %rdi
callq 0x8420