// File: AgathokakologicalBit[P]wit/src/parsing/parsing.cpp
// Function: akbit::system::parsing::(anonymous namespace)::parse_expression(std::shared_ptr<akbit::system::Node>, akbit::system::parsing::ParserState&, unsigned int)
std::shared_ptr<Node> parse_expression(std::shared_ptr<Node> left_operand, ParserState &state, uint32_t base_priority)
    {
      state.save();
      operator_t const * operation = &parse_operator(state);
      if (operation == &operator_unknown || operation->precedence < base_priority)
      {
        state.restore();
        return left_operand;
      }
      state.drop();

      std::shared_ptr<Node> right_operand = parse_statement_or_composite_unit(state);
      if (state.is_failed())
        return left_operand;

      // Get next operator
      state.save();
      operator_t const * next_operation = &parse_operator(state);
      if (state.is_failed()) { state.restore(); }
      else state.drop();

      while (next_operation->precedence > base_priority)
      {
          if (next_operation->precedence > operation->precedence)
          {
            // If the following operator has the higher priority
            // parse that subexpression first
            state.index -= next_operation->representation.size();
            right_operand = parse_statement(right_operand, state, operation->precedence);
            if (state.is_failed())
              return left_operand;

            state.save();
            next_operation = &parse_operator(state);
            if (state.is_failed()) { state.restore(); break; }
            else state.drop();

            if (next_operation->precedence <= base_priority)
              break;
          }

          if (left_operand->value.index() == 5 && std::get<Node::binary_operation_t>(left_operand->value).operation == operation)
          {
            std::get<Node::binary_operation_t>(left_operand->value).operands.push_back(right_operand);
          }
          else
          {
            left_operand = make_node_bop(left_operand, right_operand, operation);
          }

          operation = next_operation;

          right_operand = parse_statement_or_composite_unit(state);
          if (state.is_failed())
            return left_operand;

          state.save();
          next_operation = &parse_operator(state);
          if (state.is_failed()) { state.restore(); break; }
          else state.drop();
      }

      if (next_operation->precedence <= base_priority)
        state.index -= next_operation->representation.size();

      if (left_operand->value.index() == 5 && std::get<Node::binary_operation_t>(left_operand->value).operation == operation)
      {
        std::get<Node::binary_operation_t>(left_operand->value).operands.push_back(right_operand);
      }
      else
      {
        left_operand = make_node_bop(left_operand, right_operand, operation);
      }

      return left_operand;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rsi, -0x100(%rbp)
movq %rdi, -0xf8(%rbp)
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1c950
movq -0x18(%rbp), %rdi
callq 0x147e0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
leaq 0x406ad(%rip), %rcx     # 0x548c0
cmpq (%rcx), %rax
je 0x14224
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x1c(%rbp), %eax
jae 0x14245
movq -0x18(%rbp), %rdi
callq 0x1c980
movq -0xf8(%rbp), %rdi
movq -0x100(%rbp), %rsi
callq 0x15c80
jmp 0x147bd
movq -0x18(%rbp), %rdi
callq 0x1ca00
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x14ae0
movq -0x18(%rbp), %rdi
callq 0x15c20
testb $0x1, %al
jne 0x1426a
jmp 0x14289
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x15c80
movl $0x1, -0x3c(%rbp)
jmp 0x147a7
movq -0x18(%rbp), %rdi
callq 0x1c950
jmp 0x14294
movq -0x18(%rbp), %rdi
callq 0x147e0
movq %rax, -0x108(%rbp)
jmp 0x142a6
movq -0x108(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x15c20
testb $0x1, %al
jne 0x142c0
jmp 0x142de
movq -0x18(%rbp), %rdi
callq 0x1c980
jmp 0x142cb
jmp 0x142eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x147b2
movq -0x18(%rbp), %rdi
callq 0x1ca00
jmp 0x142e9
jmp 0x142eb
jmp 0x142ed
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x14627
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x1442f
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
callq 0x4240
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
leaq -0x78(%rbp), %rdi
movq %rdi, -0x110(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x9b20
movq -0x110(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
leaq -0x68(%rbp), %rdi
callq 0x14c70
jmp 0x14361
leaq -0x38(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x186a0
leaq -0x68(%rbp), %rdi
callq 0x9b50
leaq -0x78(%rbp), %rdi
callq 0x9b50
movq -0x18(%rbp), %rdi
callq 0x15c20
testb $0x1, %al
jne 0x1438f
jmp 0x143c8
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x15c80
movl $0x1, -0x3c(%rbp)
jmp 0x147a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x9b50
jmp 0x147b2
movq -0x18(%rbp), %rdi
callq 0x1c950
jmp 0x143d3
movq -0x18(%rbp), %rdi
callq 0x147e0
movq %rax, -0x118(%rbp)
jmp 0x143e5
movq -0x118(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x15c20
testb $0x1, %al
jne 0x143ff
jmp 0x1440f
movq -0x18(%rbp), %rdi
callq 0x1c980
jmp 0x1440a
jmp 0x14627
movq -0x18(%rbp), %rdi
callq 0x1ca00
jmp 0x1441a
jmp 0x1441c
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x1c(%rbp), %eax
ja 0x1442d
jmp 0x14627
jmp 0x1442f
movq -0x100(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
addq $0x10, %rdi
callq 0x9e50
cmpq $0x5, %rax
jne 0x144ba
movq -0x100(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
addq $0x10, %rdi
callq 0x18780
movq %rax, -0x120(%rbp)
jmp 0x1446e
movq -0x120(%rbp), %rax
movq (%rax), %rax
cmpq -0x28(%rbp), %rax
jne 0x144ba
movq -0x100(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
addq $0x10, %rdi
callq 0x18780
movq %rax, -0x128(%rbp)
jmp 0x1449f
movq -0x128(%rbp), %rdi
addq $0x8, %rdi
leaq -0x38(%rbp), %rsi
callq 0x1ca20
jmp 0x144b5
jmp 0x1456d
movq -0x100(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x9b20
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x9b20
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x88(%rbp), %rdi
callq 0x1ca90
jmp 0x1450b
movq -0x100(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x186a0
leaq -0x88(%rbp), %rdi
callq 0x9b50
leaq -0xa8(%rbp), %rdi
callq 0x9b50
leaq -0x98(%rbp), %rdi
callq 0x9b50
jmp 0x1456d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x9b50
leaq -0x98(%rbp), %rdi
callq 0x9b50
jmp 0x147b2
movq -0x58(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x14ae0
jmp 0x14587
leaq -0x38(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x186a0
leaq -0xb8(%rbp), %rdi
callq 0x9b50
movq -0x18(%rbp), %rdi
callq 0x15c20
testb $0x1, %al
jne 0x145b2
jmp 0x145d1
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x15c80
movl $0x1, -0x3c(%rbp)
jmp 0x147a7
movq -0x18(%rbp), %rdi
callq 0x1c950
jmp 0x145dc
movq -0x18(%rbp), %rdi
callq 0x147e0
movq %rax, -0x140(%rbp)
jmp 0x145ee
movq -0x140(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x15c20
testb $0x1, %al
jne 0x14608
jmp 0x14615
movq -0x18(%rbp), %rdi
callq 0x1c980
jmp 0x14613
jmp 0x14627
movq -0x18(%rbp), %rdi
callq 0x1ca00
jmp 0x14620
jmp 0x14622
jmp 0x142ed
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x1c(%rbp), %eax
ja 0x14652
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
callq 0x4240
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x100(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
addq $0x10, %rdi
callq 0x9e50
cmpq $0x5, %rax
jne 0x146dd
movq -0x100(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
addq $0x10, %rdi
callq 0x18780
movq %rax, -0x148(%rbp)
jmp 0x14691
movq -0x148(%rbp), %rax
movq (%rax), %rax
cmpq -0x28(%rbp), %rax
jne 0x146dd
movq -0x100(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
addq $0x10, %rdi
callq 0x18780
movq %rax, -0x150(%rbp)
jmp 0x146c2
movq -0x150(%rbp), %rdi
addq $0x8, %rdi
leaq -0x38(%rbp), %rsi
callq 0x1ca20
jmp 0x146d8
jmp 0x1478d
movq -0x100(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x9b20
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x158(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x9b20
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
callq 0x1ca90
jmp 0x1472e
movq -0x100(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x186a0
leaq -0xc8(%rbp), %rdi
callq 0x9b50
leaq -0xe8(%rbp), %rdi
callq 0x9b50
leaq -0xd8(%rbp), %rdi
callq 0x9b50
jmp 0x1478d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x9b50
leaq -0xd8(%rbp), %rdi
callq 0x9b50
jmp 0x147b2
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x15c80
movl $0x1, -0x3c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9b50
jmp 0x147bd
leaq -0x38(%rbp), %rdi
callq 0x9b50
jmp 0x147cd
movq -0xf0(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4560
nopw %cs:(%rax,%rax)