// File: /workspace/github_cpp_makefile_star2_O3/exrd[P]neteruhsp/neteruhsp/neteruhsp.cc
// Function: neteruhsp::evaluate_ast_node(neteruhsp::ast_node_t*, neteruhsp::value_stack_t*)
bool evaluate_ast_node( ast_node_t* n, value_stack_t* stack )
{
	switch( n->tag_ )
	{
		case NODE_EMPTY: break;

		case NODE_EXPRESSION:
			assert( n->left_ != nullptr );
			return evaluate_ast_node( n->left_, stack );

		case NODE_BOR:
		case NODE_BAND:
		case NODE_BXOR:
		case NODE_EQ:
		case NODE_NEQ:
		case NODE_GT:
		case NODE_GTOE:
		case NODE_LT:
		case NODE_LTOE:
		case NODE_ADD:
		case NODE_SUB:
		case NODE_MUL:
		case NODE_DIV:
		case NODE_MOD:
		{
			assert( n->left_ != nullptr );
			if ( !evaluate_ast_node( n->left_, stack ) )
			{
				return false;
			}
			assert( n->right_ != nullptr );
			if ( !evaluate_ast_node( n->right_, stack ) )
			{
				return false;
			}

			if ( stack->top_ < 2 )
			{
				print_error( "式評価：二項演算時に対象の値が存在してません：\n" );
				return false;
			}

			auto* left = stack_peek( stack, -2 );
			auto* right = stack_peek( stack, -1 );
			value_isolate( *left );

			switch( n->tag_ )
			{
				case NODE_BOR:		value_bor( left, *right ); break;
				case NODE_BAND:		value_band( left, *right ); break;
				case NODE_BXOR:		value_bxor( left, *right ); break;
				case NODE_EQ:		value_eq( left, *right ); break;
				case NODE_NEQ:		value_neq( left, *right ); break;
				case NODE_GT:		value_gt( left, *right ); break;
				case NODE_GTOE:		value_gtoe( left, *right ); break;
				case NODE_LT:		value_lt( left, *right ); break;
				case NODE_LTOE:		value_ltoe( left, *right ); break;
				case NODE_ADD:		value_add( left, *right ); break;
				case NODE_SUB:		value_sub( left, *right ); break;
				case NODE_MUL:		value_mul( left, *right ); break;
				case NODE_DIV:		value_div( left, *right ); break;
				case NODE_MOD:		value_mod( left, *right ); break;
				default: assert( false ); break;
			}

			stack_pop( stack, 1 );
			break;
		}

		case NODE_UNARY_MINUS:
		{
			assert( n->left_ != nullptr );
			if ( !evaluate_ast_node( n->left_, stack ) )
			{
				return false;
			}
			if ( stack->top_ < 1 )
			{
				print_error( "式評価：単項演算時に対象の値が存在してません：\n" );
				return false;
			}
			auto* const v = stack_peek( stack, -1 );
			value_isolate( *v );
			value_unary_minus( v );
			break;
		}

		case NODE_PRIMITIVE_VALUE:
		{
			switch( n->token_->tag_ )
			{
				case TOKEN_INTEGER:	stack_push( stack, create_value( atoi( n->token_->content_ ) ) ); break;
				case TOKEN_REAL:	stack_push( stack, create_value( atof( n->token_->content_ ) ) ); break;
				case TOKEN_STRING:	stack_push( stack, create_value( n->token_->content_ ) ); break;
				default: assert( false ); break;
			}
			break;
		}
		default:
			print_error( "式評価：サポートされてないノードの呼び出し（%s）@@ %d行目\n", n->token_->content_, n->token_->appear_line_ + 1 );
			return false;
	}
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2bd7(%rip), %rax      # 0xc5d8
movl (%r14), %ecx
cmpq $0x1f, %rcx
ja 0x9c5c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0x9a01
leaq 0x6072(%rip), %rdi      # 0xfa99
leaq 0x2e6b(%rip), %rsi      # 0xc899
leaq 0x6078(%rip), %rcx      # 0xfaad
movl $0x176d, %edx           # imm = 0x176D
callq 0x20e0
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x9c84
movq %rbx, %rsi
callq 0x99ec
testb %al, %al
je 0x9b4d
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x9ca3
movq %rbx, %rsi
callq 0x99ec
testb %al, %al
je 0x9b4d
cmpl $0x1, 0x8(%rbx)
jle 0x9c4a
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7b11
movq %rax, %r12
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7b11
movq %rax, %r15
movq %r12, %rdi
callq 0x4d52
movl (%r14), %eax
addl $-0x10, %eax
cmpl $0xd, %eax
ja 0x9d00
leaq 0x2b97(%rip), %rcx      # 0xc658
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
movq %r15, %rsi
callq 0x71fe
jmp 0x9c2d
movq 0x8(%r14), %rax
movl (%rax), %ecx
cmpl $0xb, %ecx
je 0x9b64
cmpl $0xa, %ecx
je 0x9b54
cmpl $0x9, %ecx
jne 0x9ce1
movq 0x8(%rax), %rdi
callq 0x2250
movl %eax, %edi
callq 0x6cf7
jmp 0x9b6d
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x9cc2
movq %rbx, %rsi
callq 0x99ec
testb %al, %al
je 0x9b4d
cmpl $0x0, 0x8(%rbx)
jle 0x9c7b
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7b11
movq %rax, %rbx
movq %rax, %rdi
callq 0x4d52
movq %rbx, %rdi
callq 0x7944
jmp 0x9c3a
xorl %ebx, %ebx
jmp 0x9c3c
movq 0x8(%rax), %rdi
callq 0x21c0
callq 0x6d32
jmp 0x9b6d
movq 0x8(%rax), %rdi
callq 0x6d77
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7ab5
jmp 0x9c3a
movq %r12, %rdi
movq %r15, %rsi
callq 0x779e
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x73e8
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x780b
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x7675
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x72cc
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x7333
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x7589
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x7265
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x749d
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x78a0
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x7513
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x7735
jmp 0x9c2d
movq %r12, %rdi
movq %r15, %rsi
callq 0x75ff
movl $0x1, %esi
movq %rbx, %rdi
callq 0x7a28
movb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x5eb2(%rip), %rdi      # 0xfb03
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2318
jmp 0x9c3c
movq 0x8(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x18(%rax), %edx
incl %edx
leaq 0x5f21(%rip), %rdi      # 0xfb91
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2318
jmp 0x9c3c
leaq 0x5ec8(%rip), %rdi      # 0xfb4a
jmp 0x9c51
leaq 0x5e0e(%rip), %rdi      # 0xfa99
leaq 0x2c07(%rip), %rsi      # 0xc899
leaq 0x5e14(%rip), %rcx      # 0xfaad
movl $0x177f, %edx           # imm = 0x177F
callq 0x20e0
leaq 0x5e44(%rip), %rdi      # 0xfaee
leaq 0x2be8(%rip), %rsi      # 0xc899
leaq 0x5df5(%rip), %rcx      # 0xfaad
movl $0x1784, %edx           # imm = 0x1784
callq 0x20e0
leaq 0x5dd0(%rip), %rdi      # 0xfa99
leaq 0x2bc9(%rip), %rsi      # 0xc899
leaq 0x5dd6(%rip), %rcx      # 0xfaad
movl $0x17ad, %edx           # imm = 0x17AD
callq 0x20e0
leaq 0x3a9d(%rip), %rdi      # 0xd785
leaq 0x2baa(%rip), %rsi      # 0xc899
leaq 0x5db7(%rip), %rcx      # 0xfaad
movl $0x17c4, %edx           # imm = 0x17C4
callq 0x20e0
leaq 0x3a7e(%rip), %rdi      # 0xd785
leaq 0x2b8b(%rip), %rsi      # 0xc899
leaq 0x5d98(%rip), %rcx      # 0xfaad
movl $0x17a4, %edx           # imm = 0x17A4
callq 0x20e0