// File: Danis98[P]PietGen/parse.cpp
// Function: parse_stmt()
void parse_stmt(){
	token t=get_tok();
	NStatement *stmt=new NStatement;
	stmt->cmd=keyword_map[t];
	if(keyword_map[t]==TOK_PROC){
		stmt=new NProcedure;
		if(nested) parse_error("Procedures cannot be nested");
		NStatementList *prev_node=cur_node;
		token id=get_tok();
		if(keyword_map[id]!=TOK_INVALID)
			parse_error("Keywords are not permitted as procedure IDs: "
					+id+" used\n");
		nested=true;
		cur_node=&(((NProcedure*)stmt)->block);
		parse_stmt_list();
		cur_node=prev_node;
		nested=false;
		token end=get_tok();
		if(keyword_map[end]!=TOK_END)
			parse_error("Procedures must be ended with the end keyword");
	}
	else if(keyword_map[t]==TOK_PUSH){
		token v=get_tok();
		int val=to_num(v);
		if(val==-1) parse_error("Only integers can be pushed into the stack: "
					+v+" pushed instead");
		stmt->val=val;
	}
	else if(keyword_map[t]==TOK_IN){
		token io=get_tok();
		if(keyword_map[io]!=TOK_INT && keyword_map[io]!=TOK_CHAR)
			parse_error("Wrong token: "+io);
		stmt->io_type=keyword_map[io];}
	else if(keyword_map[t]==TOK_OUT){
		token io=get_tok();
		if(keyword_map[io]!=TOK_INT && keyword_map[io]!=TOK_CHAR)
			parse_error("Wrong token: "+io);
		stmt->io_type=keyword_map[io];
	}
	else if(keyword_map[t]==TOK_CALL){
		token id=get_tok();
		if(keyword_map[id]!=TOK_INVALID)
			parse_error("Keywords are not permitted as procedure IDs: "
					+id+" used\n");
		stmt->id=id;
	}
	
	cur_node->stmts.push_back(stmt);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
leaq -0x20(%rbp), %rdi
callq 0x4770
movl $0x38, %edi
callq 0x21e0
movq %rax, -0x280(%rbp)
jmp 0x52c7
movq -0x280(%rbp), %rdi
callq 0x6020
movq -0x280(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x8f1b(%rip), %rdi      # 0xe200
leaq -0x20(%rbp), %rsi
callq 0x6060
movq %rax, -0x288(%rbp)
jmp 0x52f7
movq -0x288(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
leaq 0x8ef2(%rip), %rdi      # 0xe200
leaq -0x20(%rbp), %rsi
callq 0x6060
movq %rax, -0x290(%rbp)
jmp 0x5320
movq -0x290(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x561a
movl $0x78, %edi
callq 0x21e0
movq %rax, -0x298(%rbp)
jmp 0x5343
movq -0x298(%rbp), %rdi
callq 0x6140
movq -0x298(%rbp), %rax
movq %rax, -0x28(%rbp)
testb $0x1, 0x8edb(%rip)      # 0xe23c
je 0x53f1
leaq -0x59(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x22f0
movq -0x2a0(%rbp), %rdx
leaq 0x3e11(%rip), %rsi      # 0x9196
leaq -0x58(%rbp), %rdi
callq 0x2230
jmp 0x5390
leaq -0x58(%rbp), %rdi
callq 0x38a0
jmp 0x539b
leaq -0x58(%rbp), %rdi
callq 0x2120
leaq -0x59(%rbp), %rdi
callq 0x2200
jmp 0x53f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5b63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x53e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2120
leaq -0x59(%rbp), %rdi
callq 0x2200
jmp 0x5b63
movq 0x8e38(%rip), %rax      # 0xe230
movq %rax, -0x68(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x4770
jmp 0x540a
leaq 0x8def(%rip), %rdi      # 0xe200
leaq -0x88(%rbp), %rsi
callq 0x6060
movq %rax, -0x2a8(%rbp)
jmp 0x5426
movq -0x2a8(%rbp), %rax
cmpl $0x0, (%rax)
je 0x54de
leaq 0x3d75(%rip), %rsi      # 0x91b2
leaq -0xc8(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x61e0
jmp 0x5452
leaq 0x3d87(%rip), %rdx      # 0x91e0
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x6190
jmp 0x546e
leaq -0xa8(%rbp), %rdi
callq 0x38a0
jmp 0x547c
leaq -0xa8(%rbp), %rdi
callq 0x2120
leaq -0xc8(%rbp), %rdi
callq 0x2120
jmp 0x54de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5609
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x54cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2120
leaq -0xc8(%rbp), %rdi
callq 0x2120
jmp 0x5609
movb $0x1, 0x8d57(%rip)      # 0xe23c
movq -0x28(%rbp), %rax
addq $0x58, %rax
movq %rax, 0x8d3c(%rip)      # 0xe230
callq 0x5b80
jmp 0x54fb
movq -0x68(%rbp), %rax
movq %rax, 0x8d2a(%rip)      # 0xe230
movb $0x0, 0x8d2f(%rip)      # 0xe23c
leaq -0xe8(%rbp), %rdi
callq 0x4770
jmp 0x551b
leaq 0x8cde(%rip), %rdi      # 0xe200
leaq -0xe8(%rbp), %rsi
callq 0x6060
movq %rax, -0x2b0(%rbp)
jmp 0x5537
movq -0x2b0(%rbp), %rax
cmpl $0x2, (%rax)
je 0x55e0
leaq -0x109(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x22f0
movq -0x2b8(%rbp), %rdx
leaq 0x3c7f(%rip), %rsi      # 0x91e7
leaq -0x108(%rbp), %rdi
callq 0x2230
jmp 0x5576
leaq -0x108(%rbp), %rdi
callq 0x38a0
jmp 0x5584
leaq -0x108(%rbp), %rdi
callq 0x2120
leaq -0x109(%rbp), %rdi
callq 0x2200
jmp 0x55e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x55fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x55d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x2120
leaq -0x109(%rbp), %rdi
callq 0x2200
jmp 0x55fd
leaq -0xe8(%rbp), %rdi
callq 0x2120
leaq -0x88(%rbp), %rdi
callq 0x2120
jmp 0x5b3b
leaq -0xe8(%rbp), %rdi
callq 0x2120
leaq -0x88(%rbp), %rdi
callq 0x2120
jmp 0x5b63
leaq 0x8bdf(%rip), %rdi      # 0xe200
leaq -0x20(%rbp), %rsi
callq 0x6060
movq %rax, -0x2c0(%rbp)
jmp 0x5633
movq -0x2c0(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x578a
leaq -0x130(%rbp), %rdi
callq 0x4770
jmp 0x5651
leaq -0x158(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x20d0
jmp 0x5666
leaq -0x158(%rbp), %rdi
callq 0x4680
movl %eax, -0x2c4(%rbp)
jmp 0x567a
leaq -0x158(%rbp), %rdi
callq 0x2120
movl -0x2c4(%rbp), %eax
movl %eax, -0x134(%rbp)
cmpl $-0x1, -0x134(%rbp)
jne 0x575b
leaq 0x3b6f(%rip), %rsi      # 0x9215
leaq -0x198(%rbp), %rdi
leaq -0x130(%rbp), %rdx
callq 0x61e0
jmp 0x56bb
leaq 0x3b80(%rip), %rdx      # 0x9242
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x6190
jmp 0x56d7
leaq -0x178(%rbp), %rdi
callq 0x38a0
jmp 0x56e5
leaq -0x178(%rbp), %rdi
callq 0x2120
leaq -0x198(%rbp), %rdi
callq 0x2120
jmp 0x575b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x2120
jmp 0x5779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x574d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x2120
leaq -0x198(%rbp), %rdi
callq 0x2120
jmp 0x5779
movl -0x134(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
leaq -0x130(%rbp), %rdi
callq 0x2120
jmp 0x5b39
leaq -0x130(%rbp), %rdi
callq 0x2120
jmp 0x5b63
leaq 0x8a6f(%rip), %rdi      # 0xe200
leaq -0x20(%rbp), %rsi
callq 0x6060
movq %rax, -0x2d0(%rbp)
jmp 0x57a3
movq -0x2d0(%rbp), %rax
cmpl $0x10, (%rax)
jne 0x58c3
leaq -0x1b8(%rbp), %rdi
callq 0x4770
jmp 0x57c1
leaq 0x8a38(%rip), %rdi      # 0xe200
leaq -0x1b8(%rbp), %rsi
callq 0x6060
movq %rax, -0x2d8(%rbp)
jmp 0x57dd
movq -0x2d8(%rbp), %rax
cmpl $0x12, (%rax)
je 0x5875
leaq 0x8a0c(%rip), %rdi      # 0xe200
leaq -0x1b8(%rbp), %rsi
callq 0x6060
movq %rax, -0x2e0(%rbp)
jmp 0x5809
movq -0x2e0(%rbp), %rax
cmpl $0x13, (%rax)
je 0x5875
leaq 0x3a36(%rip), %rsi      # 0x9252
leaq -0x1d8(%rbp), %rdi
leaq -0x1b8(%rbp), %rdx
callq 0x61e0
jmp 0x5831
leaq -0x1d8(%rbp), %rdi
callq 0x38a0
jmp 0x583f
leaq -0x1d8(%rbp), %rdi
callq 0x2120
jmp 0x5875
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x58b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x2120
jmp 0x58b2
leaq 0x8984(%rip), %rdi      # 0xe200
leaq -0x1b8(%rbp), %rsi
callq 0x6060
movq %rax, -0x2e8(%rbp)
jmp 0x5891
movq -0x2e8(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
leaq -0x1b8(%rbp), %rdi
callq 0x2120
jmp 0x5b37
leaq -0x1b8(%rbp), %rdi
callq 0x2120
jmp 0x5b63
leaq 0x8936(%rip), %rdi      # 0xe200
leaq -0x20(%rbp), %rsi
callq 0x6060
movq %rax, -0x2f0(%rbp)
jmp 0x58dc
movq -0x2f0(%rbp), %rax
cmpl $0x11, (%rax)
jne 0x59fc
leaq -0x1f8(%rbp), %rdi
callq 0x4770
jmp 0x58fa
leaq 0x88ff(%rip), %rdi      # 0xe200
leaq -0x1f8(%rbp), %rsi
callq 0x6060
movq %rax, -0x2f8(%rbp)
jmp 0x5916
movq -0x2f8(%rbp), %rax
cmpl $0x12, (%rax)
je 0x59ae
leaq 0x88d3(%rip), %rdi      # 0xe200
leaq -0x1f8(%rbp), %rsi
callq 0x6060
movq %rax, -0x300(%rbp)
jmp 0x5942
movq -0x300(%rbp), %rax
cmpl $0x13, (%rax)
je 0x59ae
leaq 0x38fd(%rip), %rsi      # 0x9252
leaq -0x218(%rbp), %rdi
leaq -0x1f8(%rbp), %rdx
callq 0x61e0
jmp 0x596a
leaq -0x218(%rbp), %rdi
callq 0x38a0
jmp 0x5978
leaq -0x218(%rbp), %rdi
callq 0x2120
jmp 0x59ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x59eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2120
jmp 0x59eb
leaq 0x884b(%rip), %rdi      # 0xe200
leaq -0x1f8(%rbp), %rsi
callq 0x6060
movq %rax, -0x308(%rbp)
jmp 0x59ca
movq -0x308(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
leaq -0x1f8(%rbp), %rdi
callq 0x2120
jmp 0x5b35
leaq -0x1f8(%rbp), %rdi
callq 0x2120
jmp 0x5b63
leaq 0x87fd(%rip), %rdi      # 0xe200
leaq -0x20(%rbp), %rsi
callq 0x6060
movq %rax, -0x310(%rbp)
jmp 0x5a15
movq -0x310(%rbp), %rax
cmpl $0x14, (%rax)
jne 0x5b33
leaq -0x238(%rbp), %rdi
callq 0x4770
jmp 0x5a33
leaq 0x87c6(%rip), %rdi      # 0xe200
leaq -0x238(%rbp), %rsi
callq 0x6060
movq %rax, -0x318(%rbp)
jmp 0x5a4f
movq -0x318(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5b01
leaq 0x374c(%rip), %rsi      # 0x91b2
leaq -0x278(%rbp), %rdi
leaq -0x238(%rbp), %rdx
callq 0x61e0
jmp 0x5a7b
leaq 0x375e(%rip), %rdx      # 0x91e0
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x6190
jmp 0x5a97
leaq -0x258(%rbp), %rdi
callq 0x38a0
jmp 0x5aa5
leaq -0x258(%rbp), %rdi
callq 0x2120
leaq -0x278(%rbp), %rdi
callq 0x2120
jmp 0x5b01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5b25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5af3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x2120
leaq -0x278(%rbp), %rdi
callq 0x2120
jmp 0x5b25
movq -0x28(%rbp), %rdi
addq $0x18, %rdi
leaq -0x238(%rbp), %rsi
callq 0x2040
jmp 0x5b17
leaq -0x238(%rbp), %rdi
callq 0x2120
jmp 0x5b33
leaq -0x238(%rbp), %rdi
callq 0x2120
jmp 0x5b63
jmp 0x5b35
jmp 0x5b37
jmp 0x5b39
jmp 0x5b3b
movq 0x86ee(%rip), %rdi      # 0xe230
addq $0x8, %rdi
leaq -0x28(%rbp), %rsi
callq 0x62f0
jmp 0x5b51
leaq -0x20(%rbp), %rdi
callq 0x2120
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x2120
movq -0x30(%rbp), %rdi
callq 0x22e0
nopw %cs:(%rax,%rax)