// File: /workspace/github_cpp_makefile_star2_O1/exrd[P]neteruhsp/neteruhsp/neteruhsp.cc
// Function: neteruhsp::(anonymous namespace)::command_input(neteruhsp::execute_environment_t*, neteruhsp::execute_status_t*, int)
void command_input( execute_environment_t* e, execute_status_t* s, int arg_num )
{
	if ( arg_num < 2 )
	{
		raise_error( "input：引数がたりません" );
	}
	if ( arg_num > 3 )
	{
		raise_error( "input：引数が多すぎます" );
	}

	const auto arg_start = -arg_num;
	const auto v = stack_peek( s->stack_, arg_start );
	if ( v->type_ != VALUE_VARIABLE )
	{
		raise_error( "input：対象が変数ではありません" );
	}
	if ( v->index_ > 0 )
	{
		raise_error( "input：対象の変数が配列として指定されています" );
	}

	const auto n = stack_peek( s->stack_, arg_start +1 );
	const auto len = value_calc_int( *n ) +1;

	const auto mode = ( arg_num>2 ? value_calc_int( *stack_peek( s->stack_, arg_start +2 ) ) : 0 );

	auto buf = create_string( len );
	int w =0;
	for( ; ; )
	{
		if ( w >= len )
		{ break; }

		const auto c = getchar();
		if ( c == EOF )
		{ break; }

		const auto ch = static_cast<char>( c );

		if ( mode==1 && ch=='\n' )
		{ break; }

		if ( mode==2 )
		{
			if ( ch == '\r' )
			{
				const auto nc =getchar();
				if ( static_cast<char>(nc) == '\n' )
				{ break; }
				ungetc( nc, stdin );
			}
			else if ( ch == '\n' )
			{ break; }
		}

		buf[w] = static_cast<char>( ch );
		++w;
	}
	buf[w] = '\0';

	auto t = create_value_move( buf );
	variable_set( e->variable_table_, *t, v->variable_->name_, 0 );
	destroy_value( t );

	s->strsize_ = w;

	stack_pop( s->stack_, arg_num );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x1, %edx
jle 0xa9c6
movl %edx, %r15d
cmpl $0x4, %edx
jge 0xa9cf
movq %rsi, %r13
movq %rdi, %rbx
movl %r15d, %esi
negl %esi
movq (%r13), %rdi
callq 0x7f19
cmpl $0x4, (%rax)
jne 0xa9d8
movq %rbx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x10(%rax)
jg 0xa9e1
movq (%r13), %rdi
movl $0x1, %esi
subl %r15d, %esi
callq 0x7f19
movq %rax, %rdi
callq 0x51df
movl %eax, %ebp
xorl %r14d, %r14d
movl $0x0, %ebx
cmpl $0x2, %r15d
je 0xa888
movq (%r13), %rdi
movl $0x2, %esi
subl %r15d, %esi
callq 0x7f19
movq %rax, %rdi
callq 0x51df
movl %eax, %ebx
movl %r15d, 0xc(%rsp)
movslq %ebp, %rdi
addq $0x2, %rdi
callq 0x21d0
movq %rax, (%rsp)
movl %ebx, %r15d
xorl $0x1, %r15d
movq %r13, 0x20(%rsp)
cmpl %ebp, %r14d
jg 0xa933
callq 0x2200
movl $0x2, %ecx
cmpl $-0x1, %eax
je 0xa92b
movl %eax, %r12d
shll $0x18, %eax
movl %eax, %edx
xorl $0xa000000, %edx        # imm = 0xA000000
orl %r15d, %edx
je 0xa92b
cmpl $0x2, %ebx
jne 0xa91b
cmpl $0xd000000, %eax        # imm = 0xD000000
jne 0xa914
callq 0x2200
movzbl %al, %r13d
movl $0x2, %ecx
cmpl $0xa, %r13d
je 0xa907
movq 0xc6dd(%rip), %rcx      # 0x16fd8
movq (%rcx), %rsi
movl %eax, %edi
callq 0x2070
xorl %ecx, %ecx
cmpl $0xa, %r13d
movq 0x20(%rsp), %r13
jne 0xa91b
jmp 0xa92b
cmpl $0xa000000, %eax        # imm = 0xA000000
je 0xa92b
movslq %r14d, %rax
movq (%rsp), %rcx
movb %r12b, (%rcx,%rax)
incl %r14d
xorl %ecx, %ecx
testl %ecx, %ecx
je 0xa8a9
movslq %r14d, %rax
movq (%rsp), %rcx
movb $0x0, (%rcx,%rax)
movslq 0xca5b(%rip), %rax      # 0x173a0
cmpq $0x3f, %rax
jg 0xa961
leal 0x1(%rax), %ecx
movl %ecx, 0xca4c(%rip)      # 0x173a0
leaq 0xc845(%rip), %rcx      # 0x171a0
movq (%rcx,%rax,8), %r15
jmp 0xa96e
movl $0x18, %edi
callq 0x21d0
movq %rax, %r15
movq 0x10(%rsp), %rax
movl $0x3, (%r15)
movq (%rsp), %rcx
movq %rcx, 0x8(%r15)
movq 0x18(%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdx
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x66f2
movq %r15, %rdi
callq 0x507f
movl %r14d, 0x1b0(%r13)
movq (%r13), %rdi
movl 0xc(%rsp), %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7e30
leaq 0x6d4e(%rip), %rdi      # 0x1171b
jmp 0xa9e8
leaq 0x6d66(%rip), %rdi      # 0x1173c
jmp 0xa9e8
leaq 0x6d7e(%rip), %rdi      # 0x1175d
jmp 0xa9e8
leaq 0x6da2(%rip), %rdi      # 0x1178a
xorl %eax, %eax
callq 0x34a8