// File: /workspace/github_cpp_makefile_star2_O1/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 0x36f7(%rip), %rax      # 0xd61c
movl (%r14), %ecx
cmpq $0x1f, %rcx
ja 0xa180
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0x9f25
leaq 0x6c54(%rip), %rdi      # 0x10b9f
leaq 0x3987(%rip), %rsi      # 0xd8d9
leaq 0x6c5a(%rip), %rcx      # 0x10bb3
movl $0x176d, %edx           # imm = 0x176D
callq 0x20f0
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0xa1a8
movq %rbx, %rsi
callq 0x9f10
testb %al, %al
je 0xa071
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xa1c7
movq %rbx, %rsi
callq 0x9f10
testb %al, %al
je 0xa071
cmpl $0x1, 0x8(%rbx)
jle 0xa16e
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7f19
movq %rax, %r12
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7f19
movq %rax, %r15
movq %r12, %rdi
callq 0x5109
movl (%r14), %eax
addl $-0x10, %eax
cmpl $0xd, %eax
ja 0xa224
leaq 0x36b7(%rip), %rcx      # 0xd69c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
movq %r15, %rsi
callq 0x7600
jmp 0xa151
movq 0x8(%r14), %rax
movl (%rax), %ecx
cmpl $0xb, %ecx
je 0xa088
cmpl $0xa, %ecx
je 0xa078
cmpl $0x9, %ecx
jne 0xa205
movq 0x8(%rax), %rdi
callq 0x2250
movl %eax, %edi
callq 0x70f7
jmp 0xa091
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0xa1e6
movq %rbx, %rsi
callq 0x9f10
testb %al, %al
je 0xa071
cmpl $0x0, 0x8(%rbx)
jle 0xa19f
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7f19
movq %rax, %rbx
movq %rax, %rdi
callq 0x5109
movq %rbx, %rdi
callq 0x7d46
jmp 0xa15e
xorl %ebx, %ebx
jmp 0xa160
movq 0x8(%rax), %rdi
callq 0x21c0
callq 0x7132
jmp 0xa091
movq 0x8(%rax), %rdi
callq 0x7177
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7ec0
jmp 0xa15e
movq %r12, %rdi
movq %r15, %rsi
callq 0x7ba0
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x77ea
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7c0d
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7a77
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x76ce
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7735
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x798b
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7667
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x789f
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7ca2
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7915
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7b37
jmp 0xa151
movq %r12, %rdi
movq %r15, %rsi
callq 0x7a01
movl $0x1, %esi
movq %rbx, %rdi
callq 0x7e30
movb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x6a94(%rip), %rdi      # 0x10c09
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2318
jmp 0xa160
movq 0x8(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x18(%rax), %edx
incl %edx
leaq 0x6b03(%rip), %rdi      # 0x10c97
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2318
jmp 0xa160
leaq 0x6aaa(%rip), %rdi      # 0x10c50
jmp 0xa175
leaq 0x69f0(%rip), %rdi      # 0x10b9f
leaq 0x3723(%rip), %rsi      # 0xd8d9
leaq 0x69f6(%rip), %rcx      # 0x10bb3
movl $0x177f, %edx           # imm = 0x177F
callq 0x20f0
leaq 0x6a26(%rip), %rdi      # 0x10bf4
leaq 0x3704(%rip), %rsi      # 0xd8d9
leaq 0x69d7(%rip), %rcx      # 0x10bb3
movl $0x1784, %edx           # imm = 0x1784
callq 0x20f0
leaq 0x69b2(%rip), %rdi      # 0x10b9f
leaq 0x36e5(%rip), %rsi      # 0xd8d9
leaq 0x69b8(%rip), %rcx      # 0x10bb3
movl $0x17ad, %edx           # imm = 0x17AD
callq 0x20f0
leaq 0x45eb(%rip), %rdi      # 0xe7f7
leaq 0x36c6(%rip), %rsi      # 0xd8d9
leaq 0x6999(%rip), %rcx      # 0x10bb3
movl $0x17c4, %edx           # imm = 0x17C4
callq 0x20f0
leaq 0x45cc(%rip), %rdi      # 0xe7f7
leaq 0x36a7(%rip), %rsi      # 0xd8d9
leaq 0x697a(%rip), %rcx      # 0x10bb3
movl $0x17a4, %edx           # imm = 0x17A4
callq 0x20f0