// File: mniip[P]sandbox/wakeup.cpp
// Function: try_connect()
void try_connect()
{
	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(connect(server, (struct sockaddr *)&addr, sizeof addr))
	{
		unlink((conf_sockdir + "/socket_" + ident).c_str());
		return;
	}

	std::thread feed_in(feed_data, fileno(stdin), server, false, !conf_wakeup);
	feed_data(server, fileno(stdout), false, false);
	exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x5120
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jge 0x14e7b
leaq -0x29(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x5900
movq -0x148(%rbp), %rdx
leaq 0x75d9(%rip), %rsi      # 0x1c3f9
leaq -0x28(%rbp), %rdi
callq 0x72d0
jmp 0x14e2b
leaq -0x28(%rbp), %rdi
callq 0x130c0
jmp 0x14e36
leaq -0x28(%rbp), %rdi
callq 0x59b8
leaq -0x29(%rbp), %rdi
callq 0x5560
jmp 0x14e7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x14e6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x59b8
leaq -0x29(%rbp), %rdi
callq 0x5560
jmp 0x1509d
xorps %xmm0, %xmm0
movups %xmm0, -0x52(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movw $0x1, -0xb0(%rbp)
leaq -0xae(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq 0x127df(%rip), %rsi     # 0x276a0
leaq 0x7538(%rip), %rdx      # 0x1c400
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x10ec0
movq -0x150(%rbp), %rsi
movq 0x1265f(%rip), %rdx     # 0x27548
leaq -0xd0(%rbp), %rdi
callq 0x13520
jmp 0x14ef7
leaq -0xd0(%rbp), %rdi
callq 0x5200
movq -0x158(%rbp), %rdi
movq %rax, %rsi
movl $0x6b, %edx
callq 0x52a0
leaq -0xd0(%rbp), %rdi
callq 0x59b8
leaq -0xf0(%rbp), %rdi
callq 0x59b8
movl -0x4(%rbp), %edi
leaq -0xb0(%rbp), %rsi
movl $0x6e, %edx
callq 0x5410
cmpl $0x0, %eax
je 0x14ff8
leaq 0x1274d(%rip), %rsi     # 0x276a0
leaq 0x74a6(%rip), %rdx      # 0x1c400
leaq -0x130(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x10ec0
movq -0x160(%rbp), %rsi
movq 0x125cd(%rip), %rdx     # 0x27548
leaq -0x110(%rbp), %rdi
callq 0x13520
jmp 0x14f89
leaq -0x110(%rbp), %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5270
leaq -0x110(%rbp), %rdi
callq 0x59b8
leaq -0x130(%rbp), %rdi
callq 0x59b8
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x59b8
jmp 0x1509d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x59b8
jmp 0x1509d
movq 0x11fc9(%rip), %rax     # 0x26fc8
movq (%rax), %rdi
callq 0x5540
movl %eax, -0x13c(%rbp)
movb $0x0, -0x13d(%rbp)
leaq 0x126a5(%rip), %rax     # 0x276c0
movb (%rax), %al
notb %al
andb $0x1, %al
movb %al, -0x13e(%rbp)
leaq -0xb6e(%rip), %rsi      # 0x144c0
leaq -0x138(%rbp), %rdi
leaq -0x13c(%rbp), %rdx
leaq -0x4(%rbp), %rcx
leaq -0x13d(%rbp), %r8
leaq -0x13e(%rbp), %r9
callq 0x77f0
movl -0x4(%rbp), %eax
movl %eax, -0x164(%rbp)
movq 0x11f3d(%rip), %rax     # 0x26fa0
movq (%rax), %rdi
callq 0x5540
movl -0x164(%rbp), %edi
movl %eax, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x144c0
jmp 0x1507e
xorl %edi, %edi
callq 0x55e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x15790
movq -0x38(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)