// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl %r8d, %ebp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
leaq 0x40ec(%rip), %rcx      # 0xc672
pushq $0x6
popq %rdx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x4540
testl %eax, %eax
je 0x85fb
leaq 0x40e3(%rip), %rcx      # 0xc681
pushq $0x7
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4540
testl %eax, %eax
jne 0x865f
leaq 0x40cf(%rip), %rcx      # 0xc689
pushq $0x8
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4540
testl %eax, %eax
je 0x865f
leaq 0x8(%rsp), %r15
pushq $0x7
popq %rdx
pushq $-0x1
popq %rcx
movq %r15, %rdi
movq %r12, %rsi
callq 0x4430
leaq 0x409d(%rip), %rsi      # 0xc689
leaq 0x50(%rsp), %rdi
movq %r15, %rdx
callq 0x8a3d
jmp 0x863d
leaq 0x4077(%rip), %rcx      # 0xc679
pushq $0x7
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4540
testl %eax, %eax
je 0x8597
leaq 0x8(%rsp), %r15
pushq $0x6
popq %rdx
pushq $-0x1
popq %rcx
movq %r15, %rdi
movq %r12, %rsi
callq 0x4430
leaq 0x4049(%rip), %rsi      # 0xc679
leaq 0x50(%rsp), %rdi
movq %r15, %rdx
callq 0x8a3d
leaq 0x50(%rsp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x44c0
movq %r15, %rdi
callq 0x4828
leaq 0x8(%rsp), %rdi
callq 0x4828
movq %r14, 0x28(%rsp)
leaq 0x9f35(%rip), %rax      # 0x125a0
movq (%rax), %rcx
movq 0x8(%rax), %r14
movq %rcx, %r15
cmpq %r14, %rcx
je 0x87d6
movq 0x8(%r15), %rdx
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rcx
callq 0x4520
leaq 0x20(%r15), %rcx
testl %eax, %eax
jne 0x8672
testb $0x3, %bpl
je 0x86b4
leaq 0x3fee(%rip), %rsi      # 0xc692
movq %rbx, %rdi
callq 0x47d0
movb $0x1, %r13b
jmp 0x87d6
leaq 0x9efd(%rip), %rsi      # 0x125b8
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x4590
movq (%r13), %rdi
callq 0x4170
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x87c9
movq 0x8(%rsp), %rdi
callq 0x4210
callq 0x4130
cmpl $-0x1, %eax
je 0x87b9
movl %eax, %r13d
testl %eax, %eax
je 0x87f1
leaq 0x50(%rsp), %r12
movl %r13d, %edi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4360
cmpl $-0x1, %eax
je 0x87c2
movl 0x50(%rsp), %eax
andl $0x7f, %eax
je 0x8732
shll $0x18, %eax
addl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x1ffffff, %eax        # imm = 0x1FFFFFF
jle 0x8704
movl %ebp, %eax
movq 0x28(%rsp), %rbp
movl %eax, 0x40(%rbp)
leaq 0x50(%rsp), %rdi
callq 0x42c0
leaq 0x60(%rsp), %rdi
leaq 0x3f65(%rip), %rsi      # 0xc6b7
callq 0x4400
movq %rax, %r12
callq 0x4610
movq %r12, %rdi
movl %eax, %esi
callq 0x4760
leaq 0x3d92(%rip), %rsi      # 0xc502
movq %rax, %rdi
callq 0x4400
movl 0x40(%rbp), %esi
movq %rax, %rdi
callq 0x4760
leaq 0x68(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x4690
leaq 0x30(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x44c0
movq %r12, %rdi
callq 0x4828
leaq 0x50(%rsp), %rdi
callq 0x4300
movb $0x1, %r13b
jmp 0x87cc
movl %ebp, %edi
callq 0x4800
jmp 0x87c9
movl %ebp, %edi
callq 0x4800
xorl %r13d, %r13d
leaq 0x8(%rsp), %rdi
callq 0x4828
cmpq %r14, %r15
setne %al
andb %r13b, %al
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rsi
movl %ebp, %edi
callq 0x43f0
movl %ebp, %edi
callq 0x4800
movq (%r12), %r9
andq $0x0, (%rsp)
leaq 0x3e8a(%rip), %rdi      # 0xc69c
leaq 0x3e88(%rip), %rdx      # 0xc6a1
leaq 0x3e8a(%rip), %rcx      # 0xc6aa
leaq 0x3e8d(%rip), %r8       # 0xc6b4
movq %rdi, %rsi
xorl %eax, %eax
callq 0x4160
pushq $0x1
popq %rdi
callq 0x44b0
jmp 0x8856
jmp 0x8841
jmp 0x8856
jmp 0x8856
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4300
jmp 0x8859
jmp 0x8856
jmp 0x8856
jmp 0x8856
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4828
movq %rbx, %rdi
callq 0x4770
nop