// File: /workspace/github_cpp_makefile_star2_O1/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 0x8f68(%rip), %rax      # 0x14488
movq (%rax), %rdi
callq 0x4570
movq 0x8f59(%rip), %rdi      # 0x14488
callq 0x4740
movl 0x8f46(%rip), %ebx      # 0x14480
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 0x8f2c(%rip), %rax      # 0x14490
movq (%rax), %rdi
movl $0xa, %esi
callq 0x44f0
movq 0x8f18(%rip), %rdi      # 0x14490
callq 0x4740
movl 0x8efd(%rip), %ebx      # 0x14480
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 0x8edb(%rip), %rdi      # 0x14488
testq %rdi, %rdi
je 0xb5c6
cmpq $0x0, (%rdi)
jne 0xba49
movl $0x8, %esi
callq 0x43e0
movq 0x8ec3(%rip), %rdi      # 0x14490
testq %rdi, %rdi
je 0xb5e6
cmpq $0x0, (%rdi)
jne 0xba49
movl $0x8, %esi
callq 0x43e0
movl 0x8e34(%rip), %edi      # 0x14420
cmpl $-0x1, %edi
jne 0xb63f
callq 0x4580
movl %eax, %edi
movl $0xa, %esi
callq 0x45a0
movq 0x89a7(%rip), %rax      # 0x13fb0
movq (%rax), %rdi
callq 0x4420
movl %eax, %edi
callq 0x47e0
movq 0x8969(%rip), %rax      # 0x13f88
movq (%rax), %rdi
callq 0x4420
movl %eax, %edi
callq 0x47e0
movq 0x89a3(%rip), %rax      # 0x13fd8
movq (%rax), %rdi
callq 0x4420
movl %eax, %edi
callq 0x47e0
callq 0xb4c9
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x40d0
movl %eax, %ebx
testl %eax, %eax
jns 0xb6af
leaq 0xc0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x42de(%rip), %rsi      # 0xf951
leaq 0x42dd(%rip), %rdx      # 0xf957
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x9376
movq %r14, %rdi
callq 0xa5a4
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0xb6af
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x43e0
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movups %xmm0, 0x12e(%rsp)
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movw $0x1, 0xd0(%rsp)
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x8ec4(%rip), %r13      # 0x145c8
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x8ff2
leaq 0x4235(%rip), %rsi      # 0xf958
movq %r14, %rdi
callq 0x47c0
movq 0x8d3e(%rip), %rsi      # 0x14470
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 0xb764
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0xb76c
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 0xd2(%rsp), %rdi
movq 0x30(%rsp), %r14
movl $0x6b, %edx
movq %r14, %rsi
callq 0x4200
cmpq %r12, %r14
je 0xb7b3
movq 0x40(%rsp), %rsi
incq %rsi
movq %r14, %rdi
callq 0x43e0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xb7ca
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
leaq 0xd0(%rsp), %rsi
movl %ebx, %edi
movl $0x6e, %edx
callq 0x4090
testl %eax, %eax
je 0xb833
leaq 0xa0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x416c(%rip), %rsi      # 0xf961
leaq 0x4169(%rip), %rdx      # 0xf965
leaq 0x90(%rsp), %rdi
callq 0x9376
leaq 0x90(%rsp), %rdi
callq 0xa5a4
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0xb833
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43e0
movl %ebx, %edi
movl $0x1, %esi
callq 0x4440
testl %eax, %eax
je 0xb88b
leaq 0x80(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4110(%rip), %rsi      # 0xf966
leaq 0x410f(%rip), %rdx      # 0xf96c
leaq 0x70(%rsp), %rdi
callq 0x9376
leaq 0x70(%rsp), %rdi
callq 0xa5a4
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0xb88b
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 0xb8e0
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x40bf(%rip), %rsi      # 0xf96d
leaq 0x40be(%rip), %rdx      # 0xf973
leaq 0x50(%rsp), %rdi
callq 0x9376
leaq 0x50(%rsp), %rdi
callq 0xa5a4
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0xb8e0
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 0x8ff2
leaq 0x404f(%rip), %rsi      # 0xf958
movq %rbx, %rdi
callq 0x47c0
movq 0x8b58(%rip), %rsi      # 0x14470
leaq 0x10(%rsp), %rdi
callq 0x47c0
movq %r12, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb945
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0xb94d
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)
movq 0x30(%rsp), %rdi
callq 0x41d0
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0xb986
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xb99d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
movl $0x8, %edi
callq 0x43d0
movq %rax, %r14
leaq 0x30(%rsp), %r8
movb $0x0, (%r8)
leaq 0x8c2e(%rip), %rax      # 0x145e8
movb (%rax), %al
xorb $0x1, %al
leaq 0x10(%rsp), %r9
movb %al, (%r9)
leaq -0x689(%rip), %rsi      # 0xb344
leaq 0x8aa8(%rip), %rcx      # 0x1447c
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
callq 0xc42c
movq %r14, 0x8aa0(%rip)      # 0x14488
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 -0x6ca(%rip), %rsi      # 0xb344
leaq 0x8a6b(%rip), %rdx      # 0x14480
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
callq 0xc42c
movq %r14, 0x8a67(%rip)      # 0x14490
movl 0xc(%rsp), %eax
movl %eax, 0x89ed(%rip)      # 0x14420
callq 0xb482
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 0xbae9
movq 0x60(%rsp), %rsi
jmp 0xbae1
jmp 0xbab5
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0xbae9
movq 0xc0(%rsp), %rsi
jmp 0xbae1
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0xbae9
movq 0x80(%rsp), %rsi
jmp 0xbae1
jmp 0xbab5
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0xbae9
movq 0xa0(%rsp), %rsi
jmp 0xbae1
movq %rax, %rbx
jmp 0xbae9
jmp 0xbabc
movq %rax, %rbx
movl $0x8, %esi
movq %r14, %rdi
jmp 0xbae4
jmp 0xbacf
jmp 0xbacf
jmp 0xbacf
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0xbae9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x4770