// File: /workspace/github_cpp_makefile_star2_O1/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 0x2319(%rip), %rsi      # 0x60f2
leaq 0x2314(%rip), %rdx      # 0x60f4
leaq 0x88(%rsp), %rdi
callq 0x553e
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x22f8(%rip), %rsi      # 0x60f5
leaq 0x22f3(%rip), %rdx      # 0x60f7
leaq 0x68(%rsp), %rdi
callq 0x553e
movq $0x0, 0x40(%rsp)
movq 0x519a(%rip), %r13      # 0x8fb8
movl %ebp, %edi
movq %r14, %rsi
leaq 0x22ce(%rip), %rdx      # 0x60f8
callq 0x2040
cmpl $0x72, %eax
jle 0x3e43
cmpl $0x73, %eax
jne 0x3e73
leaq 0x88(%rsp), %r12
jmp 0x3e4d
leaq 0x68(%rsp), %r12
cmpl $0x64, %eax
jne 0x3e8c
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 0x3e1e
cmpl $0x78, %eax
jne 0x3f26
movq (%r13), %rdi
callq 0x2360
movq %rax, 0x40(%rsp)
jmp 0x3e1e
cmpl $-0x1, %eax
jne 0x3f26
movq 0x90(%rsp), %rdx
cmpq 0x70(%rsp), %rdx
jne 0x3f2e
testq %rdx, %rdx
je 0x3ec3
movq 0x68(%rsp), %rsi
movq 0x88(%rsp), %rdi
callq 0x2230
testl %eax, %eax
jne 0x3f2e
movl $0x10, %edi
callq 0x20c0
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x2115(%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 0x4152
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x415f
movq (%r14), %rdi
callq 0x3d0f
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 0x4201
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 0x4808
leaq 0x178(%rsp), %rdi
leaq 0x28(%rsp), %r14
leaq 0x220(%rsp), %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x48fa
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 0x35ba
leaq 0x28(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x4aa4
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 0x410e
movb $0x1, %al
cmpb $0x0, 0x218(%rsp)
jne 0x4124
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 0x4122
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 0x4124
movl 0x38(%rsp), %ecx
incl %ecx
cmpl %ecx, %eax
jne 0x412b
movq %r13, %rdi
callq 0x5380
jmp 0x412b
xorl %eax, %eax
movb %al, 0x218(%rsp)
movq 0x28(%rsp), %rdi
callq 0x21a0
testl %eax, %eax
jne 0x406d
movq %r15, %rdi
callq 0x38f8
movq %r12, %rdi
callq 0x54ae
jmp 0x406d
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 0x1f05(%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 0x41a9
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x41b6
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 0x1f27(%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 0x4264
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4277
movl $0x10, %edi
callq 0x20c0
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x1dd7(%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 0x4326
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x4333
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 0x1dd6(%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 0x42c5
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x42d8
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 0x1e06(%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 0x437d
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4390
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 0x1d31(%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 0x43d7
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x43e4
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 0x4c2d(%rip), %rsi      # 0x8ff0
movq 0x4bfe(%rip), %rdx      # 0x8fc8
movq %r14, %rdi
callq 0x23b0
jmp 0x4546
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 0x1d02(%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 0x442f
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4442
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 0x1c0b(%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 0x4490
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x44a3
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 0x1c3b(%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 0x44f1
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
jmp 0x4504
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 0x4ab9(%rip), %rsi      # 0x8ff0
movq 0x4a8a(%rip), %rdx      # 0x8fc8
movq %r14, %rdi
callq 0x23b0
movq %rax, %rbx
jmp 0x479c
jmp 0x46df
jmp 0x46df
jmp 0x46df
movq %rax, %rbx
movq 0x238(%rsp), %rdi
leaq 0x248(%rsp), %rax
cmpq %rax, %rdi
je 0x458d
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x458d
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x188(%rsp), %rax
movq 0x178(%rsp), %rdi
cmpq %rax, %rdi
je 0x45ba
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x45ba
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0x45ec
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x45ec
jmp 0x46df
movq %rax, %rbx
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x4610
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x4610
jmp 0x46df
movq %rax, %rbx
movb $0x1, %bpl
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x4686
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x4686
movq %rax, %rbx
movq 0x238(%rsp), %rdi
leaq 0x248(%rsp), %rax
cmpq %rax, %rdi
je 0x4659
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x4659
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x188(%rsp), %rax
movq 0x178(%rsp), %rdi
cmpq %rax, %rdi
je 0x46b8
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x46b8
movq %rax, %rbx
movb $0x1, %bpl
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46a3
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2220
testb %bpl, %bpl
je 0x46e2
movq %r14, %rdi
callq 0x2120
jmp 0x46e2
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0x470b
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x470b
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x4780
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2220
jmp 0x4780
movq %rax, %rbx
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x472c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x472c
jmp 0x477d
movq %rax, %rbx
movb $0x1, %bpl
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x474d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x474d
jmp 0x477d
movq %rax, %rbx
movb $0x1, %bpl
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x476a
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2220
testb %bpl, %bpl
je 0x4780
movq %r14, %rdi
callq 0x2120
jmp 0x4780
jmp 0x477d
jmp 0x477d
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x479c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2220
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x47c1
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x23e0
nop