// File: /workspace/github_cpp_makefile_star2_O3/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 $0x158, %rsp            # imm = 0x158
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 0x3c2e
movq %rsi, %rbx
movl %edi, %ebp
movq 0x8(%rsi), %rsi
leaq 0xc8(%rsp), %rdi
leaq 0x128(%rsp), %r14
movq %r14, %rdx
callq 0x3db0
leaq 0x130(%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 0x8(%rsp), %r15
leaq 0x28(%rsp), %r12
movq (%rbx,%rbp,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x3db0
movq %r14, %rdi
movq %r15, %rsi
callq 0x3fac
movb $0x1, (%rax)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x360c
movq 0x18(%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 0x3bb5
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
xorl %ebp, %ebp
movq %rbp, -0x8(%r14)
movb %bpl, (%r14)
leaq 0x78(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rbp, -0x8(%rcx)
movb %bpl, (%rcx)
leaq 0x58(%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 0x3b85
addq %rbx, %rdi
movb $0x1, %al
movl %eax, 0x4(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
movl $0xa, %esi
callq 0x21b0
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0x22b0
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %r15
movb (%r12), %al
testb $0x1, %r14b
je 0x3725
testb $0x1, %r13b
je 0x37bb
cmpb $0x60, %al
jne 0x3ab2
cmpb $0x60, 0x1(%r12)
jne 0x3ab2
cmpb $0x60, 0x2(%r12)
jne 0x3ab2
testb $0x1, 0x4(%rsp)
je 0x3b20
leaq 0xc8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2618
movl %eax, %ebp
movb $0x1, %r14b
xorl %r13d, %r13d
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x3b45
xorl %r14d, %r14d
xorl %ebp, %ebp
cmpb $0x23, %al
jne 0x3b45
cmpb $0x20, 0x1(%r12)
jne 0x3b1b
shlq $0x20, %r15
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
addq %rax, %r15
sarq $0x20, %r15
movl $0x2, %edx
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rcx
callq 0x21e0
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2210
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3795
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x128(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x40ca
leaq 0x130(%rsp), %rcx
cmpq %rcx, %rax
setne %r14b
jmp 0x3b45
movb $0x1, %r14b
cmpb $0x23, %al
jne 0x384c
cmpb $0x20, 0x1(%r12)
jne 0x384c
movq %r15, %rcx
shlq $0x20, %rcx
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
addq %rax, %rcx
sarq $0x20, %rcx
movl $0x2, %edx
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x21e0
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2210
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3825
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x128(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x40ca
leaq 0x130(%rsp), %rcx
cmpq %rcx, %rax
setne %r14b
movb $0x1, %al
movl %eax, 0x4(%rsp)
movl $0x5, %edx
movq %r12, %rdi
leaq 0x193e(%rip), %rsi      # 0x5199
callq 0x2120
testl %eax, %eax
sete %al
cmpl $0x7, %r15d
setge %cl
andb %al, %cl
xorl %ebp, %ebp
cmpb $0x1, %cl
jne 0x393d
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0x41cc
leaq 0x6(%r12), %rbp
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq %rbp, %rdi
callq 0x2100
leaq (%r12,%rax), %rdx
addq $0x6, %rdx
leaq 0x108(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4034
leaq 0xa8(%rsp), %rdi
movq %r13, %rsi
callq 0x2ac9
movl %eax, %ebp
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x3918
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x393d
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21d0
cmpl $0x7, %r15d
setge %r15b
movl $0x5, %edx
movq %r12, %rdi
leaq 0x184b(%rip), %rsi      # 0x519f
callq 0x2120
testl %eax, %eax
sete %al
andb %r15b, %al
cmpb $0x1, %al
jne 0x3a2d
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x41cc
leaq 0x6(%r12), %r15
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq %r15, %rdi
callq 0x2100
leaq (%r12,%rax), %rdx
addq $0x6, %rdx
leaq 0xe8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x4034
leaq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0x3003
movl %eax, %ebp
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x3a08
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x3a2d
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x21d0
movl $0x12, %edx
movq %r12, %rdi
leaq 0x1769(%rip), %rsi      # 0x51a5
callq 0x2120
testl %eax, %eax
sete %r15b
orb 0x4(%rsp), %r15b
movl $0x11, %edx
movq %r12, %rdi
leaq 0x175d(%rip), %rsi      # 0x51b8
callq 0x2120
testl %eax, %eax
setne %al
andb %r15b, %al
movl %eax, 0x4(%rsp)
cmpb $0x60, (%r12)
jne 0x3b42
cmpb $0x60, 0x1(%r12)
jne 0x3b42
cmpb $0x60, 0x2(%r12)
jne 0x3b42
movb $0x1, %r13b
movq 0x50(%rsp), %rdx
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
leaq 0x1697(%rip), %rcx      # 0x513c
xorl %r8d, %r8d
callq 0x2250
jmp 0x3b45
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
addq %r12, %r15
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x41cc
movq %r14, %rdi
leaq 0x165f(%rip), %rsi      # 0x513b
callq 0x22c0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0x2090
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3b11
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
xorl %ebp, %ebp
movb $0x1, %r14b
movb $0x1, %r13b
jmp 0x3b45
xorl %r14d, %r14d
jmp 0x3b45
movq 0x48(%rsp), %rdi
callq 0x2190
testb $0x7f, %al
movzbl %ah, %ebp
movl $0x1, %eax
cmovnel %eax, %ebp
movb $0x1, %r14b
movl $0x0, 0x4(%rsp)
xorl %r13d, %r13d
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %eax
andl $0x2, %eax
orl %ebp, %eax
je 0x369d
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3b7b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x38(%rsp), %r14
leaq 0x78(%rsp), %rcx
movq 0x68(%rsp), %rdi
cmpq %rcx, %rdi
je 0x3b9c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x3c00
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3c00
movq 0x3434(%rip), %rbx      # 0x6ff0
leaq 0x15bc(%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 0x3402(%rip), %rdi      # 0x6ff0
callq 0x2030
movl $0x42, %ebp
movq %rax, %rdi
callq 0x2140
leaq 0x128(%rsp), %rdi
callq 0x4154
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c2e
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x21d0
movl %ebp, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x3c6f
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3c6f
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x3d08
movq 0x98(%rsp), %rsi
jmp 0x3cf7
movq %rax, %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x3cbf
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3cbf
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x3d08
movq 0xb8(%rsp), %rsi
jmp 0x3cf7
jmp 0x3ce0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3d08
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x3d08
jmp 0x3d05
jmp 0x3d56
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3d24
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3d40
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3d7a
movq 0x38(%rsp), %rsi
jmp 0x3d72
movq %rax, %rbx
jmp 0x3d7a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3d7a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x128(%rsp), %rdi
callq 0x4154
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3da8
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2290