// File: martinda3[P]Compiler/src/TCparser.cpp
// Function: toyc::TCparser::Primary()
ASexpression* TCparser::Primary() // DONE with AS
	{
		/* Primary --> ID [ FunctionCall ]
					 | NUMBER
					 | STRING
					 | CHARLITERAL
					 | LPAREN Expression RPAREN
					 | MINUS | NOT Primary */
		enteringDEBUG("Primary");
		ASexpression* operand = NULL;
		TCtoken* t = buff;
		int loc;
		int tok = buff->getTokenType();
		switch (tok)
		{
			case ID:
				operand = new ASsimpleExpr(t);
                if (buff->getTokenType() == ID)
                {
                    loc = symTable->find(buff->getLexeme());
                    if (loc == -1)
                    {
                        reportSEMANTIC_ERROR(scanner,"variable not declared Primanry");
                        exit(EXIT_FAILURE);
                    }
                }
                accept(ID);
                if (buff->getTokenType() == LPAREN){
                    try
                    {
                        ASexpression* arr[] = { FunctionCall() };
                        operand = new ASfuncCall(operand, arr, 1);
                    }
                    catch (int t) { break; }
                    break;
                }
				break;

			case NUMBER:
				operand = new ASsimpleExpr(t);
				accept(NUMBER);
				break;

			case STRING:
				operand = new ASsimpleExpr(t);
				accept(STRING);
				break;

			case CHARLITERAL:
				operand = new ASsimpleExpr(t);
				accept(CHARLITERAL);
				break;

			case LPAREN:
				enteringDEBUG("Primary Additional");
				accept(LPAREN);
				operand = Expression();
				exitingDEBUG("Primary Additional");
				accept(RPAREN);
				break;

			case MINUS:
				enteringDEBUG("Primary Additional");
				accept(MINUS);
				operand = new ASminus(Primary());
				exitingDEBUG("Primary Additional");
				break;

			case NOTEQUAL:
				enteringDEBUG("Primary Additional");
				accept(NOTEQUAL);
				operand = new ASnot(Primary());
				exitingDEBUG("Primary Additional");
				break;

			default:
				throw tok;
		}
		exitingDEBUG("Primary");
		return operand;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x95c0
movq -0x1d0(%rbp), %rdx
leaq 0x20a9c(%rip), %rsi     # 0x33464
leaq -0x28(%rbp), %rdi
callq 0x13550
jmp 0x129d3
leaq -0x28(%rbp), %rdi
callq 0xd790
jmp 0x129de
leaq -0x28(%rbp), %rdi
callq 0x9658
leaq -0x29(%rbp), %rdi
callq 0x93b0
movq -0x1d8(%rbp), %rax
movq $0x0, -0x48(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x8(%rax), %rdi
callq 0x1be60
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
addl $-0x10, %eax
movl %eax, %ecx
movq %rcx, -0x1e0(%rbp)
subl $0xe, %eax
ja 0x1329d
movq -0x1e0(%rbp), %rax
leaq 0x206c7(%rip), %rcx     # 0x33100
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12a65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x9658
leaq -0x29(%rbp), %rdi
callq 0x93b0
jmp 0x13353
movl $0x18, %edi
callq 0x9350
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1e8(%rbp)
movq -0x50(%rbp), %rsi
callq 0x1def0
jmp 0x12a95
movq -0x1d8(%rbp), %rax
movq -0x1e8(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rdi
callq 0x1be60
cmpl $0x18, %eax
jne 0x12c08
movq -0x1d8(%rbp), %rax
leaq 0x32b99(%rip), %rcx     # 0x45660
movq (%rcx), %rcx
movq %rcx, -0x200(%rbp)
movq 0x8(%rax), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x1be70
movq -0x200(%rbp), %rdi
movq -0x1f8(%rbp), %rsi
callq 0x31840
movl %eax, -0x1ec(%rbp)
jmp 0x12b00
movl -0x1ec(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x9658
cmpl $-0x1, -0x54(%rbp)
jne 0x12c06
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x210(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x95c0
movq -0x208(%rbp), %rdx
leaq 0x2091e(%rip), %rsi     # 0x3346c
leaq -0x98(%rbp), %rdi
callq 0x13550
jmp 0x12b5c
movq -0x210(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x1b380
jmp 0x12b71
leaq -0x98(%rbp), %rdi
callq 0x9658
leaq -0x99(%rbp), %rdi
callq 0x93b0
movl $0x1, %edi
callq 0x9410
movq -0x1e8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x9360
jmp 0x13353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x9658
jmp 0x13353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12bf5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x9658
leaq -0x99(%rbp), %rdi
callq 0x93b0
jmp 0x13353
jmp 0x12c08
movq -0x1d8(%rbp), %rdi
movl $0x18, %esi
callq 0xe670
movq -0x1d8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1be60
cmpl $0x1e, %eax
jne 0x12cee
movq -0x1d8(%rbp), %rdi
callq 0x13360
movq %rax, -0x218(%rbp)
jmp 0x12c47
movq -0x218(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl $0xfc0, %edi            # imm = 0xFC0
callq 0x9350
movq %rax, -0x220(%rbp)
jmp 0x12c68
movq -0x220(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
movl $0x1, %ecx
callq 0x1f3a0
jmp 0x12c86
movq -0x220(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x12ce9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12cbe
movq -0x220(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0xfc0, %esi            # imm = 0xFC0
callq 0x9360
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x13353
movq -0x38(%rbp), %rdi
callq 0x9140
movl (%rax), %eax
movl %eax, -0xac(%rbp)
callq 0x9540
jmp 0x132bf
jmp 0x132bf
jmp 0x132bf
movl $0x18, %edi
callq 0x9350
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x228(%rbp)
movq -0x50(%rbp), %rsi
callq 0x1def0
jmp 0x12d15
movq -0x1d8(%rbp), %rdi
movq -0x228(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x10, %esi
callq 0xe670
jmp 0x132bf
movq -0x228(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x9360
jmp 0x13353
movl $0x18, %edi
callq 0x9350
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x230(%rbp)
movq -0x50(%rbp), %rsi
callq 0x1def0
jmp 0x12d7a
movq -0x1d8(%rbp), %rdi
movq -0x230(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1a, %esi
callq 0xe670
jmp 0x132bf
movq -0x230(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x9360
jmp 0x13353
movl $0x18, %edi
callq 0x9350
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x238(%rbp)
movq -0x50(%rbp), %rsi
callq 0x1def0
jmp 0x12ddf
movq -0x1d8(%rbp), %rdi
movq -0x238(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x19, %esi
callq 0xe670
jmp 0x132bf
movq -0x238(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x9360
jmp 0x13353
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x95c0
movq -0x240(%rbp), %rdx
leaq 0x20648(%rip), %rsi     # 0x3348b
leaq -0xd0(%rbp), %rdi
callq 0x13550
jmp 0x12e51
leaq -0xd0(%rbp), %rdi
callq 0xd790
jmp 0x12e5f
leaq -0xd0(%rbp), %rdi
callq 0x9658
leaq -0xd1(%rbp), %rdi
callq 0x93b0
movq -0x1d8(%rbp), %rdi
movl $0x1e, %esi
callq 0xe670
movq -0x1d8(%rbp), %rdi
callq 0xfe60
movq %rax, -0x48(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x95c0
movq -0x248(%rbp), %rdx
leaq 0x205d2(%rip), %rsi     # 0x3348b
leaq -0xf8(%rbp), %rdi
callq 0x13550
jmp 0x12ec7
leaq -0xf8(%rbp), %rdi
callq 0xda50
jmp 0x12ed5
leaq -0xf8(%rbp), %rdi
callq 0x9658
leaq -0xf9(%rbp), %rdi
callq 0x93b0
movq -0x1d8(%rbp), %rdi
movl $0x1f, %esi
callq 0xe670
jmp 0x132bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12f29
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x9658
leaq -0xd1(%rbp), %rdi
callq 0x93b0
jmp 0x13353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12f60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x9658
leaq -0xf9(%rbp), %rdi
callq 0x93b0
jmp 0x13353
leaq -0x121(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x95c0
movq -0x250(%rbp), %rdx
leaq 0x204f9(%rip), %rsi     # 0x3348b
leaq -0x120(%rbp), %rdi
callq 0x13550
jmp 0x12fa0
leaq -0x120(%rbp), %rdi
callq 0xd790
jmp 0x12fae
leaq -0x120(%rbp), %rdi
callq 0x9658
leaq -0x121(%rbp), %rdi
callq 0x93b0
movq -0x1d8(%rbp), %rdi
movl $0x11, %esi
callq 0xe670
movl $0x18, %edi
callq 0x9350
movq -0x1d8(%rbp), %rdi
movq %rax, -0x260(%rbp)
callq 0x12990
movq %rax, -0x258(%rbp)
jmp 0x12ffd
movq -0x258(%rbp), %rsi
movq -0x260(%rbp), %rdi
callq 0x31480
jmp 0x13012
movq -0x260(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x95c0
movq -0x268(%rbp), %rdx
leaq 0x2044d(%rip), %rsi     # 0x3348b
leaq -0x148(%rbp), %rdi
callq 0x13550
jmp 0x1304c
leaq -0x148(%rbp), %rdi
callq 0xda50
jmp 0x1305a
leaq -0x148(%rbp), %rdi
callq 0x9658
leaq -0x149(%rbp), %rdi
callq 0x93b0
jmp 0x132bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1309d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x9658
leaq -0x121(%rbp), %rdi
callq 0x93b0
jmp 0x13353
movq -0x260(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x9360
jmp 0x13353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x130f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x9658
leaq -0x149(%rbp), %rdi
callq 0x93b0
jmp 0x13353
leaq -0x171(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x95c0
movq -0x270(%rbp), %rdx
leaq 0x20363(%rip), %rsi     # 0x3348b
leaq -0x170(%rbp), %rdi
callq 0x13550
jmp 0x13136
leaq -0x170(%rbp), %rdi
callq 0xd790
jmp 0x13144
leaq -0x170(%rbp), %rdi
callq 0x9658
leaq -0x171(%rbp), %rdi
callq 0x93b0
movq -0x1d8(%rbp), %rdi
movl $0x17, %esi
callq 0xe670
movl $0x18, %edi
callq 0x9350
movq -0x1d8(%rbp), %rdi
movq %rax, -0x280(%rbp)
callq 0x12990
movq %rax, -0x278(%rbp)
jmp 0x13193
movq -0x278(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x2d430
jmp 0x131a8
movq -0x280(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x199(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x95c0
movq -0x288(%rbp), %rdx
leaq 0x202b7(%rip), %rsi     # 0x3348b
leaq -0x198(%rbp), %rdi
callq 0x13550
jmp 0x131e2
leaq -0x198(%rbp), %rdi
callq 0xda50
jmp 0x131f0
leaq -0x198(%rbp), %rdi
callq 0x9658
leaq -0x199(%rbp), %rdi
callq 0x93b0
jmp 0x132bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x13233
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x9658
leaq -0x171(%rbp), %rdi
callq 0x93b0
jmp 0x13353
movq -0x280(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x9360
jmp 0x13353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1328c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x9658
leaq -0x199(%rbp), %rdi
callq 0x93b0
jmp 0x13353
movl $0x4, %edi
callq 0x91b0
movq %rax, %rdi
movl -0x58(%rbp), %eax
movl %eax, (%rdi)
movq 0x31ce2(%rip), %rsi     # 0x44f98
xorl %eax, %eax
movl %eax, %edx
callq 0x9580
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x95c0
movq -0x290(%rbp), %rdx
leaq 0x20184(%rip), %rsi     # 0x33464
leaq -0x1c0(%rbp), %rdi
callq 0x13550
jmp 0x132ee
leaq -0x1c0(%rbp), %rdi
callq 0xda50
jmp 0x132fc
leaq -0x1c0(%rbp), %rdi
callq 0x9658
leaq -0x1c1(%rbp), %rdi
callq 0x93b0
movq -0x48(%rbp), %rax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x13347
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x9658
leaq -0x1c1(%rbp), %rdi
callq 0x93b0
movq -0x38(%rbp), %rdi
callq 0x95b0
nopl (%rax)