// File: /workspace/github_cpp_makefile_star2_O1/mniip[P]sandbox/main.cpp
// Function: main
int main(int argc, char **argv)
{
	if(argc < 3 || (std::string(argv[2]) == "kill" && argc < 4))
	{
		fprintf(stderr, "Usage: %s <config.conf> <ident> [prog [args...]]\n", argv[0]);
		fprintf(stderr, "       %s <config.conf> kill <ident>\n", argv[0]);
		abort();
	}

	ident = std::string(argv[2]) == "kill" ? argv[3] : argv[2];
	read_conf(argv[1]);

	if(std::string(argv[2]) == "kill")
	{
		kill_session();
		printf("Done\n");
		exit(EXIT_SUCCESS);
	}

	try_connect();

	signal(SIGUSR1, ignore);

	int pid = fork();
	if(pid < 0)
		panic_errno("fork");

	if(!pid)
	{
		if(pipe(in_pipe))
			panic_errno("pipe");
		if(pipe(out_pipe))
			panic_errno("pipe");
		if(argc >= 4)
		{
			main_process = sandbox.spawn_process(argv[3], argc - 3, argv + 3, set_limits);
		}
		else
		{
			std::vector<char *> av;
			for(std::vector<std::string>::iterator i = conf_arg.begin(), end = conf_arg.end(); i != end; i++)
				av.push_back(&(*i)[0]);
			main_process = sandbox.spawn_process(conf_program.c_str(), av.size(), av.data(), set_limits);
		}
		close(in_pipe[0]);
		close(out_pipe[1]);
		feed_in = new std::thread(feed_data, fileno(stdin), in_pipe[1], true, !conf_wakeup);
		feed_out = new std::thread(feed_data, out_pipe[0], fileno(stdout), false, false);
		sandbox.event_loop();
		exit(0);
	}
	else
	{
		signal(SIGUSR1, detach);
		wait(NULL);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movb $0x1, %r14b
cmpl $0x3, %edi
jl 0x50c8
movq 0x10(%rbx), %rsi
leaq 0xb8(%rsp), %r14
leaq 0x7(%rsp), %rdx
movq %r14, %rdi
callq 0x55de
leaq 0xa452(%rip), %rsi      # 0xf507
movq %r14, %rdi
callq 0x4110
movl %ebp, %ecx
xorl $0x3, %ecx
orl %eax, %ecx
sete %r14b
cmpl $0x3, %ebp
jl 0x50ee
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x50ee
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x43e0
testb %r14b, %r14b
jne 0x5273
movq 0x10(%rbx), %rsi
leaq 0x10(%rsp), %r14
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x55de
leaq 0xa3f3(%rip), %rsi      # 0xf507
movq %r14, %rdi
callq 0x4110
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movq 0x10(%rbx,%rcx,8), %rax
leaq 0xf341(%rip), %rcx      # 0x14470
movq %rax, (%rcx)
movq (%r14), %rdi
leaq 0x20(%rsp), %r12
cmpq %r12, %rdi
je 0x514c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x8(%rbx), %rsi
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x55de
leaq 0x98(%rsp), %rdi
callq 0xc4f4
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5190
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x10(%rbx), %rsi
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x55de
leaq 0xa35a(%rip), %rsi      # 0xf507
movq %r15, %rdi
callq 0x4110
movl %eax, %r14d
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x51cd
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
testl %r14d, %r14d
je 0x527b
callq 0xbaf1
leaq -0x16c(%rip), %rsi      # 0x5076
movl $0xa, %edi
callq 0x4480
callq 0x40f0
movl %eax, %r14d
testl %eax, %eax
jns 0x5242
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xa358(%rip), %rsi      # 0xf564
leaq 0xa355(%rip), %rdx      # 0xf568
leaq 0x78(%rsp), %r15
movq %r15, %rdi
callq 0x9376
movq %r15, %rdi
callq 0xa5a4
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x5242
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x43e0
testl %r14d, %r14d
je 0x5293
leaq -0x1e0(%rip), %rsi      # 0x506e
movl $0xa, %edi
callq 0x4480
xorl %edi, %edi
callq 0x44c0
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x4820
callq 0xbe0b
leaq 0xa500(%rip), %rdi      # 0xf787
callq 0x4650
xorl %edi, %edi
callq 0x44a0
leaq 0xf1de(%rip), %r14      # 0x14478
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
jne 0x53c8
leaq 0xf1cf(%rip), %r15      # 0x14480
movq %r15, %rdi
callq 0x4540
testl %eax, %eax
jne 0x5415
cmpl $0x4, %ebp
jl 0x5461
addq $0x18, %rbx
movq (%rbx), %rsi
addl $-0x3, %ebp
leaq 0xf165(%rip), %rdi      # 0x14440
leaq -0x3e6(%rip), %r8       # 0x4efc
movl %ebp, %edx
movq %rbx, %rcx
callq 0x561c
movl %eax, 0xf146(%rip)      # 0x14438
movl (%r14), %edi
callq 0x47e0
movl 0x4(%r15), %edi
callq 0x47e0
movl $0x8, %edi
callq 0x43d0
movq %rax, %r15
movq 0xec99(%rip), %rax      # 0x13fb0
movq (%rax), %rdi
callq 0x4420
leaq 0x10(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x8(%rsp), %r8
movb $0x1, (%r8)
leaq 0xf2b2(%rip), %rax      # 0x145e8
movb (%rax), %al
xorb $0x1, %al
leaq 0x6(%rsp), %r9
movb %al, (%r9)
addq $0x4, %r14
leaq 0x5ff7(%rip), %rsi      # 0xb344
movq %r15, %rdi
movq %r14, %rcx
callq 0x57c8
leaq 0xf129(%rip), %rax      # 0x14488
movq %r15, (%rax)
movl $0x8, %edi
callq 0x43d0
movq %rax, %r14
movq 0xec12(%rip), %rax      # 0x13f88
movq (%rax), %rdi
callq 0x4420
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
xorl %eax, %eax
leaq 0x8(%rsp), %r8
movb %al, (%r8)
leaq 0x6(%rsp), %r9
movb %al, (%r9)
leaq 0x5fa6(%rip), %rsi      # 0xb344
leaq 0xf0db(%rip), %rdx      # 0x14480
movq %r14, %rdi
callq 0x5874
leaq 0xf0dc(%rip), %rax      # 0x14490
movq %r14, (%rax)
leaq 0xf082(%rip), %rdi      # 0x14440
callq 0x5920
jmp 0x528c
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xa190(%rip), %rsi      # 0xf569
leaq 0xa18d(%rip), %rdx      # 0xf56d
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x9376
movq %r15, %rdi
callq 0xa5a4
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x52aa
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0x52aa
leaq 0x48(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xa144(%rip), %rsi      # 0xf569
leaq 0xa141(%rip), %rdx      # 0xf56d
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x9376
movq %r12, %rdi
callq 0xa5a4
movq 0x38(%rsp), %rdi
cmpq %r13, %rdi
je 0x52c1
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0x52c1
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0xf057(%rip), %rax      # 0x144d0
movq (%rax), %r13
movq 0x8(%rax), %rbp
cmpq %rbp, %r13
je 0x54ac
leaq 0x10(%rsp), %rbx
leaq 0x8(%rsp), %r12
movq (%r13), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa382
addq $0x20, %r13
cmpq %rbp, %r13
jne 0x548f
leaq 0xeffd(%rip), %rax      # 0x144b0
movq (%rax), %rsi
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
leaq 0xef72(%rip), %rdi      # 0x14440
leaq -0x5d9(%rip), %r8       # 0x4efc
callq 0x561c
movl %eax, 0xef58(%rip)      # 0x14438
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x52f2
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x43e0
jmp 0x52f2
jmp 0x5512
movq %rax, %rbx
movl $0x8, %esi
movq %r14, %rdi
jmp 0x5594
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x559e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
jmp 0x5594
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r13, %rdi
je 0x559e
movq 0x48(%rsp), %rsi
jmp 0x5591
movq %rax, %rbx
movl $0x8, %esi
movq %r15, %rdi
jmp 0x5594
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x559e
movq 0x68(%rsp), %rsi
jmp 0x5591
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x559e
movq 0x88(%rsp), %rsi
jmp 0x5591
movq %rax, %rbx
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x559e
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0x559e
movq %rax, %rbx
movq %rbx, %rdi
callq 0x4770