// File: /workspace/github_cpp_makefile_star2_O3/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: FunctionCallToken::output(Parser*)
void FunctionCallToken::output(Parser *parser) {
  // Check if the function is a builtin, in which case the assembly
  // output will look different (with no CALL instruction).
  if ("COLOR" == _funcName) {
    // Signature is "void COLOR(uint16 color)"
    _arguments[0]->output(parser, VarLocation("M"));
    parser->writeInst("COLOR M");
  } else if ("PIXEL" == _funcName) {
    // Signature is "void PIXEL(uint16 x, uint16 y)"
    _arguments[0]->output(parser, VarLocation("M"));
    _arguments[1]->output(parser, VarLocation("N"));
    parser->writeInst("PIXEL M N");
  } else if ("TIMERST" == _funcName) {
    // Signatue is "void TIMERST()"
    parser->writeInst("TIMERST");
  } else if ("TIME" == _funcName) {
    // Signature is "uint16 TIME()"
    parser->writeInst("TIME L");
  } else if ("INPUT" == _funcName) {
    // Signature is "uint16 INPUT(uint16 input_id)"
    _arguments[0]->output(parser, VarLocation("M"));
    parser->writeInst("INPUT L M");
  } else if ("RND" == _funcName) {
    // Signature is "uint16 RND()"
    parser->writeInst("RND L");
  } else {
    // Save registers A through D if we are using them as arguments.
    std::stack<std::string> savedRegisters;
    std::string reg = "A";
    for (size_t i = 0; i < 4 && i < _arguments.size(); i++, reg[0]++) {
      parser->writeInst("PUSH " + reg);
      savedRegisters.push(reg);
    }
    // Evaluate up to the first four arguments and store them in registers
    // A through D.
    reg = "A";
    for (size_t i = 0; i < 4 && i < _arguments.size(); i++, reg[0]++) {
      _arguments[i]->output(parser, VarLocation(reg));
    }
    // Push any overflow arguments onto the stack. In reverse order so that
    // it matches the callee's expectations of the order.
    for (int i = _arguments.size() - 1; 4 <= i; i--) {
      _arguments[i]->output(parser, VarLocation("L"));
      parser->writeInst("PUSH L");
    }
    // Call the function
    parser->writeInst("CALL " + _funcName);
    // Restore registers A through D if they were used as arguments.
    while (!savedRegisters.empty()) {
      parser->writeInst("POP " + savedRegisters.top());
      savedRegisters.pop();
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r13
movq %rdi, %r14
leaq 0x10(%rdi), %rbx
leaq 0x1eb87(%rip), %rsi     # 0x35045
movq %rbx, %rdi
callq 0x70c0
testl %eax, %eax
je 0x168d0
leaq 0x1eb83(%rip), %rsi     # 0x35058
movq %rbx, %rdi
callq 0x70c0
testl %eax, %eax
je 0x16983
leaq 0x1eb74(%rip), %rsi     # 0x35060
movq %rbx, %rdi
callq 0x70c0
testl %eax, %eax
je 0x16ac0
leaq 0x1eb65(%rip), %rsi     # 0x35068
movq %rbx, %rdi
callq 0x70c0
testl %eax, %eax
je 0x16af3
leaq 0x1eb53(%rip), %rsi     # 0x3506d
movq %rbx, %rdi
callq 0x70c0
testl %eax, %eax
je 0x16b26
leaq 0x1eb4b(%rip), %rsi     # 0x3507c
movq %rbx, %rdi
callq 0x70c0
testl %eax, %eax
je 0x16bd6
movq %rbx, 0xc0(%rsp)
movq %r13, %rbx
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0xb9be
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f2da(%rip), %rsi     # 0x3585b
leaq 0x1f2d4(%rip), %rdx     # 0x3585c
leaq 0x80(%rsp), %rdi
callq 0xbdee
xorl %r15d, %r15d
leaq 0x8(%rsp), %r13
leaq 0x80(%rsp), %rbp
leaq 0x30(%rsp), %r12
movq 0x38(%r14), %rax
subq 0x30(%r14), %rax
sarq $0x4, %rax
cmpq %rax, %r15
jae 0x16612
movq %r13, %rdi
leaq 0x1eb8a(%rip), %rsi     # 0x3514f
movq %rbp, %rdx
callq 0xb692
movq %rbx, %rdi
movq %r13, %rsi
callq 0xab5a
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x165f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3030c
incq %r15
movq 0x80(%rsp), %rax
incb (%rax)
cmpq $0x4, %r15
jne 0x165aa
leaq 0x1f242(%rip), %rsi     # 0x3585b
leaq 0x80(%rsp), %rdi
callq 0x73d0
xorl %r15d, %r15d
leaq 0x8(%rsp), %r12
xorl %ebp, %ebp
movq 0x30(%r14), %rcx
movq 0x38(%r14), %rax
subq %rcx, %rax
movq %rax, %rdx
sarq $0x4, %rdx
cmpq %rdx, %rbp
jae 0x166bd
movq (%rcx,%r15), %r13
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xbd58
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x153ca
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1669a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x80(%rsp), %rax
incb (%rax)
incq %rbp
addq $0x10, %r15
cmpq $0x4, %rbp
jne 0x16630
movq 0x38(%r14), %rax
subq 0x30(%r14), %rax
shrq $0x4, %rax
decl %eax
cmpl $0x4, %eax
jl 0x167da
movl %eax, %ebp
leaq 0x1(%rbp), %r15
shlq $0x4, %rbp
leaq 0x8(%rsp), %r12
movq 0x30(%r14), %rax
movq (%rax,%rbp), %r13
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x1f3d6(%rip), %rsi     # 0x35ad8
leaq 0x1f3d0(%rip), %rdx     # 0x35ad9
callq 0xbdee
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xbd58
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x153ca
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1675d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x16782
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r12, %rdi
leaq 0x1f015(%rip), %rsi     # 0x357ab
leaq 0x1f014(%rip), %rdx     # 0x357b1
callq 0xbdee
movq %rbx, %rdi
movq %r12, %rsi
callq 0xab5a
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x167c9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
decq %r15
addq $-0x10, %rbp
cmpq $0x4, %r15
jg 0x166db
leaq 0x1f2f9(%rip), %rsi     # 0x35ada
leaq 0x8(%rsp), %rdi
movq 0xc0(%rsp), %rdx
callq 0xb692
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xab5a
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1681c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x60(%rsp), %rdx
cmpq 0x40(%rsp), %rdx
je 0x1689c
movl $0x200, %r13d           # imm = 0x200
leaq 0x1e8ff(%rip), %r14     # 0x35134
leaq 0x8(%rsp), %r15
leaq 0x30(%rsp), %r12
cmpq 0x68(%rsp), %rdx
jne 0x16852
movq 0x78(%rsp), %rax
movq -0x8(%rax), %rdx
addq %r13, %rdx
addq $-0x20, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xb692
movq %rbx, %rdi
movq %r15, %rsi
callq 0xab5a
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x16888
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq %r12, %rdi
callq 0x30170
movq 0x60(%rsp), %rdx
cmpq 0x40(%rsp), %rdx
jne 0x1683f
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x168c1
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x30(%rsp), %rdi
callq 0xbb36
jmp 0x16c1b
movq 0x30(%r14), %rax
movq (%rax), %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1ee39(%rip), %rsi     # 0x35720
leaq 0x1ee33(%rip), %rdx     # 0x35721
leaq 0x8(%rsp), %rdi
callq 0xbdee
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xbd58
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x153ca
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1693f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x16956
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x30(%rsp), %rdi
movq %rbx, (%rdi)
leaq 0x1f14c(%rip), %rsi     # 0x35ab1
leaq 0x1f14c(%rip), %rdx     # 0x35ab8
callq 0xbdee
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0xab5a
jmp 0x16c04
movq 0x30(%r14), %rax
movq (%rax), %r15
leaq 0x18(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1ed86(%rip), %rsi     # 0x35720
leaq 0x1ed80(%rip), %rdx     # 0x35721
leaq 0x8(%rsp), %rdi
callq 0xbdee
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xbd58
leaq 0x30(%rsp), %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x153ca
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x169f3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x16a0a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x30(%r14), %rax
movq 0x10(%rax), %r14
leaq 0x8(%rsp), %rdi
movq %rbx, (%rdi)
leaq 0x1edd7(%rip), %rsi     # 0x357f8
leaq 0x1edd1(%rip), %rdx     # 0x357f9
callq 0xbdee
leaq 0x30(%rsp), %rdi
movq %r12, (%rdi)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
callq 0xbd58
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x153ca
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x16a6e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x16a85
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x30(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x1f025(%rip), %rsi     # 0x35ab9
leaq 0x1f027(%rip), %rdx     # 0x35ac2
callq 0xbdee
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0xab5a
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
jne 0x16c0e
jmp 0x16c1b
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1e590(%rip), %rsi     # 0x35060
leaq 0x1e590(%rip), %rdx     # 0x35067
leaq 0x30(%rsp), %rdi
callq 0xbdee
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0xab5a
jmp 0x16c04
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1efc0(%rip), %rsi     # 0x35ac3
leaq 0x1efbf(%rip), %rdx     # 0x35ac9
leaq 0x30(%rsp), %rdi
callq 0xbdee
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0xab5a
jmp 0x16c04
movq 0x30(%r14), %rax
movq (%rax), %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1ebe3(%rip), %rsi     # 0x35720
leaq 0x1ebdd(%rip), %rdx     # 0x35721
leaq 0x8(%rsp), %rdi
callq 0xbdee
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xbd58
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x153ca
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x16b95
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x16bac
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x30(%rsp), %rdi
movq %rbx, (%rdi)
leaq 0x1ef0f(%rip), %rsi     # 0x35aca
leaq 0x1ef11(%rip), %rdx     # 0x35ad3
callq 0xbdee
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0xab5a
jmp 0x16c04
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1eeee(%rip), %rsi     # 0x35ad4
leaq 0x1eeec(%rip), %rdx     # 0x35ad9
leaq 0x30(%rsp), %rdi
callq 0xbdee
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0xab5a
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x16c1b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16cc5
jmp 0x16d1e
jmp 0x16cc5
jmp 0x16d1e
jmp 0x16cdf
jmp 0x16cfb
jmp 0x16d1e
jmp 0x16d7e
jmp 0x16d79
jmp 0x16d79
movq %rax, %r14
jmp 0x16dc2
jmp 0x16cc5
jmp 0x16d1e
jmp 0x16cc5
jmp 0x16d1e
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
jne 0x16cd6
jmp 0x16dcc
jmp 0x16d1e
jmp 0x16c95
jmp 0x16cb1
jmp 0x16d1e
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x16cb4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x16cb4
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x16d0c
jmp 0x16dcc
jmp 0x16d1e
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x16dcc
movq 0x40(%rsp), %rsi
jmp 0x16d11
jmp 0x16d1e
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x16cfe
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x16cfe
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x16dcc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x16dcc
movq %rax, %r14
jmp 0x16dcc
jmp 0x16d7e
jmp 0x16d79
jmp 0x16d79
jmp 0x16d79
jmp 0x16d7e
jmp 0x16d79
movq %rax, %r14
jmp 0x16d56
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x16d56
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x16d9d
movq 0xb0(%rsp), %rsi
jmp 0x16d95
jmp 0x16d79
jmp 0x16d7e
movq %rax, %r14
jmp 0x16d9d
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x16d9d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x16dc2
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x30(%rsp), %rdi
callq 0xbb36
movq %r14, %rdi
callq 0x74f0