// File: /workspace/github_cpp_makefile_star2_O2/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 0x21b0
leaq 0x1f95(%rip), %rsi      # 0x50f2
leaq 0xd8(%rsp), %r15
leaq 0xf8(%rsp), %rdx
movq %r15, %rdi
callq 0x36a6
leaq 0x1f79(%rip), %rsi      # 0x50f5
leaq 0xb8(%rsp), %r12
leaq 0xf8(%rsp), %rdx
movq %r12, %rdi
callq 0x36a6
movl $0x0, 0xc(%rsp)
leaq 0x1f55(%rip), %r13      # 0x50f8
movq 0x4e0e(%rip), %rbx      # 0x7fb8
movl %ebp, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2040
movq %r12, %rdi
cmpl $0x64, %eax
je 0x31c7
cmpl $0x73, %eax
jne 0x31d1
movq %r15, %rdi
movq (%rbx), %rsi
callq 0x2450
jmp 0x31aa
cmpl $0x78, %eax
jne 0x31e4
movq (%rbx), %rdi
callq 0x2380
movl %eax, 0xc(%rsp)
jmp 0x31aa
cmpl $-0x1, %eax
jne 0x32d3
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x36e1
testb %al, %al
je 0x32db
pushq $0x10
popq %rdi
callq 0x20f0
movq %rax, %r14
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1dd7(%rip), %rdx      # 0x5004
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x3686
leaq 0x1e44(%rip), %rdx      # 0x5087
leaq 0x28(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3686
leaq 0x1ea7(%rip), %rdx      # 0x5100
leaq 0x1b8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3686
leaq 0x1e01(%rip), %rdx      # 0x5073
leaq 0x250(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x3686
leaq 0x1e76(%rip), %rdx      # 0x5104
leaq 0xf8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x3686
movb $0x1, %bpl
leaq 0xf8(%rsp), %rsi
movq %r14, %rdi
callq 0x23a0
xorl %ebp, %ebp
movq 0x4d31(%rip), %rsi      # 0x7ff0
movq 0x4d02(%rip), %rdx      # 0x7fc8
movq %r14, %rdi
callq 0x23d0
jmp 0x352e
movq (%r14), %rdi
callq 0x309f
leaq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x25c0
leaq 0xa0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x25c0
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2afa
movl 0xc(%rsp), %r14d
movq 0x88(%rsp), %rbx
movq 0x90(%rsp), %rax
subq %rbx, %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
cmpq %r14, %rax
jbe 0x346a
leaq 0xf8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x28f4
imulq $0x18, %r14, %rax
addq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
movq %rbx, %rcx
callq 0x370a
leaq 0x250(%rsp), %rdi
leaq 0x10(%rsp), %r14
leaq 0xa0(%rsp), %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x37ee
movq 0x10(%rsp), %rax
movq 0xe8(%rax), %rcx
movslq 0xe0(%rax), %rax
shlq $0x7, %rax
movq 0x10(%rcx,%rax), %rax
leaq 0x28(%rsp), %rdi
movq %r14, (%rdi)
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
callq 0x2ce2
leaq 0x10(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x398e
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2aea
leaq 0x138(%rsp), %rbx
leaq 0xf8(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0x250(%rsp), %r12
leaq 0x28(%rsp), %r13
leaq 0x1b8(%rsp), %rbp
movq %r14, %rdi
movq %r15, %rsi
callq 0x297a
movl 0xf8(%rsp), %eax
cmpl 0x18(%rsp), %eax
jne 0x3438
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3d7c
jmp 0x344a
movl 0x20(%rsp), %ecx
incl %ecx
cmpl %ecx, %eax
jne 0x344a
movq %rbp, %rdi
callq 0x3d9c
movq 0x10(%rsp), %rdi
callq 0x21d0
testl %eax, %eax
jne 0x3413
movq %r13, %rdi
callq 0x2e52
movq %r12, %rdi
callq 0x3eaa
jmp 0x3413
pushq $0x10
popq %rdi
callq 0x20f0
movq %rax, %r14
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1b77(%rip), %rdx      # 0x5004
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x3686
leaq 0x1be4(%rip), %rdx      # 0x5087
leaq 0x28(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3686
leaq 0x1c50(%rip), %rdx      # 0x5109
leaq 0x1b8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3686
leaq 0x1ba1(%rip), %rdx      # 0x5073
leaq 0x250(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x3686
leaq 0x1c16(%rip), %rdx      # 0x5104
leaq 0xf8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x3686
movb $0x1, %bpl
leaq 0xf8(%rsp), %rsi
movq %r14, %rdi
callq 0x23a0
xorl %ebp, %ebp
movq 0x4ad1(%rip), %rsi      # 0x7ff0
movq 0x4aa2(%rip), %rdx      # 0x7fc8
movq %r14, %rdi
callq 0x23d0
movq %rax, %rbx
jmp 0x3671
jmp 0x35ef
jmp 0x35ef
jmp 0x35ef
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x20c0
jmp 0x355d
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x250(%rsp), %rdi
callq 0x20c0
jmp 0x3572
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x1b8(%rsp), %rdi
callq 0x20c0
jmp 0x3589
jmp 0x35ef
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x20c0
jmp 0x359d
jmp 0x35ef
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x68(%rsp), %rdi
callq 0x20c0
jmp 0x35af
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x35f2
movq %r14, %rdi
callq 0x2150
jmp 0x35f2
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x20c0
jmp 0x35e0
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x250(%rsp), %rdi
callq 0x20c0
jmp 0x3607
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x3ff6
jmp 0x3664
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x1b8(%rsp), %rdi
callq 0x20c0
jmp 0x361e
jmp 0x3661
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x20c0
jmp 0x3632
jmp 0x3661
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x68(%rsp), %rdi
callq 0x20c0
jmp 0x3646
jmp 0x3661
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x3664
movq %r14, %rdi
callq 0x2150
jmp 0x3664
jmp 0x3661
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x20c0
leaq 0xd8(%rsp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2400