// File: liskin[P]hybrid-screenclone/screenclone.cc
// Function: image_replayer::image_replayer(display const&, display const&, xinerama_screen const&)
image_replayer( const display &_src, const display &_dst, const xinerama_screen &_src_screen )
		: src( &_src ), dst( &_dst), src_screen( &_src_screen )
		, src_window( src->root() ), dst_window( dst->root() )
		, damaged( true )
	{	
		size_t sz = src_screen->info.width * src_screen->info.height * 4;
		src_info.shmid = dst_info.shmid = shmget( IPC_PRIVATE, sz, IPC_CREAT | 0666 );
		src_info.shmaddr = dst_info.shmaddr = (char *) shmat( src_info.shmid, 0, 0);
		src_info.readOnly = dst_info.readOnly = false;
		shmctl( src_info.shmid, IPC_RMID, NULL );

		src_image = XShmCreateImage( src->dpy, DefaultVisual( src->dpy, DefaultScreen( src->dpy ) ),
			DefaultDepth( src->dpy, DefaultScreen( src->dpy ) ), ZPixmap, src_info.shmaddr,
			&src_info, src_screen->info.width, src_screen->info.height );
		dst_image = XShmCreateImage( dst->dpy, DefaultVisual( dst->dpy, DefaultScreen( dst->dpy ) ),
			DefaultDepth( dst->dpy, DefaultScreen( dst->dpy ) ), ZPixmap, dst_info.shmaddr,
			&dst_info, src_screen->info.width, src_screen->info.height );

		XShmAttach( src->dpy, &src_info );
		XShmAttach( dst->dpy, &dst_info );

		dst_gc = DefaultGC( dst->dpy, DefaultScreen( dst->dpy ) );
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
addq $0x18, %rdi
movq (%rax), %rsi
callq 0x3d90
movq -0x30(%rbp), %rax
movq %rax, %rdi
addq $0x30, %rdi
movq 0x8(%rax), %rsi
callq 0x3d90
movq -0x30(%rbp), %rcx
movb $0x1, 0xa0(%rcx)
movq 0x10(%rcx), %rax
movswl 0x10(%rax), %eax
movq 0x10(%rcx), %rcx
movswl 0x12(%rcx), %ecx
imull %ecx, %eax
shll $0x2, %eax
cltq
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
xorl %edi, %edi
movl $0x3b6, %edx            # imm = 0x3B6
callq 0x3130
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x70(%rax)
movl %ecx, 0x50(%rax)
movl 0x50(%rax), %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x33f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x78(%rax)
movq %rcx, 0x58(%rax)
movl $0x0, 0x80(%rax)
movl $0x0, 0x60(%rax)
movl 0x50(%rax), %edi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x31f0
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq (%rcx), %rdi
movq (%rax), %rcx
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq (%rax), %rdx
movq (%rdx), %rdx
movslq 0xe0(%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x40(%rcx), %rsi
movq (%rax), %rcx
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq (%rax), %rdx
movq (%rdx), %rdx
movslq 0xe0(%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rcx
movl 0x38(%rcx), %edx
movq 0x58(%rax), %r8
movq %rax, %r9
addq $0x48, %r9
movq 0x10(%rax), %rcx
movswl 0x10(%rcx), %r10d
movq 0x10(%rax), %rax
movswl 0x12(%rax), %eax
movl $0x2, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x3390
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x88(%rax)
movq 0x8(%rax), %rcx
movq (%rcx), %rdi
movq 0x8(%rax), %rcx
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq 0x8(%rax), %rdx
movq (%rdx), %rdx
movslq 0xe0(%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x40(%rcx), %rsi
movq 0x8(%rax), %rcx
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq 0x8(%rax), %rdx
movq (%rdx), %rdx
movslq 0xe0(%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rcx
movl 0x38(%rcx), %edx
movq 0x78(%rax), %r8
movq %rax, %r9
addq $0x68, %r9
movq 0x10(%rax), %rcx
movswl 0x10(%rcx), %r10d
movq 0x10(%rax), %rax
movswl 0x12(%rax), %eax
movl $0x2, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x3390
movq -0x30(%rbp), %rsi
movq %rax, 0x90(%rsi)
movq (%rsi), %rax
movq (%rax), %rdi
addq $0x48, %rsi
callq 0x3360
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rax
movq (%rax), %rdi
addq $0x68, %rsi
callq 0x3360
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq 0x8(%rax), %rdx
movq (%rdx), %rdx
movslq 0xe0(%rdx), %rdx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x48(%rcx), %rcx
movq %rcx, 0x98(%rax)
addq $0x40, %rsp
popq %rbp
retq