// File: mniip[P]sandbox/main.cpp
// Function: TracedThread::should_replace_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, int, int)
bool should_replace_path(std::string path, std::string &newpath, int at, int flags)
	{
		if(path.compare(0, strlen("http:/"), "http:/") == 0 && path.compare(0, strlen("http://"), "http://") != 0)
			path = "http://" + path.substr(strlen("http:/"));
		else if(path.compare(0, strlen("https:/"), "https:/") == 0 && path.compare(0, strlen("https://"), "https://") != 0)
			path = "https://" + path.substr(strlen("https:/"));
		for(std::vector<std::string>::const_iterator i = conf_http.begin(), end = conf_http.end(); i != end; i++)
			if(path.compare(0, i->size(), *i) == 0)
			{
				if((flags & O_ACCMODE) != O_RDONLY)
				{
					newpath = "/dev/null";
					return true;
				}
				std::string filename = conf_downloadpat;
				int fd = mkstemp(&filename[0]);
				if(fd == -1)
					return false;
				unlink(&filename[0]);

				pid_t pid = fork();
				if(pid == -1)
				{
					close(fd);
					return false;
				}

				if(pid == 0)
				{
					dup2(fd, 1);
					close(fd);
					execlp("curl", "curl", "--silent", "--globoff", "--", path.c_str(), NULL);
					exit(1);
				}

				while(1)
				{
					int status;
					if(waitpid(pid, &status, 0) == -1)
					{
						close(fd);
						return false;
					}
					if(WIFEXITED(status) || WIFSIGNALED(status))
						break;
				}

				pipe_fd = fd;
				std::stringstream ss;
				ss << "/proc/" << getpid() << "/fd/" << pipe_fd;

				newpath = ss.str();
				return true;
			}
		return false;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rsi, -0x2d0(%rbp)
movq %rdi, %rax
movq -0x2d0(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
movq %rax, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2c0(%rbp)
xorl %eax, %eax
movl %eax, %esi
movl $0x6, %edx
leaq 0xbcb3(%rip), %rcx      # 0x1c1b4
callq 0x56a0
cmpl $0x0, %eax
jne 0x105ad
movq -0x2c8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x7, %edx
leaq 0xbc95(%rip), %rcx      # 0x1c1bb
callq 0x56a0
cmpl $0x0, %eax
je 0x105ad
movq -0x2c8(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
movl $0x6, %edx
movq $-0x1, %rcx
callq 0x5510
movq -0x2d8(%rbp), %rdx
leaq 0xbc5a(%rip), %rsi      # 0x1c1bb
leaq -0x48(%rbp), %rdi
callq 0x10fb0
jmp 0x1056c
movq -0x2c8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x55f0
leaq -0x48(%rbp), %rdi
callq 0x59b8
leaq -0x68(%rbp), %rdi
callq 0x59b8
jmp 0x10685
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x59b8
jmp 0x10a51
movq -0x2c8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x7, %edx
leaq 0xbbff(%rip), %rcx      # 0x1c1c3
callq 0x56a0
cmpl $0x0, %eax
jne 0x10683
movq -0x2c8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x8, %edx
leaq 0xbbe2(%rip), %rcx      # 0x1c1cb
callq 0x56a0
cmpl $0x0, %eax
je 0x10683
movq -0x2c8(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
movl $0x7, %edx
movq $-0x1, %rcx
callq 0x5510
movq -0x2e0(%rbp), %rdx
leaq 0xbba0(%rip), %rsi      # 0x1c1cb
leaq -0x98(%rbp), %rdi
callq 0x10fb0
jmp 0x10639
movq -0x2c8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x55f0
leaq -0x98(%rbp), %rdi
callq 0x59b8
leaq -0xb8(%rbp), %rdi
callq 0x59b8
jmp 0x10683
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x59b8
jmp 0x10a51
jmp 0x10685
leaq 0x16fdc(%rip), %rdi     # 0x27668
callq 0x7020
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x7050
leaq 0x16fb6(%rip), %rdi     # 0x27668
callq 0x7090
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x7050
leaq -0xc0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x70c0
testb $0x1, %al
jne 0x106ed
jmp 0x10a3f
leaq -0xc0(%rbp), %rdi
callq 0x7100
movq %rax, %rdi
callq 0x5330
movq %rax, -0x2e8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x10ea0
movq -0x2c8(%rbp), %rdi
movq -0x2e8(%rbp), %rdx
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
callq 0x5680
cmpl $0x0, %eax
jne 0x10a23
movl -0x28(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x1075b
movq -0x20(%rbp), %rdi
leaq 0xba87(%rip), %rsi      # 0x1c1d4
callq 0x56d0
movb $0x1, -0x1(%rbp)
jmp 0x10a43
leaq 0x16f1e(%rip), %rsi     # 0x27680
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x5210
movq -0x2f8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x59a0
movq %rax, -0x2f0(%rbp)
jmp 0x1078e
movq -0x2f0(%rbp), %rdi
callq 0x5190
movl %eax, -0x2fc(%rbp)
jmp 0x107a2
movl -0x2fc(%rbp), %eax
movl %eax, -0xfc(%rbp)
cmpl $-0x1, -0xfc(%rbp)
jne 0x107db
movb $0x0, -0x1(%rbp)
movl $0x1, -0x100(%rbp)
jmp 0x10a07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x10a15
xorl %eax, %eax
movl %eax, %esi
leaq -0xf8(%rbp), %rdi
callq 0x59a0
movq %rax, -0x308(%rbp)
jmp 0x107f4
movq -0x308(%rbp), %rdi
callq 0x5270
callq 0x5150
movl %eax, -0x104(%rbp)
cmpl $-0x1, -0x104(%rbp)
jne 0x10834
movl -0xfc(%rbp), %edi
callq 0x5970
jmp 0x10821
movb $0x0, -0x1(%rbp)
movl $0x1, -0x100(%rbp)
jmp 0x10a07
cmpl $0x0, -0x104(%rbp)
jne 0x108a3
movl -0xfc(%rbp), %edi
movl $0x1, %esi
callq 0x54a0
movl -0xfc(%rbp), %edi
callq 0x5970
jmp 0x1085a
movq -0x2c8(%rbp), %rdi
callq 0x5200
movq %rax, %r9
leaq 0xb96e(%rip), %rsi      # 0x1c1de
leaq 0xb96c(%rip), %rdx      # 0x1c1e3
leaq 0xb96e(%rip), %rcx      # 0x1c1ec
leaq 0xb971(%rip), %r8       # 0x1c1f6
xorl %eax, %eax
movq %rsi, %rdi
movq $0x0, (%rsp)
movb $0x0, %al
callq 0x5180
movl $0x1, %edi
callq 0x55e0
jmp 0x108a5
jmp 0x108a7
movl -0x104(%rbp), %edi
leaq -0x108(%rbp), %rsi
xorl %edx, %edx
callq 0x53e0
movl %eax, -0x30c(%rbp)
jmp 0x108c3
movl -0x30c(%rbp), %eax
cmpl $-0x1, %eax
jne 0x108ee
movl -0xfc(%rbp), %edi
callq 0x5970
jmp 0x108db
movb $0x0, -0x1(%rbp)
movl $0x1, -0x100(%rbp)
jmp 0x10a07
movl -0x108(%rbp), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
je 0x10912
movl -0x108(%rbp), %eax
andl $0x7f, %eax
addl $0x1, %eax
movsbl %al, %eax
sarl %eax
cmpl $0x0, %eax
jle 0x10914
jmp 0x10916
jmp 0x108a5
movq -0x2c0(%rbp), %rax
movl -0xfc(%rbp), %ecx
movl %ecx, 0x40(%rax)
leaq -0x290(%rbp), %rdi
callq 0x5340
jmp 0x10934
leaq -0x280(%rbp), %rdi
leaq 0xb8b7(%rip), %rsi      # 0x1c1f9
callq 0x54d0
movq %rax, -0x318(%rbp)
jmp 0x10950
callq 0x5790
movq -0x318(%rbp), %rdi
movl %eax, %esi
callq 0x58d0
movq %rax, -0x320(%rbp)
jmp 0x1096c
movq -0x320(%rbp), %rdi
leaq 0xb6c4(%rip), %rsi      # 0x1c03e
callq 0x54d0
movq %rax, -0x328(%rbp)
jmp 0x10988
movq -0x328(%rbp), %rdi
movq -0x2c0(%rbp), %rax
movl 0x40(%rax), %esi
callq 0x58d0
jmp 0x109a0
leaq -0x2b0(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x54c0
jmp 0x109b5
movq -0x20(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x55f0
leaq -0x2b0(%rbp), %rdi
callq 0x59b8
movb $0x1, -0x1(%rbp)
movl $0x1, -0x100(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x5380
jmp 0x10a07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x5380
jmp 0x10a15
leaq -0xf8(%rbp), %rdi
callq 0x59b8
jmp 0x10a43
leaq -0xf8(%rbp), %rdi
callq 0x59b8
jmp 0x10a51
jmp 0x10a25
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
callq 0x7120
movq %rax, -0x2b8(%rbp)
jmp 0x106d1
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x58f0
nopw (%rax,%rax)