// File: /workspace/github_cpp_makefile_star2_O2/mniip[P]sandbox/wakeup.cpp
// Function: kill_session()
void kill_session()
{
	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))
	{
		if(errno == ENOENT)
			return;
		int err = errno;
		unlink(("socket_" + std::string(ident)).c_str());
		errno = err;
		panic_errno("connect");
	}

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

	struct ucred creds;
	socklen_t len = sizeof creds;
	if(getsockopt(server, SOL_SOCKET, SO_PEERCRED, &creds, &len))
		panic_errno("getsockopt SO_PEERCRED");
	if(kill(creds.pid, SIGTERM))
		panic_errno("kill");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
pushq $0x1
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x4100
movl %eax, %ebx
testl %eax, %eax
jns 0x9fd7
leaq 0x295e(%rip), %rsi      # 0xc906
leaq 0xa8(%rsp), %rdi
leaq 0xca(%rsp), %rdx
callq 0x5422
leaq 0xa8(%rsp), %rdi
callq 0x8e3a
leaq 0xa8(%rsp), %rdi
callq 0x4828
xorps %xmm0, %xmm0
movups %xmm0, 0x128(%rsp)
movups %xmm0, 0x11c(%rsp)
movups %xmm0, 0x10c(%rsp)
movups %xmm0, 0xfc(%rsp)
movups %xmm0, 0xec(%rsp)
movups %xmm0, 0xdc(%rsp)
movups %xmm0, 0xcc(%rsp)
movw $0x1, 0xca(%rsp)
leaq 0x85b5(%rip), %rsi      # 0x125d8
leaq 0x28e3(%rip), %rdx      # 0xc90d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x8a05
movq 0x8442(%rip), %rdx      # 0x12480
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x9084
leaq 0xcc(%rsp), %rdi
leaq 0x28(%rsp), %r14
movq (%r14), %rsi
pushq $0x6b
popq %rdx
callq 0x4240
movq %r14, %rdi
callq 0x4828
leaq 0x8(%rsp), %rdi
callq 0x4828
leaq 0xca(%rsp), %rsi
pushq $0x6e
popq %rdx
movl %ebx, %edi
callq 0x4380
testl %eax, %eax
je 0xa123
callq 0x4050
movl (%rax), %ebp
cmpl $0x2, %ebp
je 0xa1fa
movq %rax, %r14
movq 0x83d7(%rip), %rsi      # 0x12480
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x5422
leaq 0x284f(%rip), %rsi      # 0xc90e
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x8a3d
leaq 0x28(%rsp), %r15
movq (%r15), %rdi
callq 0x4210
movq %r15, %rdi
callq 0x4828
leaq 0x8(%rsp), %rdi
callq 0x4828
movl %ebp, (%r14)
leaq 0x2832(%rip), %rsi      # 0xc929
leaq 0x88(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x5422
leaq 0x88(%rsp), %rdi
callq 0x8e3a
leaq 0x88(%rsp), %rdi
callq 0x4828
leaq 0x84ae(%rip), %rsi      # 0x125d8
leaq 0x27dc(%rip), %rdx      # 0xc90d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x8a05
movq 0x833b(%rip), %rdx      # 0x12480
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x9084
leaq 0x28(%rsp), %r14
movq (%r14), %rdi
callq 0x4210
movq %r14, %rdi
callq 0x4828
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x4828
movl $0xc, (%r14)
pushq $0x1
popq %rsi
pushq $0x11
popq %rdx
leaq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %r8
movl %ebx, %edi
callq 0x4330
testl %eax, %eax
je 0xa1c0
leaq 0x2794(%rip), %rsi      # 0xc931
leaq 0x68(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x5422
leaq 0x68(%rsp), %rdi
callq 0x8e3a
leaq 0x68(%rsp), %rdi
callq 0x4828
movl 0x28(%rsp), %edi
pushq $0xf
popq %rsi
callq 0x45d0
testl %eax, %eax
je 0xa1fa
leaq 0x2330(%rip), %rsi      # 0xc507
leaq 0x48(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x5422
leaq 0x48(%rsp), %rdi
callq 0x8e3a
leaq 0x48(%rsp), %rdi
callq 0x4828
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0xa24f
jmp 0xa240
jmp 0xa247
jmp 0xa240
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0xa24f
jmp 0xa240
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0xa24f
jmp 0xa240
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0xa24f
movq %rax, %rbx
jmp 0xa254
jmp 0xa247
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4828
movq %rbx, %rdi
callq 0x4770