// File: /workspace/github_c_makefile_star2_O1/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movl 0x15e96(%rip), %eax     # 0x1836c
movl %eax, %ecx
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x15e88(%rip)     # 0x1836c
movl $0x494452, -0x18(%rbp)  # imm = 0x494452
movl 0x8(%rsi), %ecx
cmpl $0x37, %ecx
je 0x2506
cmpl $0x39, %ecx
jne 0x256f
leaq 0xe0e6(%rip), %rsi      # 0x105e5
movl $0x108000, %ecx         # imm = 0x108000
jmp 0x2512
leaq 0xe0bd(%rip), %rsi      # 0x105ca
movl $0x104000, %ecx         # imm = 0x104000
orl %ecx, %eax
movl %eax, 0x15e52(%rip)     # 0x1836c
leaq 0x15e27(%rip), %r14     # 0x18348
movq (%r14), %rdi
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
callq 0x1100
leaq 0xe0cb(%rip), %rsi      # 0x10601
movl $0x9, %edi
callq 0x153a
orb $-0x80, 0x15e21(%rip)   # 0x18368
movq (%r14), %rdi
movl 0x1c(%rbx), %edx
leaq 0xe0b7(%rip), %rsi      # 0x1060b
xorl %eax, %eax
callq 0x1100
movq (%r14), %rcx
leaq 0xe0b6(%rip), %rdi      # 0x1061b
movl $0x1b, %esi
jmp 0x268f
movq 0x10(%rbx), %rcx
xorl %edx, %edx
cmpl $0x37, (%rcx)
setne %dl
leaq 0xe0b5(%rip), %rcx      # 0x10637
leaq 0xe0cc(%rip), %rsi      # 0x10655
cmoveq %rcx, %rsi
shll $0x10, %edx
addl $0x110000, %edx         # imm = 0x110000
orl %edx, %eax
movl %eax, 0x15dce(%rip)     # 0x1836c
leaq 0x15da3(%rip), %r14     # 0x18348
movq (%r14), %rdi
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
callq 0x1100
orl $0x140, 0x15dab(%rip)   # imm = 0x140
leaq 0xe196(%rip), %rsi      # 0x1075a
movq %rbx, %rdi
callq 0x160f
leaq 0xe543(%rip), %rsi      # 0x10b16
movq %rbx, %rdi
callq 0x1678
movq (%r14), %rcx
leaq 0xe08f(%rip), %rdi      # 0x10674
movl $0x1b, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xe092(%rip), %rdi      # 0x10690
movl $0xd, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xe087(%rip), %rdi      # 0x1069e
movl $0xd, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xdece(%rip), %rdi      # 0x104fe
movl $0xc, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xdec2(%rip), %rdi      # 0x1050b
movl $0xd, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xe04a(%rip), %rdi      # 0x106ac
movl $0x10, %esi
movl $0x1, %edx
callq 0x1170
leaq 0xdc97(%rip), %rsi      # 0x1030f
movq %rbx, %rdi
callq 0x16e1
movq (%r14), %rcx
leaq 0xe033(%rip), %rdi      # 0x106bd
movl $0x10, %esi
movl $0x1, %edx
callq 0x1170
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq