// File: /workspace/github_c_makefile_star2_O0/anuwu[P]ERPLAG-Compiler/codegen.c
// Function: expr
void expr (astNode *node, moduleST *lst, int singleAssign)
{
	if (node->child == NULL || node->child->next == NULL)
	{
		exprLeaf (node, lst, singleAssign) ;
		return ;
	}

	expr (node->child->next, lst, singleAssign) ;
	expr (node->child, lst, singleAssign); 
	codePrint ("\t\tPOP AX\n");
	codePrint ("\t\tPOP BX\n");

	switch (node->id)
	{
		case TK_PLUS :
			codePrint ("\t\tADD AX,BX\n");
			break ;

		case TK_MINUS :
			codePrint ("\t\tSUB AX,BX\n");
			break ;

		case TK_MUL :
			codePrint ("\t\tIMUL BX\n");
			break ;

		case TK_DIV :
		{
			codePrint ("\t\tCMP BX, 0\n") ;

			tf |= 1 << divZeroERROR ;
			int lab = get_label (LABEL_DIV_ZERO) ;
			codePrint ("\t\tJNE @DIV_ZERO%d\n", lab) ;
			codePrint ("\t\tCALL @divZeroERROR\n") ;

			codePrint ("\n\t@DIV_ZERO%d:\n", lab) ;
			codePrint ("\t\tCWD\n") ;
			codePrint ("\t\tIDIV BX\n");
			break ;
		}

		case TK_LT : case TK_GT : case TK_LE : case TK_GE : case TK_NE : case TK_EQ :
		{
			codePrint ("\t\tCMP AX,BX\n");

			switch (node->id)
			{
				case TK_LT :
					codePrint ("\t\tSETL AL\n");
					break ;
				case TK_GT :
					codePrint ("\t\tSETG AL\n");
					break ;
				case TK_LE :
					codePrint ("\t\tSETLE AL\n");
					break ;
				case TK_GE :
					codePrint ("\t\tSETGE AL\n");
					break ;
				case TK_NE :
					codePrint ("\t\tSETNE AL\n");
					break ;
				case TK_EQ :
					codePrint ("\t\tSETE AL\n");
					break ;
			}
			codePrint ("\t\tMOVSX AX, AL\n") ;

			break ;
		}

		case TK_AND : case TK_OR :
		{
			if (node->id == TK_AND)
				codePrint ("\t\tAND AX, BX\n");
			else
				codePrint ("\t\tOR AX, BX\n");

			break ;
		}
	}

	codePrint ("\t\tPUSH AX\n") ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x231d
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
cmpq $0x0, 0x38(%rax)
jne 0x2332
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x20b0
jmp 0x261d
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x22f0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x22f0
leaq 0x1afc3(%rip), %rax     # 0x1d328
movq %rax, -0x30(%rbp)
movq (%rax), %rdi
leaq 0x13116(%rip), %rsi     # 0x15489
xorl %eax, %eax
movb %al, -0x21(%rbp)
callq 0x10d0
movq -0x30(%rbp), %rcx
movb -0x21(%rbp), %al
movq (%rcx), %rdi
leaq 0x13176(%rip), %rsi     # 0x15504
callq 0x10d0
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl $-0x4e, %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x12, %eax
ja 0x2605
movq -0x20(%rbp), %rax
leaq 0x12dde(%rip), %rcx     # 0x15194
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1af62(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1313e(%rip), %rsi     # 0x1550e
movb $0x0, %al
callq 0x10d0
jmp 0x2605
leaq 0x1af45(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1312e(%rip), %rsi     # 0x1551b
movb $0x0, %al
callq 0x10d0
jmp 0x2605
leaq 0x1af28(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1311e(%rip), %rsi     # 0x15528
movb $0x0, %al
callq 0x10d0
jmp 0x2605
leaq 0x1af0b(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1310c(%rip), %rsi     # 0x15533
movb $0x0, %al
callq 0x10d0
movl 0x1af14(%rip), %eax     # 0x1d348
orl $0x20, %eax
movl %eax, 0x1af0b(%rip)     # 0x1d348
movl $0x3, %edi
callq 0x1600
movl %eax, -0x18(%rbp)
leaq 0x1aed7(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x18(%rbp), %edx
leaq 0x130e2(%rip), %rsi     # 0x15540
movb $0x0, %al
callq 0x10d0
leaq 0x1aebc(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x130dd(%rip), %rsi     # 0x15553
movb $0x0, %al
callq 0x10d0
leaq 0x1aea4(%rip), %rax     # 0x1d328
movq (%rax), %rdi
movl -0x18(%rbp), %edx
leaq 0x130d8(%rip), %rsi     # 0x15569
movb $0x0, %al
callq 0x10d0
leaq 0x1ae89(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x130d0(%rip), %rsi     # 0x15579
movb $0x0, %al
callq 0x10d0
leaq 0x1ae71(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x130bf(%rip), %rsi     # 0x15580
movb $0x0, %al
callq 0x10d0
jmp 0x2605
leaq 0x1ae54(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x130ad(%rip), %rsi     # 0x1558b
xorl %eax, %eax
callq 0x10d0
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl $-0x5b, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x5, %eax
ja 0x25ae
movq -0x38(%rbp), %rax
leaq 0x12cd8(%rip), %rcx     # 0x151e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1ae10(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x13076(%rip), %rsi     # 0x15598
movb $0x0, %al
callq 0x10d0
jmp 0x25ae
leaq 0x1adf3(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x13064(%rip), %rsi     # 0x155a3
movb $0x0, %al
callq 0x10d0
jmp 0x25ae
leaq 0x1add9(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x13055(%rip), %rsi     # 0x155ae
movb $0x0, %al
callq 0x10d0
jmp 0x25ae
leaq 0x1adbf(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x13047(%rip), %rsi     # 0x155ba
movb $0x0, %al
callq 0x10d0
jmp 0x25ae
leaq 0x1ada5(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x13039(%rip), %rsi     # 0x155c6
movb $0x0, %al
callq 0x10d0
jmp 0x25ae
leaq 0x1ad8b(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1302b(%rip), %rsi     # 0x155d2
movb $0x0, %al
callq 0x10d0
leaq 0x1ad73(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1301e(%rip), %rsi     # 0x155dd
movb $0x0, %al
callq 0x10d0
jmp 0x2605
movq -0x8(%rbp), %rax
cmpl $0x4e, (%rax)
jne 0x25eb
leaq 0x1ad50(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x1300b(%rip), %rsi     # 0x155ed
movb $0x0, %al
callq 0x10d0
jmp 0x2603
leaq 0x1ad36(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12fff(%rip), %rsi     # 0x155fb
movb $0x0, %al
callq 0x10d0
jmp 0x2605
leaq 0x1ad1c(%rip), %rax     # 0x1d328
movq (%rax), %rdi
leaq 0x12ff2(%rip), %rsi     # 0x15608
movb $0x0, %al
callq 0x10d0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)