// File: /workspace/github_cpp_makefile_star2_O3/liskin[P]hybrid-screenclone/screenclone.cc
// Function: main
int main( int argc, char *argv[] )
{
	XInitThreads();

	std::string src_name( ":0" ), dst_name( ":1" );
	unsigned screen_number = 0;

	int opt;
	while ( ( opt = getopt( argc, argv, "s:d:x:h" ) ) != -1 )
		switch ( opt ) {
		case 's':
			src_name = optarg;
			break;
		case 'd':
			dst_name = optarg;
			break;
		case 'x':
			screen_number = atoi( optarg );
			break;
		default:
			usage( argv[ 0 ] );
		}

	if ( src_name == dst_name )
		ERR;
	display src( src_name ), dst( dst_name );

	auto screens = src.xinerama_screens();
	if ( screen_number < 0 || screen_number >= screens.size() )
		ERR;
	auto &screen = screens[ screen_number ];

	// Clone src not to fight with the blocking loop.
	mouse_replayer mouse( src.clone(), dst, screen );
	image_replayer image( src, dst, screen );

	window root = src.root();
	root.create_damage();

	src.record_pointer_events( &mouse );
	src.select_cursor_input( root );

	for ( ;; ) {
		do {
			const XEvent e = src.next_event();
			if ( e.type == src.damage_event + XDamageNotify ) {
				const XDamageNotifyEvent &de = * (const XDamageNotifyEvent *) &e;
				image.damage( de.area );
			} else if ( e.type == src.xfixes_event + XFixesCursorNotify ) {
				mouse.cursor_changed();
			}
		} while ( src.pending() );

		root.clear_damage();
		image.copy_if_damaged();
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rsi, %r14
movl %edi, %ebp
callq 0x2180
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2317(%rip), %rsi      # 0x60f2
leaq 0x2312(%rip), %rdx      # 0x60f4
leaq 0x88(%rsp), %rdi
callq 0x552a
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x22f6(%rip), %rsi      # 0x60f5
leaq 0x22f1(%rip), %rdx      # 0x60f7
leaq 0x68(%rsp), %rdi
callq 0x552a
movq $0x0, 0x40(%rsp)
movq 0x5198(%rip), %r13      # 0x8fb8
movl %ebp, %edi
movq %r14, %rsi
leaq 0x22cc(%rip), %rdx      # 0x60f8
callq 0x2040
cmpl $0x72, %eax
jle 0x3e45
cmpl $0x73, %eax
jne 0x3e75
leaq 0x88(%rsp), %r12
jmp 0x3e4f
leaq 0x68(%rsp), %r12
cmpl $0x64, %eax
jne 0x3e8e
movq (%r13), %r15
movq 0x8(%r12), %rbx
movq %r15, %rdi
callq 0x2090
movq %r12, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x2350
jmp 0x3e20
cmpl $0x78, %eax
jne 0x3f28
movq (%r13), %rdi
callq 0x2360
movq %rax, 0x40(%rsp)
jmp 0x3e20
cmpl $-0x1, %eax
jne 0x3f28
movq 0x90(%rsp), %rdx
cmpq 0x70(%rsp), %rdx
jne 0x3f30
testq %rdx, %rdx
je 0x3ec5
movq 0x68(%rsp), %rsi
movq 0x88(%rsp), %rdi
callq 0x2230
testl %eax, %eax
jne 0x3f30
movl $0x10, %edi
callq 0x20c0
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x2113(%rip), %rsi      # 0x6004
leaq 0xa8(%rsp), %rdi
callq 0x2420
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4154
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x4161
movq (%r14), %rdi
callq 0x3d11
leaq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x25b0
leaq 0x220(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x25b0
leaq 0xc8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x31ce
movl 0x40(%rsp), %ebx
movq 0xc8(%rsp), %r14
movq 0xd0(%rsp), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
cmpq %rbx, %rcx
jbe 0x4203
leaq 0x238(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2dd2
leaq (%rbx,%rbx,2), %rax
leaq (%r14,%rax,8), %rbx
leaq 0xe0(%rsp), %rdi
leaq 0x238(%rsp), %rsi
leaq 0x220(%rsp), %rdx
movq %rbx, %rcx
callq 0x480a
leaq 0x178(%rsp), %rdi
leaq 0x28(%rsp), %r14
leaq 0x220(%rsp), %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x48f8
movq 0x28(%rsp), %rax
movq 0xe8(%rax), %rcx
movslq 0xe0(%rax), %rax
shlq $0x7, %rax
movq 0x10(%rcx,%rax), %rax
leaq 0x8(%rsp), %rdi
movq %r14, (%rdi)
movq %rax, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
callq 0x35bc
leaq 0x28(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x4aa2
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x21f0
leaq 0x238(%rsp), %rbx
leaq 0x28(%rsp), %r14
leaq 0x8(%rsp), %r15
leaq 0x178(%rsp), %r12
leaq 0xe0(%rsp), %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e7e
movl 0x238(%rsp), %eax
cmpl 0x30(%rsp), %eax
jne 0x4110
movb $0x1, %al
cmpb $0x0, 0x218(%rsp)
jne 0x4126
movq 0x188(%rsp), %rax
movswl 0x278(%rsp), %ecx
movzwl 0x27c(%rsp), %edx
addl %ecx, %edx
movswl 0xc(%rax), %esi
movswl 0x10(%rax), %edi
addl %esi, %edi
xorl %r8d, %r8d
cmpl %esi, %edx
setg %r8b
xorl %edx, %edx
cmpl %ecx, %edi
setg %dl
cmpw %si, %cx
cmovll %r8d, %edx
cmpb $0x1, %dl
jne 0x4124
movswl 0x27a(%rsp), %ecx
movzwl 0x27e(%rsp), %edx
addl %ecx, %edx
movswl 0xe(%rax), %esi
movswl 0x12(%rax), %edi
addl %esi, %edi
xorl %r8d, %r8d
cmpl %esi, %edx
setg %r8b
xorl %eax, %eax
cmpl %ecx, %edi
setg %al
cmpw %si, %cx
cmovll %r8d, %eax
jmp 0x4126
movl 0x38(%rsp), %ecx
incl %ecx
cmpl %ecx, %eax
jne 0x412d
movq %r13, %rdi
callq 0x537c
jmp 0x412d
xorl %eax, %eax
movb %al, 0x218(%rsp)
movq 0x28(%rsp), %rdi
callq 0x21a0
testl %eax, %eax
jne 0x406f
movq %r15, %rdi
callq 0x38fa
movq %r12, %rdi
callq 0x549a
jmp 0x406f
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
movq 0x8(%rax), %rdx
leaq 0x48(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1f03(%rip), %rsi      # 0x6087
callq 0x2420
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x41ab
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x41b8
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1f25(%rip), %rsi      # 0x6100
callq 0x2420
leaq 0xf0(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4266
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4279
movl $0x10, %edi
callq 0x20c0
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x1dd5(%rip), %rsi      # 0x6004
leaq 0xa8(%rsp), %rdi
callq 0x2420
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4328
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x4335
movq %rdx, 0xe0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf0(%rsp)
movq 0x8(%rax), %rdx
leaq 0xe0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1dd4(%rip), %rsi      # 0x6073
callq 0x2420
leaq 0x188(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x42c7
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x42da
movq %rdx, 0x178(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x188(%rsp)
movq 0x8(%rax), %rdx
leaq 0x178(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1e04(%rip), %rsi      # 0x6104
callq 0x2420
leaq 0x248(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x437f
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4392
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
movq 0x8(%rax), %rdx
leaq 0x48(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1d2f(%rip), %rsi      # 0x6087
callq 0x2420
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x43d9
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x43e6
movq %rdx, 0x238(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x248(%rsp)
movq 0x8(%rax), %rdx
leaq 0x238(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x2380
xorl %ebp, %ebp
movq 0x4c2b(%rip), %rsi      # 0x8ff0
movq 0x4bfc(%rip), %rdx      # 0x8fc8
movq %r14, %rdi
callq 0x23b0
jmp 0x4548
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1d00(%rip), %rsi      # 0x6109
callq 0x2420
leaq 0xf0(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4431
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4444
movq %rdx, 0xe0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf0(%rsp)
movq 0x8(%rax), %rdx
leaq 0xe0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1c09(%rip), %rsi      # 0x6073
callq 0x2420
leaq 0x188(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4492
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x44a5
movq %rdx, 0x178(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x188(%rsp)
movq 0x8(%rax), %rdx
leaq 0x178(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1c39(%rip), %rsi      # 0x6104
callq 0x2420
leaq 0x248(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x44f3
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4506
movq %rdx, 0x238(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x248(%rsp)
movq 0x8(%rax), %rdx
leaq 0x238(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x2380
xorl %ebp, %ebp
movq 0x4ab7(%rip), %rsi      # 0x8ff0
movq 0x4a88(%rip), %rdx      # 0x8fc8
movq %r14, %rdi
callq 0x23b0
movq %rax, %rbx
jmp 0x479e
jmp 0x46e1
jmp 0x46e1
jmp 0x46e1
movq %rax, %rbx
movq 0x238(%rsp), %rdi
leaq 0x248(%rsp), %rax
cmpq %rax, %rdi
je 0x458f
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x458f
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x188(%rsp), %rax
movq 0x178(%rsp), %rdi
cmpq %rax, %rdi
je 0x45bc
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x45bc
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0x45ee
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x45ee
jmp 0x46e1
movq %rax, %rbx
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x4612
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x4612
jmp 0x46e1
movq %rax, %rbx
movb $0x1, %bpl
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x4688
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x4688
movq %rax, %rbx
movq 0x238(%rsp), %rdi
leaq 0x248(%rsp), %rax
cmpq %rax, %rdi
je 0x465b
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x465b
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x188(%rsp), %rax
movq 0x178(%rsp), %rdi
cmpq %rax, %rdi
je 0x46ba
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x46ba
movq %rax, %rbx
movb $0x1, %bpl
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46a5
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2220
testb %bpl, %bpl
je 0x46e4
movq %r14, %rdi
callq 0x2120
jmp 0x46e4
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0x470d
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x470d
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x4782
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2220
jmp 0x4782
movq %rax, %rbx
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x472e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x472e
jmp 0x477f
movq %rax, %rbx
movb $0x1, %bpl
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x474f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x474f
jmp 0x477f
movq %rax, %rbx
movb $0x1, %bpl
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x476c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2220
testb %bpl, %bpl
je 0x4782
movq %r14, %rdi
callq 0x2120
jmp 0x4782
jmp 0x477f
jmp 0x477f
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x479e
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2220
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x47c3
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x23e0
nop