// File: /workspace/github_cpp_makefile_star2_O3/mniip[P]sandbox/wakeup.cpp
// Function: do_wakeup()
void do_wakeup()
{
	pthread_cancel(feed_in->native_handle());
	feed_in->join();
	fcntl(out_pipe[0], F_SETFL, fcntl(out_pipe[0], F_GETFL) | O_NONBLOCK);
	pthread_kill(feed_out->native_handle(), SIGUSR1);
	feed_out->join();
	fcntl(out_pipe[0], F_SETFL, fcntl(out_pipe[0], F_GETFL) & ~O_NONBLOCK);
	delete feed_in;
	delete feed_out;
	if(old_client != -1)
		close(old_client);
	else
	{
		kill(getppid(), SIGUSR1);
		close(fileno(stdin));
		close(fileno(stdout));
		close(fileno(stderr));
	}
	unset_timer();

	int server = socket(AF_UNIX, SOCK_STREAM, 0);
	if(server < 0)
		panic_errno("socket");

	struct sockaddr_un addr;
	memset(&addr, 0, sizeof addr);
	addr.sun_family = AF_UNIX;
	strncpy(addr.sun_path, (conf_sockdir + "/socket_" + ident).c_str(), sizeof addr.sun_path - 1);
	if(bind(server, (struct sockaddr *)&addr, sizeof addr))
		panic_errno("bind");

	if(listen(server, 1))
		panic_errno("listen");

	int client = accept(server, NULL, NULL);
	if(client < 0)
		panic_errno("accept");

	close(server);
	unlink((conf_sockdir + "/socket_" + ident).c_str());

	feed_in = new std::thread(feed_data, client, in_pipe[1], false, !conf_wakeup);
	feed_out = new std::thread(feed_data, out_pipe[0], client, false, false);

	old_client = client;
	set_timer();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movq 0x8136(%rip), %rax      # 0x13488
movq (%rax), %rdi
callq 0x4570
movq 0x8127(%rip), %rdi      # 0x13488
callq 0x4740
movl 0x8114(%rip), %ebx      # 0x13480
movl %ebx, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0x4260
orl $0x800, %eax            # imm = 0x800
movl %ebx, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x4260
movq 0x80fa(%rip), %rax      # 0x13490
movq (%rax), %rdi
movl $0xa, %esi
callq 0x44f0
movq 0x80e6(%rip), %rdi      # 0x13490
callq 0x4740
movl 0x80cb(%rip), %ebx      # 0x13480
movl %ebx, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0x4260
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %ebx, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x4260
movq 0x80a9(%rip), %rdi      # 0x13488
testq %rdi, %rdi
je 0xb3ee
cmpq $0x0, (%rdi)
jne 0xb879
movl $0x8, %esi
callq 0x43e0
movq 0x8091(%rip), %rdi      # 0x13490
testq %rdi, %rdi
je 0xb40e
cmpq $0x0, (%rdi)
jne 0xb879
movl $0x8, %esi
callq 0x43e0
movl 0x8002(%rip), %edi      # 0x13420
cmpl $-0x1, %edi
jne 0xb471
callq 0x4580
movl %eax, %edi
movl $0xa, %esi
callq 0x45a0
movq 0x7b75(%rip), %rax      # 0x12fb0
movq (%rax), %rdi
callq 0x4420
movl %eax, %edi
callq 0x47e0
movq 0x7b37(%rip), %rax      # 0x12f88
movq (%rax), %rdi
callq 0x4420
movl %eax, %edi
callq 0x47e0
movq 0x7b71(%rip), %rax      # 0x12fd8
movq (%rax), %rdi
callq 0x4420
movl %eax, %edi
callq 0x47e0
callq 0xb2fd
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x40d0
movl %eax, %ebx
testl %eax, %eax
jns 0xb4e1
leaq 0xc0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x34ac(%rip), %rsi      # 0xe951
leaq 0x34ab(%rip), %rdx      # 0xe957
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x9234
movq %r14, %rdi
callq 0xa3cc
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0xb4e1
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x43e0
xorps %xmm0, %xmm0
movups %xmm0, 0x130(%rsp)
movups %xmm0, 0x124(%rsp)
movups %xmm0, 0x114(%rsp)
movups %xmm0, 0x104(%rsp)
movups %xmm0, 0xf4(%rsp)
movups %xmm0, 0xe4(%rsp)
movups %xmm0, 0xd4(%rsp)
movw $0x1, 0xd2(%rsp)
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x8092(%rip), %r13      # 0x135c8
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x8eda
leaq 0x3403(%rip), %rsi      # 0xe958
movq %r14, %rdi
callq 0x47c0
movq 0x7f0c(%rip), %rsi      # 0x13470
leaq 0x10(%rsp), %rdi
callq 0x47c0
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb596
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0xb59e
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xd4(%rsp), %rdi
movq 0x30(%rsp), %r14
movl $0x6b, %edx
movq %r14, %rsi
callq 0x4200
cmpq %r12, %r14
je 0xb5e5
movq 0x40(%rsp), %rsi
incq %rsi
movq %r14, %rdi
callq 0x43e0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xb5fc
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
leaq 0xd2(%rsp), %rsi
movl %ebx, %edi
movl $0x6e, %edx
callq 0x4090
testl %eax, %eax
je 0xb665
leaq 0xa0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x333a(%rip), %rsi      # 0xe961
leaq 0x3337(%rip), %rdx      # 0xe965
leaq 0x90(%rsp), %rdi
callq 0x9234
leaq 0x90(%rsp), %rdi
callq 0xa3cc
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0xb665
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43e0
movl %ebx, %edi
movl $0x1, %esi
callq 0x4440
testl %eax, %eax
je 0xb6bd
leaq 0x80(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x32de(%rip), %rsi      # 0xe966
leaq 0x32dd(%rip), %rdx      # 0xe96c
leaq 0x70(%rsp), %rdi
callq 0x9234
leaq 0x70(%rsp), %rdi
callq 0xa3cc
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0xb6bd
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43e0
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4150
movl %eax, 0xc(%rsp)
testl %eax, %eax
jns 0xb712
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x328d(%rip), %rsi      # 0xe96d
leaq 0x328c(%rip), %rdx      # 0xe973
leaq 0x50(%rsp), %rdi
callq 0x9234
leaq 0x50(%rsp), %rdi
callq 0xa3cc
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0xb712
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
movl %ebx, %edi
callq 0x47e0
leaq 0x10(%rsp), %rbx
movq %r15, (%rbx)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x8eda
leaq 0x321d(%rip), %rsi      # 0xe958
movq %rbx, %rdi
callq 0x47c0
movq 0x7d26(%rip), %rsi      # 0x13470
leaq 0x10(%rsp), %rdi
callq 0x47c0
movq %r12, 0x30(%rsp)
movq (%rax), %rdi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdi
je 0xb777
movq %rdi, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0xb782
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq %r12, %rdi
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x41d0
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0xb7b6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xb7cd
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
movl $0x8, %edi
callq 0x43d0
movq %rax, %r14
leaq 0x30(%rsp), %r8
movb $0x0, (%r8)
leaq 0x7dfe(%rip), %rax      # 0x135e8
movb (%rax), %al
xorb $0x1, %al
leaq 0x10(%rsp), %r9
movb %al, (%r9)
leaq -0x685(%rip), %rsi      # 0xb178
leaq 0x7c78(%rip), %rcx      # 0x1347c
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
callq 0xc218
movq %r14, 0x7c70(%rip)      # 0x13488
movl $0x8, %edi
callq 0x43d0
movq %rax, %r14
xorl %eax, %eax
leaq 0x30(%rsp), %r8
movb %al, (%r8)
leaq 0x10(%rsp), %r9
movb %al, (%r9)
leaq -0x6c6(%rip), %rsi      # 0xb178
leaq 0x7c3b(%rip), %rdx      # 0x13480
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
callq 0xc218
movq %r14, 0x7c37(%rip)      # 0x13490
movl 0xc(%rsp), %eax
movl %eax, 0x7bbd(%rip)      # 0x13420
callq 0xb2b6
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x4100
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0xb919
movq 0x60(%rsp), %rsi
jmp 0xb911
jmp 0xb8e5
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0xb919
movq 0xc0(%rsp), %rsi
jmp 0xb911
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0xb919
movq 0x80(%rsp), %rsi
jmp 0xb911
jmp 0xb8e5
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0xb919
movq 0xa0(%rsp), %rsi
jmp 0xb911
movq %rax, %rbx
jmp 0xb919
jmp 0xb8ec
movq %rax, %rbx
movl $0x8, %esi
movq %r14, %rdi
jmp 0xb914
jmp 0xb8ff
jmp 0xb8ff
jmp 0xb8ff
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xb919
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x4770