// File: /workspace/github_c_makefile_star2_O3/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 0x14ea2(%rip), %eax     # 0x1736c
movl %eax, %ecx
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x14e94(%rip)     # 0x1736c
movl $0x494452, -0x18(%rbp)  # imm = 0x494452
movl 0x8(%rsi), %ecx
cmpl $0x37, %ecx
je 0x24fa
cmpl $0x39, %ecx
jne 0x2563
leaq 0xd0f2(%rip), %rsi      # 0xf5e5
movl $0x108000, %ecx         # imm = 0x108000
jmp 0x2506
leaq 0xd0c9(%rip), %rsi      # 0xf5ca
movl $0x104000, %ecx         # imm = 0x104000
orl %ecx, %eax
movl %eax, 0x14e5e(%rip)     # 0x1736c
leaq 0x14e33(%rip), %r14     # 0x17348
movq (%r14), %rdi
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
callq 0x1100
leaq 0xd0d7(%rip), %rsi      # 0xf601
movl $0x9, %edi
callq 0x152e
orb $-0x80, 0x14e2d(%rip)   # 0x17368
movq (%r14), %rdi
movl 0x1c(%rbx), %edx
leaq 0xd0c3(%rip), %rsi      # 0xf60b
xorl %eax, %eax
callq 0x1100
movq (%r14), %rcx
leaq 0xd0c2(%rip), %rdi      # 0xf61b
movl $0x1b, %esi
jmp 0x2683
movq 0x10(%rbx), %rcx
xorl %edx, %edx
cmpl $0x37, (%rcx)
setne %dl
leaq 0xd0c1(%rip), %rcx      # 0xf637
leaq 0xd0d8(%rip), %rsi      # 0xf655
cmoveq %rcx, %rsi
shll $0x10, %edx
addl $0x110000, %edx         # imm = 0x110000
orl %edx, %eax
movl %eax, 0x14dda(%rip)     # 0x1736c
leaq 0x14daf(%rip), %r14     # 0x17348
movq (%r14), %rdi
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
callq 0x1100
orl $0x140, 0x14db7(%rip)   # imm = 0x140
leaq 0xd1a2(%rip), %rsi      # 0xf75a
movq %rbx, %rdi
callq 0x1603
leaq 0xd54f(%rip), %rsi      # 0xfb16
movq %rbx, %rdi
callq 0x166c
movq (%r14), %rcx
leaq 0xd09b(%rip), %rdi      # 0xf674
movl $0x1b, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xd09e(%rip), %rdi      # 0xf690
movl $0xd, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xd093(%rip), %rdi      # 0xf69e
movl $0xd, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xceda(%rip), %rdi      # 0xf4fe
movl $0xc, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xcece(%rip), %rdi      # 0xf50b
movl $0xd, %esi
movl $0x1, %edx
callq 0x1170
movq (%r14), %rcx
leaq 0xd056(%rip), %rdi      # 0xf6ac
movl $0x10, %esi
movl $0x1, %edx
callq 0x1170
leaq 0xcca3(%rip), %rsi      # 0xf30f
movq %rbx, %rdi
callq 0x16d5
movq (%r14), %rcx
leaq 0xd03f(%rip), %rdi      # 0xf6bd
movl $0x10, %esi
movl $0x1, %edx
callq 0x1170
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq