// File: liskin[P]hybrid-screenclone/screenclone.cc
// Function: void display::record_pointer_events<mouse_replayer>(mouse_replayer*)
void display::record_pointer_events( Fun *callback ) {
	display data = clone();

	XRecordRange *rr = XRecordAllocRange();
	if ( !rr ) ERR;
	rr->device_events.first = rr->device_events.last = MotionNotify;

	XRecordClientSpec rcs = XRecordAllClients;

	XRecordContext rc = XRecordCreateContext( dpy, 0, &rcs, 1, &rr, 1 );
	if ( !rc ) ERR;

	// sync, otherwise XRecordEnableContextAsync fails
	XSync( dpy, false );
	XSync( data.dpy, false );

	if ( !XRecordEnableContextAsync( data.dpy, rc, &record_callback< Fun >, (XPointer) callback ) )
		ERR;

	std::thread( &record_thread< Fun >, data, callback ).detach();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x2b8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3ce0
callq 0x3560
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5a08
movb $0x1, -0xfd(%rbp)
movl $0x10, %edi
callq 0x30f0
movq %rax, -0x2c8(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x33e0
movq -0x2c0(%rbp), %rsi
leaq 0x2780(%rip), %rdx      # 0x8004
leaq -0xd0(%rbp), %rdi
callq 0x51b0
jmp 0x5892
leaq 0x27ee(%rip), %rdx      # 0x8087
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x51b0
jmp 0x58ae
leaq 0x289c(%rip), %rdx      # 0x8151
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x51b0
jmp 0x58ca
leaq 0x27a2(%rip), %rdx      # 0x8073
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x51b0
jmp 0x58e3
leaq 0x286b(%rip), %rdx      # 0x8155
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x51b0
jmp 0x58f9
movq -0x2c8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3490
jmp 0x590b
movq -0x2c8(%rbp), %rdi
movb $0x0, -0xfd(%rbp)
movq 0x66d0(%rip), %rsi      # 0xbff0
movq 0x66a1(%rip), %rdx      # 0xbfc8
callq 0x34d0
jmp 0x5eb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x59e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x59d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x59c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x59bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x59b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3150
leaq -0x70(%rbp), %rdi
callq 0x3150
leaq -0x90(%rbp), %rdi
callq 0x3150
leaq -0xb0(%rbp), %rdi
callq 0x3150
leaq -0xd0(%rbp), %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
testb $0x1, -0xfd(%rbp)
jne 0x59f7
jmp 0x5a03
movq -0x2c8(%rbp), %rdi
callq 0x31a0
jmp 0x5ea9
movq -0x2b8(%rbp), %rax
movq -0x30(%rbp), %rcx
movb $0x6, 0x13(%rcx)
movq -0x30(%rbp), %rcx
movb $0x6, 0x12(%rcx)
movq $0x3, -0x108(%rbp)
movq (%rax), %rdi
xorl %esi, %esi
leaq -0x108(%rbp), %rdx
movl $0x1, %r9d
leaq -0x30(%rbp), %r8
movl %r9d, %ecx
callq 0x34b0
movq %rax, -0x110(%rbp)
cmpq $0x0, -0x110(%rbp)
jne 0x5c2c
movb $0x1, -0x1d1(%rbp)
movl $0x10, %edi
callq 0x30f0
movq %rax, -0x2d8(%rbp)
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x33e0
movq -0x2d0(%rbp), %rsi
leaq 0x256e(%rip), %rdx      # 0x8004
leaq -0x1b0(%rbp), %rdi
callq 0x51b0
jmp 0x5aa4
leaq 0x25dc(%rip), %rdx      # 0x8087
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x51b0
jmp 0x5ac0
leaq 0x26a4(%rip), %rdx      # 0x816b
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x51b0
jmp 0x5adc
leaq 0x2590(%rip), %rdx      # 0x8073
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x51b0
jmp 0x5af8
leaq 0x2656(%rip), %rdx      # 0x8155
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x51b0
jmp 0x5b14
movq -0x2d8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3490
jmp 0x5b29
movq -0x2d8(%rbp), %rdi
movb $0x0, -0x1d1(%rbp)
movq 0x64b2(%rip), %rsi      # 0xbff0
movq 0x6483(%rip), %rdx      # 0xbfc8
callq 0x34d0
jmp 0x5eb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5c04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5bf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5be0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5bd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x3150
leaq -0x150(%rbp), %rdi
callq 0x3150
leaq -0x170(%rbp), %rdi
callq 0x3150
leaq -0x190(%rbp), %rdi
callq 0x3150
leaq -0x1b0(%rbp), %rdi
callq 0x3150
leaq -0x1d0(%rbp), %rdi
callq 0x3150
testb $0x1, -0x1d1(%rbp)
jne 0x5c1b
jmp 0x5c27
movq -0x2d8(%rbp), %rdi
callq 0x31a0
jmp 0x5ea9
movq -0x2b8(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x3540
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x3540
movq -0x28(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq -0x10(%rbp), %rcx
leaq 0x1522(%rip), %rdx      # 0x7180
callq 0x34c0
cmpl $0x0, %eax
jne 0x5e38
movb $0x1, -0x299(%rbp)
movl $0x10, %edi
callq 0x30f0
movq %rax, -0x2e8(%rbp)
leaq -0x298(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x33e0
movq -0x2e0(%rbp), %rsi
leaq 0x235f(%rip), %rdx      # 0x8004
leaq -0x278(%rbp), %rdi
callq 0x51b0
jmp 0x5cb3
leaq 0x23cd(%rip), %rdx      # 0x8087
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x51b0
jmp 0x5ccf
leaq 0x2499(%rip), %rdx      # 0x816f
leaq -0x238(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x51b0
jmp 0x5ceb
leaq 0x2381(%rip), %rdx      # 0x8073
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x51b0
jmp 0x5d07
leaq 0x2447(%rip), %rdx      # 0x8155
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x51b0
jmp 0x5d23
movq -0x2e8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x3490
jmp 0x5d38
movq -0x2e8(%rbp), %rdi
movb $0x0, -0x299(%rbp)
movq 0x62a3(%rip), %rsi      # 0xbff0
movq 0x6274(%rip), %rdx      # 0xbfc8
callq 0x34d0
jmp 0x5eb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5e13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5e07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5dfb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5def
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
jmp 0x5de3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3150
leaq -0x218(%rbp), %rdi
callq 0x3150
leaq -0x238(%rbp), %rdi
callq 0x3150
leaq -0x258(%rbp), %rdi
callq 0x3150
leaq -0x278(%rbp), %rdi
callq 0x3150
leaq -0x298(%rbp), %rdi
callq 0x3150
testb $0x1, -0x299(%rbp)
jne 0x5e2a
jmp 0x5e36
movq -0x2e8(%rbp), %rdi
callq 0x31a0
jmp 0x5ea9
leaq 0x1371(%rip), %rax      # 0x71b0
movq %rax, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
leaq -0x2b0(%rbp), %rsi
leaq -0x28(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x7290
movq -0x2f0(%rbp), %rdi
callq 0x34f0
jmp 0x5e76
leaq -0x2a8(%rbp), %rdi
callq 0x7360
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x7360
movq -0xf8(%rbp), %rdi
callq 0x3500
nopw %cs:(%rax,%rax)
nop