// File: /workspace/github_c_makefile_star2_O0/anuwu[P]ERPLAG-Compiler/codegen.c
// Function: getValue
void getValue (moduleST *lst, varST *vst)
{		
	int rspAlign ;
	df |= 1 << inputInt ;
	char promptReg[5] ;

	#if defined __linux__ || defined __MACH__
		strcpy (promptReg, "RDI") ;
	#endif
	#ifdef _WIN64
		strcpy (promptReg, "RCX") ;
	#endif

	if (vst->datatype == TK_INTEGER || vst->datatype == TK_BOOLEAN)
	{
		if (vst->datatype == TK_INTEGER)
		{
			df |= 1 << inputIntPrompt ;
			codePrint ("\n\t\tMOV %s, @inputIntPrompt", promptReg) ;
		}
		else if (vst->datatype == TK_BOOLEAN)
		{
			df |= 1 << inputBoolPrompt ;
			codePrint ("\n\t\tMOV %s, @inputBoolPrompt", promptReg) ;
		}
		codeComment (9, "get_value") ;


		tf |= 1 << getValuePrimitive ;
		codePrint ("\t\tMOV RBX, -%d\n", vst->offset) ;
		codePrint ("\t\tCALL @getValuePrimitive\n\n") ;		
 	}
	else // Array type
	{	
		if (vst->arrayIndices->type == TK_INTEGER)
		{
			df |= 1 << inputIntArrPrompt ;
			codePrint ("\t\tMOV %s, @inputIntArrPrompt\n", promptReg) ;
		}
		else
		{
			df |= 1 << inputBoolArrPrompt ;
			codePrint ("\t\tMOV %s, @inputBoolArrPrompt\n", promptReg) ;
		}

		tf |= 1 << printGetArrPrompt ;
		tf |= 1 << getArr ;

		#if defined __linux__ || defined __MACH__
			loadRegLeftLim (vst, "BX") ;
			loadRegRightLim (vst, "CX") ;
		#endif
		#ifdef _WIN64
			loadRegLeftLim (vst, "SI") ;
			loadRegRightLim (vst, "DI") ;
		#endif
		codePrint ("\t\tCALL @printGetArrPrompt\n\n") ;

		#if defined __linux__ || defined __MACH__		
			codePrint ("\t\tMOV DX, CX\n") ;
			codePrint ("\t\tSUB DX, BX\n") ;
			codePrint ("\t\tADD DX, 1\n") ;
			codePrint ("\t\tADD DX, DX\n") ;
			codePrint ("\t\tMOVSX RDX, DX\n") ;
		#endif
		#ifdef _WIN64
			codePrint ("\t\tMOV BX, DI\n") ;
			codePrint ("\t\tSUB BX, SI\n") ;
			codePrint ("\t\tADD BX, 1\n") ;
			codePrint ("\t\tADD BX, BX\n") ;
			codePrint ("\t\tMOVSX RBX, BX\n") ;
		#endif

		loadArrBase (vst, "RDI") ;
		codePrint ("\t\tCALL @getArr\n\n") ;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl 0x1a836(%rip), %eax     # 0x1d34c
orl $0x100000, %eax         # imm = 0x100000
movl %eax, 0x1a82b(%rip)     # 0x1d34c
leaq -0x19(%rbp), %rdi
leaq 0x12959(%rip), %rsi     # 0x15485
callq 0x1040
movq -0x10(%rbp), %rax
cmpl $0x37, 0x8(%rax)
je 0x2b49
movq -0x10(%rbp), %rax
cmpl $0x39, 0x8(%rax)
jne 0x2c19
movq -0x10(%rbp), %rax
cmpl $0x37, 0x8(%rax)
jne 0x2b82
movl 0x1a7f3(%rip), %eax     # 0x1d34c
orl $0x4000, %eax           # imm = 0x4000
movl %eax, 0x1a7e8(%rip)     # 0x1d34c
leaq 0x1a7bd(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq -0x19(%rbp), %rdx
leaq 0x12bc7(%rip), %rsi     # 0x15740
movb $0x0, %al
callq 0x10d0
jmp 0x2bbb
movq -0x10(%rbp), %rax
cmpl $0x39, 0x8(%rax)
jne 0x2bb9
movl 0x1a7ba(%rip), %eax     # 0x1d34c
orl $0x8000, %eax           # imm = 0x8000
movl %eax, 0x1a7af(%rip)     # 0x1d34c
leaq 0x1a784(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq -0x19(%rbp), %rdx
leaq 0x12ba9(%rip), %rsi     # 0x1575b
movb $0x0, %al
callq 0x10d0
jmp 0x2bbb
movl $0x9, %edi
leaq 0x12bb0(%rip), %rsi     # 0x15777
callq 0x16c0
movl 0x1a776(%rip), %eax     # 0x1d348
orl $0x80, %eax
movl %eax, 0x1a76b(%rip)     # 0x1d348
leaq 0x1a744(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %edx
leaq 0x12b8c(%rip), %rsi     # 0x15781
movb $0x0, %al
callq 0x10d0
leaq 0x1a725(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12b84(%rip), %rsi     # 0x15791
movb $0x0, %al
callq 0x10d0
jmp 0x2d7a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x37, (%rax)
jne 0x2c55
movl 0x1a720(%rip), %eax     # 0x1d34c
orl $0x10000, %eax          # imm = 0x10000
movl %eax, 0x1a715(%rip)     # 0x1d34c
leaq 0x1a6ea(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq -0x19(%rbp), %rdx
leaq 0x12b61(%rip), %rsi     # 0x157ad
movb $0x0, %al
callq 0x10d0
jmp 0x2c82
movl 0x1a6f1(%rip), %eax     # 0x1d34c
orl $0x20000, %eax          # imm = 0x20000
movl %eax, 0x1a6e6(%rip)     # 0x1d34c
leaq 0x1a6bb(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq -0x19(%rbp), %rdx
leaq 0x12b50(%rip), %rsi     # 0x157cb
movb $0x0, %al
callq 0x10d0
movl 0x1a6c0(%rip), %eax     # 0x1d348
orl $0x40, %eax
movl %eax, 0x1a6b7(%rip)     # 0x1d348
movl 0x1a6b1(%rip), %eax     # 0x1d348
orl $0x100, %eax            # imm = 0x100
movl %eax, 0x1a6a6(%rip)     # 0x1d348
movq -0x10(%rbp), %rdi
leaq 0x12c23(%rip), %rsi     # 0x158d0
callq 0x17e0
movq -0x10(%rbp), %rdi
leaq 0x12fcf(%rip), %rsi     # 0x15c8c
callq 0x1870
leaq 0x1a65f(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12b17(%rip), %rsi     # 0x157ea
movb $0x0, %al
callq 0x10d0
leaq 0x1a647(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12b1b(%rip), %rsi     # 0x15806
movb $0x0, %al
callq 0x10d0
leaq 0x1a62f(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12b11(%rip), %rsi     # 0x15814
movb $0x0, %al
callq 0x10d0
leaq 0x1a617(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12959(%rip), %rsi     # 0x15674
movb $0x0, %al
callq 0x10d0
leaq 0x1a5ff(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1294e(%rip), %rsi     # 0x15681
movb $0x0, %al
callq 0x10d0
leaq 0x1a5e7(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12ad7(%rip), %rsi     # 0x15822
movb $0x0, %al
callq 0x10d0
movq -0x10(%rbp), %rdi
leaq 0x12728(%rip), %rsi     # 0x15485
callq 0x1900
leaq 0x1a5bf(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12ac0(%rip), %rsi     # 0x15833
movb $0x0, %al
callq 0x10d0
addq $0x20, %rsp
popq %rbp
retq