// File: /workspace/github_cpp_makefile_star2_O1/wekan[P]sps/sps.cxx
// Function: main
int main (int argc, char * argv[])
{
	if (argc < 3)
	{
		use();
		return EX_USAGE; // 64
	}
	
	std::string host = argv[1];
	std::map<std::string, bool> target_list;
	for (int i = 2 ; i < argc ; i++)
		target_list[argv[i]] = true;

	std::ios_base::sync_with_stdio(false);
	if (std::cin.rdbuf()->in_avail() <= 0)
	{
		std::cerr << "No data on standard input" << std::endl;
		return EX_NOINPUT; // 65
	}

	std::string line, section, exec_cmd;
	char * str = nullptr;
	int len = 0;
	int exit_code = 0;
	bool exec_remote = true;
	bool in_section = false;
	bool in_exec = false;
	
	auto check_section = [&]() -> void
	{
		section = line.substr(2, len - 2);
		if (target_list.find(section) != target_list.end())
			in_section = true;
	};
	
	while (!std::cin.eof() && exit_code == 0)
	{
		getline(std::cin, line);
		str = (char*) line.c_str();
		len = line.length();

		if (!in_section)
		{
			if (strncmp(str, "# ", 2) == 0)
				check_section();
		}
		else
		{
			if (!in_exec)
			{
				if (strncmp(str, "# ", 2) == 0)
				{
					in_section = false;
					in_exec = false;
					exec_remote = true;
					check_section();
				}

				if (strncmp(str, "* GET", 5) == 0)
				{
					if (len > 6)
						exit_code = get_transfert(host, str + 6);
				}
				if (strncmp(str, "* PUT", 5) == 0)
				{
					if (len > 6)
						exit_code = put_transfert(host, str + 6);
				}
				if (strncmp(str, "* REMOTE_EXECUTION", 18) == 0)
					exec_remote = true;
				if (strncmp(str, "* LOCAL_EXECUTION", 17) == 0)
					exec_remote = false;

				if (strncmp(str, "```", 3) == 0)
				{
					in_exec = true;
					exec_cmd = "";
				}
			}
			else
			{
				if (strncmp(str, "```", 3) == 0)
				{
					in_exec = false;
					exit_code = exec_remote ? remote_execution(host, exec_cmd) : local_execution(exec_cmd);
				}
				else
				{
					exec_cmd += line + "\n";
				}
			}
		}
	}
	
	return exit_code;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
cmpl $0x2, %edi
jg 0x3580
movq 0x3a96(%rip), %rbx      # 0x6ff0
leaq 0x1b08(%rip), %rsi      # 0x5069
movl $0xd3, %edx
movq %rbx, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2140
movl $0x40, %ebp
jmp 0x3c36
movq %rsi, %rbx
movl %edi, %ebp
movq 0x8(%rsi), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x138(%rsp), %r14
movq %r14, %rdx
callq 0x3dbe
leaq 0x140(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movl %ebp, %r13d
movl $0x2, %ebp
leaq 0x10(%rsp), %r15
leaq 0x38(%rsp), %r12
movq (%rbx,%rbp,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x3dbe
movq %r14, %rdi
movq %r15, %rsi
callq 0x3fb8
movb $0x1, (%rax)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x360c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
incq %rbp
cmpq %rbp, %r13
jne 0x35d3
xorl %edi, %edi
callq 0x20f0
movq 0x39b6(%rip), %rbx      # 0x6fd8
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq 0xe8(%rbx,%rax), %rdi
movq 0x18(%rdi), %rax
subq 0x10(%rdi), %rax
jne 0x3641
movq (%rdi), %rax
callq *0x38(%rax)
testq %rax, %rax
jle 0x3bbd
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %ebp, %ebp
movq %rbp, -0x8(%rax)
movb %bpl, (%rax)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rbp, -0x8(%rax)
movb %bpl, (%rax)
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rbp, -0x8(%rax)
movb %bpl, (%rax)
movq (%rbx), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%rbx,%rdi)
jne 0x3b61
addq %rbx, %rdi
movq $0x0, 0x30(%rsp)
movb $0x1, %al
movl %eax, 0xc(%rsp)
xorl %ebp, %ebp
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x21b0
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x22b0
movq 0x38(%rsp), %r13
movq 0x40(%rsp), %r12
testb $0x1, %r14b
je 0x3765
testb $0x1, 0x30(%rsp)
je 0x3807
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1add(%rip), %rsi      # 0x51cd
callq 0x2120
testl %eax, %eax
je 0x3b0a
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
addq %r13, %r12
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x41d2
movq %r15, %rdi
leaq 0x1a14(%rip), %rsi      # 0x513b
callq 0x22c0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x58(%rsp), %rdi
callq 0x2090
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3b47
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3b47
movl $0x2, %edx
movq %r13, %rdi
leaq 0x1a25(%rip), %rsi      # 0x5199
callq 0x2120
testl %eax, %eax
jne 0x3b47
shlq $0x20, %r12
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
addq %rax, %r12
sarq $0x20, %r12
movl $0x2, %edx
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %r12, %rcx
callq 0x21e0
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2210
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x37d8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x138(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x40d0
leaq 0x140(%rsp), %rcx
cmpq %rcx, %rax
movzbl %r14b, %r14d
movl $0x1, %eax
cmovnel %eax, %r14d
jmp 0x3b47
movl $0x2, %edx
movq %r13, %rdi
leaq 0x1983(%rip), %rsi      # 0x5199
callq 0x2120
testl %eax, %eax
jne 0x38aa
movq %r12, %rcx
shlq $0x20, %rcx
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
addq %rax, %rcx
sarq $0x20, %rcx
movl $0x2, %edx
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x21e0
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2210
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x387a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x138(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x40d0
leaq 0x140(%rsp), %rcx
cmpq %rcx, %rax
setne %r14b
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x5, %edx
movq %r13, %rdi
leaq 0x18e3(%rip), %rsi      # 0x519c
callq 0x2120
testl %eax, %eax
sete %al
cmpl $0x7, %r12d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3998
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xd8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x41d2
leaq 0x6(%r13), %rbp
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
movq %rbp, %rdi
callq 0x2100
leaq (%rax,%r13), %rdx
addq $0x6, %rdx
leaq 0x118(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4040
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x2ac9
movl %eax, %ebp
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x3973
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x3998
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21d0
cmpl $0x7, %r12d
setge %r12b
movl $0x5, %edx
movq %r13, %rdi
leaq 0x17f3(%rip), %rsi      # 0x51a2
callq 0x2120
testl %eax, %eax
sete %al
andb %r12b, %al
cmpb $0x1, %al
jne 0x3a87
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xd8(%rsp), %rsi
movq 0xe0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x41d2
leaq 0x6(%r13), %r12
leaq 0x108(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq %r12, %rdi
callq 0x2100
leaq (%rax,%r13), %rdx
addq $0x6, %rdx
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x4040
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x3003
movl %eax, %ebp
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x3a62
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x3a87
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21d0
movl $0x12, %edx
movq %r13, %rdi
leaq 0x1712(%rip), %rsi      # 0x51a8
callq 0x2120
testl %eax, %eax
movl 0xc(%rsp), %r15d
movzbl %r15b, %r15d
movl $0x1, %eax
cmovel %eax, %r15d
movl $0x11, %edx
movq %r13, %rdi
leaq 0x16fd(%rip), %rsi      # 0x51bb
callq 0x2120
testl %eax, %eax
cmovel %eax, %r15d
movl %r15d, 0xc(%rsp)
movl $0x3, %edx
movq %r13, %rdi
leaq 0x16f0(%rip), %rsi      # 0x51cd
callq 0x2120
testl %eax, %eax
jne 0x3b47
movb $0x1, %al
movq %rax, 0x30(%rsp)
movq 0x60(%rsp), %rdx
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
leaq 0x163c(%rip), %rcx      # 0x513c
xorl %r8d, %r8d
callq 0x2250
jmp 0x3b47
testb $0x1, 0xc(%rsp)
je 0x3b27
leaq 0xd8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2618
movl %eax, %ebp
jmp 0x3b3e
movq 0x58(%rsp), %rdi
callq 0x2190
testb $0x7f, %al
movzbl %ah, %ebp
movl $0x1, %eax
cmovnel %eax, %ebp
movq $0x0, 0x30(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %eax
andl $0x2, %eax
orl %ebp, %eax
je 0x36a8
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x3b7d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3b9f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3c08
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3c08
movq 0x342c(%rip), %rbx      # 0x6ff0
leaq 0x15b4(%rip), %rsi      # 0x517f
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x33fa(%rip), %rdi      # 0x6ff0
callq 0x2030
movl $0x42, %ebp
movq %rax, %rdi
callq 0x2140
leaq 0x138(%rsp), %rdi
callq 0x415a
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c36
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x21d0
movl %ebp, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x3c77
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3c77
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x3d10
movq 0xa8(%rsp), %rsi
jmp 0x3cff
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x3cc7
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3cc7
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x3d10
movq 0xc8(%rsp), %rsi
jmp 0x3cff
jmp 0x3ce8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3d10
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3d10
jmp 0x3d0d
jmp 0x3d64
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x3d2c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3d4e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3d88
movq 0x48(%rsp), %rsi
jmp 0x3d80
movq %rax, %rbx
jmp 0x3d88
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3d88
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x138(%rsp), %rdi
callq 0x415a
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3db6
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2290