// File: mniip[P]sandbox/main.cpp
// Function: set_limits()
void set_limits()
{
	dup2(in_pipe[0], 0);
	dup2(out_pipe[1], 1);
	dup2(out_pipe[1], 2);
	close(in_pipe[0]);
	close(in_pipe[1]);
	close(out_pipe[0]);
	close(out_pipe[1]);

	if(conf_closefds)
	{
		DIR *fds = opendir("/proc/self/fd/");
		if(fds)
		{
			struct dirent *dent;
			while(dent = readdir(fds))
				if(atoi(dent->d_name) > 2)
					close(atoi(dent->d_name));
			closedir(fds);
		}
	}

	fflush(stdout);

	if(conf_clearenv)
		clearenv();
	for(std::vector<std::pair<std::string, std::string>>::const_iterator i = conf_setenv.begin(), end = conf_setenv.end(); i != end; i++)
		setenv(i->first.c_str(), i->second.c_str(), 1);
	for(std::vector<std::string>::const_iterator i = conf_unsetenv.begin(), end = conf_unsetenv.end(); i != end; i++)
		unsetenv(i->c_str());

	if(conf_chdir)
		chdir(conf_chdirto.c_str());

	struct rlimit limit;
	for(std::vector<std::pair<int, rlim_t>>::const_iterator i = conf_rlimit.begin(), end = conf_rlimit.end(); i != end; i++)
	{
		limit.rlim_max = limit.rlim_cur = i->second;
		setrlimit(i->first, &limit);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
leaq 0x212ce(%rip), %rax     # 0x27550
movl (%rax), %edi
xorl %esi, %esi
callq 0x54a0
leaq 0x212c6(%rip), %rax     # 0x27558
movl 0x4(%rax), %edi
movl $0x1, %esi
callq 0x54a0
leaq 0x212b2(%rip), %rax     # 0x27558
movl 0x4(%rax), %edi
movl $0x2, %esi
callq 0x54a0
leaq 0x21296(%rip), %rax     # 0x27550
movl (%rax), %edi
callq 0x5970
leaq 0x21288(%rip), %rax     # 0x27550
movl 0x4(%rax), %edi
callq 0x5970
leaq 0x21281(%rip), %rax     # 0x27558
movl (%rax), %edi
callq 0x5970
leaq 0x21273(%rip), %rax     # 0x27558
movl 0x4(%rax), %edi
callq 0x5970
leaq 0x212cc(%rip), %rax     # 0x275c0
testb $0x1, (%rax)
je 0x6358
leaq 0x15d34(%rip), %rdi     # 0x1c034
callq 0x57b0
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x6356
jmp 0x6312
movq -0x8(%rbp), %rdi
callq 0x57d0
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x634d
movq -0x10(%rbp), %rdi
addq $0x13, %rdi
callq 0x57e0
cmpl $0x2, %eax
jle 0x634b
movq -0x10(%rbp), %rdi
addq $0x13, %rdi
callq 0x57e0
movl %eax, %edi
callq 0x5970
jmp 0x6312
movq -0x8(%rbp), %rdi
callq 0x5810
jmp 0x6358
movq 0x20c41(%rip), %rax     # 0x26fa0
movq (%rax), %rdi
callq 0x55b0
leaq 0x21253(%rip), %rax     # 0x275c1
testb $0x1, (%rax)
je 0x6378
callq 0x5290
leaq 0x21249(%rip), %rdi     # 0x275c8
callq 0x6ee0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x6f10
leaq 0x2122c(%rip), %rdi     # 0x275c8
callq 0x6f50
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x6f10
leaq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6f80
testb $0x1, %al
jne 0x63c5
jmp 0x6417
leaq -0x18(%rbp), %rdi
callq 0x6fc0
movq %rax, %rdi
callq 0x5200
movq %rax, -0xa0(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x6fc0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x5200
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x57c0
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x6fe0
movq %rax, -0x38(%rbp)
jmp 0x63b2
leaq 0x211c2(%rip), %rdi     # 0x275e0
callq 0x7020
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7050
leaq 0x211a5(%rip), %rdi     # 0x275e0
callq 0x7090
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x7050
leaq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x70c0
testb $0x1, %al
jne 0x6464
jmp 0x648e
leaq -0x40(%rbp), %rdi
callq 0x7100
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x56f0
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x7120
movq %rax, -0x60(%rbp)
jmp 0x6451
leaq 0x21193(%rip), %rax     # 0x27628
testb $0x1, (%rax)
je 0x64ae
leaq 0x2118f(%rip), %rdi     # 0x27630
callq 0x5200
movq %rax, %rdi
callq 0x57a0
leaq 0x2119b(%rip), %rdi     # 0x27650
callq 0x7160
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x7190
leaq 0x2117e(%rip), %rdi     # 0x27650
callq 0x71d0
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x7190
leaq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x7200
testb $0x1, %al
jne 0x6507
jmp 0x6544
leaq -0x78(%rbp), %rdi
callq 0x7240
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movq %rax, -0x68(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7240
movl (%rax), %edi
leaq -0x70(%rbp), %rsi
callq 0x5470
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
callq 0x7260
movq %rax, -0x98(%rbp)
jmp 0x64f1
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)