// File: /workspace/github_cpp_makefile_star2_O2/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 $0x188, %rsp            # imm = 0x188
cmpl $0x2, %edi
jg 0x2bf2
callq 0x246c
pushq $0x40
popq %r13
jmp 0x2ff3
movq %rsi, %r14
movl %edi, %ebx
movq 0x8(%rsi), %rsi
leaq 0x50(%rsp), %rdi
leaq 0x118(%rsp), %r15
movq %r15, %rdx
callq 0x3112
leaq 0x120(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movl %ebx, %ebx
pushq $0x2
popq %r13
leaq 0xb0(%rsp), %r12
leaq 0x10(%rsp), %rbp
cmpq %r13, %rbx
je 0x2c6f
movq (%r14,%r13,8), %rsi
movq %r12, %rdi
movq %rbp, %rdx
callq 0x3112
movq %r15, %rdi
movq %r12, %rsi
callq 0x32c6
movb $0x1, (%rax)
movq %r12, %rdi
callq 0x2308
incq %r13
jmp 0x2c40
xorl %edi, %edi
callq 0x20d0
movq 0x435b(%rip), %r14      # 0x6fd8
movq (%r14), %rax
movq -0x18(%rax), %rax
movq 0xe8(%r14,%rax), %rdi
callq 0x22a0
testq %rax, %rax
jle 0x2fbd
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0xe8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %r13d, %r13d
movb %r13b, (%rax)
movb %r13b, (%rcx)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0xc(%rsp), %rcx
andl $0x0, (%rcx)
movb %r13b, (%rax)
leaq 0xb(%rsp), %rax
movb %r13b, (%rax)
leaq 0xd8(%rsp), %rdx
leaq 0xb0(%rsp), %rsi
movq %rdx, (%rsi)
movq %rbp, 0x8(%rsi)
movq %rcx, 0x10(%rsi)
movq %r15, 0x18(%rsi)
movq %rax, 0x20(%rsi)
movb $0x1, %r12b
xorl %ebp, %ebp
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x20(%r14,%rax), %eax
andl $0x2, %eax
orl %r13d, %eax
jne 0x2f9a
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2060
movq 0x10(%rsp), %r15
movl 0x18(%rsp), %ebx
movl %ebx, 0xc(%rsp)
movb (%r15), %al
cmpb $0x0, 0xb(%rsp)
je 0x2d96
testb $0x1, %bpl
je 0x2dc4
cmpb $0x60, %al
leaq 0x10(%rsp), %rsi
jne 0x2f4f
cmpb $0x60, 0x1(%r15)
jne 0x2f4f
cmpb $0x60, 0x2(%r15)
jne 0x2f4f
testb $0x1, %r12b
je 0x2f83
xorl %ebp, %ebp
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x259c
movl %eax, %r13d
movb $0x1, %r12b
jmp 0x2d0b
movl $0x0, %r13d
cmpb $0x23, %al
jne 0x2d0b
cmpb $0x20, 0x1(%r15)
jne 0x2d0b
leaq 0xb0(%rsp), %rdi
callq 0x30ae
xorl %r13d, %r13d
jmp 0x2d0b
cmpb $0x23, %al
leaq 0x90(%rsp), %rbp
jne 0x2df8
cmpb $0x20, 0x1(%r15)
jne 0x2df8
movb $0x0, 0xb(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x30ae
movb $0x1, %r12b
movl 0xc(%rsp), %ebx
leaq 0x90(%rsp), %rbp
movq %r15, %rdi
leaq 0x1397(%rip), %rsi      # 0x4199
pushq $0x5
popq %rdx
callq 0x2110
testl %eax, %eax
sete %al
cmpl $0x7, %ebx
setge %cl
andb %al, %cl
xorl %r13d, %r13d
cmpb $0x1, %cl
jne 0x2e6f
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
callq 0x2220
leaq 0x6(%r15), %rsi
leaq 0x168(%rsp), %r13
movq %r13, %rdi
leaq 0x70(%rsp), %rdx
callq 0x3112
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x27a8
movq %r13, %rdi
movl %eax, %r13d
callq 0x2308
movq %rbx, %rdi
callq 0x2308
movl 0xc(%rsp), %ebx
movq %r15, %rdi
leaq 0x1326(%rip), %rsi      # 0x419f
pushq $0x5
popq %rdx
callq 0x2110
testl %eax, %eax
jne 0x2edb
cmpl $0x7, %ebx
jl 0x2edb
leaq 0xf8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2220
leaq 0x6(%r15), %rsi
leaq 0x148(%rsp), %rbp
movq %rbp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x3112
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x29bb
movl %eax, %r13d
movq %rbp, %rdi
callq 0x2308
movq %rbx, %rdi
callq 0x2308
movq %r15, %rdi
leaq 0x12c0(%rip), %rsi      # 0x41a5
pushq $0x12
popq %rdx
callq 0x2110
testl %eax, %eax
sete %bl
orb %r12b, %bl
movq %r15, %rdi
leaq 0x12b9(%rip), %rsi      # 0x41b8
pushq $0x11
popq %rdx
callq 0x2110
testl %eax, %eax
setne %r12b
andb %bl, %r12b
xorl %ebp, %ebp
cmpb $0x60, (%r15)
jne 0x2d0b
xorl %ebp, %ebp
cmpb $0x60, 0x1(%r15)
jne 0x2d0b
xorl %ebp, %ebp
cmpb $0x60, 0x2(%r15)
jne 0x2d0b
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
leaq 0x11f7(%rip), %rsi      # 0x413c
callq 0x22d0
jmp 0x2d0b
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
leaq 0x11dd(%rip), %rdx      # 0x413b
callq 0x332c
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x22e0
movq %rbx, %rdi
callq 0x2308
movb $0x1, %bpl
xorl %r13d, %r13d
jmp 0x2d0b
xorl %r12d, %r12d
leaq 0x30(%rsp), %rdi
callq 0x2792
movl %eax, %r13d
xorl %ebp, %ebp
jmp 0x2d0b
leaq 0x30(%rsp), %rdi
callq 0x2308
leaq 0xd8(%rsp), %rdi
callq 0x2308
leaq 0x10(%rsp), %rdi
callq 0x2308
jmp 0x2fdc
movq 0x402c(%rip), %rdi      # 0x6ff0
leaq 0x11b4(%rip), %rsi      # 0x417f
callq 0x21b0
movq %rax, %rdi
callq 0x2120
pushq $0x42
popq %r13
leaq 0x118(%rsp), %rdi
callq 0x3490
leaq 0x50(%rsp), %rdi
callq 0x2308
movl %r13d, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x302f
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x2308
jmp 0x303c
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x2308
leaq 0xf8(%rsp), %rdi
jmp 0x3052
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x3052
jmp 0x307a
jmp 0x3059
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2308
jmp 0x305c
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2308
leaq 0xd8(%rsp), %rdi
callq 0x2308
leaq 0x10(%rsp), %rdi
jmp 0x308a
movq %rax, %rbx
jmp 0x308f
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x2308
leaq 0x118(%rsp), %rdi
callq 0x3490
leaq 0x50(%rsp), %rdi
callq 0x2308
movq %rbx, %rdi
callq 0x2280