#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ height;
  int /*<<< orphan*/ width;
};
typedef TYPE_1__ XRectangle;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Drawable;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ None;
int /*<<< orphan*/ XCopyArea(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XSetClipMask(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
void copy(Display *d, Drawable from, Drawable to, GC gc, XRectangle r,
          Drawable mask) {
  XSetClipMask(d, gc, mask);
  XCopyArea(d, from, to, gc, 0, 0, r.width, r.height, 0, 0);
  XSetClipMask(d, gc, None);
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r8,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <XSetClipMask@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x4(%rbp),%r10d
mov    -0x8(%rbp),%eax
xor    %r9d,%r9d
mov    %r9d,%r8d
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
call   1030 <XCopyArea@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
call   1040 <XSetClipMask@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbx
mov    %r8,%rbp
shr    $0x20,%rbp
mov    %ecx,%esi
mov    %r9d,%edx
call   1040 <XSetClipMask@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r13d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x0
push   $0x0
push   %r14
push   %rbp
call   1030 <XCopyArea@plt>
add    $0x20,%rsp
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r13d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <XSetClipMask@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@None = global i32 0
define void @copy(i32* %0, i32 %1, i32 %2, i32 %3, i64 %4, i32 %5) {
%7 = alloca %struct.TYPE_3__
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = bitcast %struct.TYPE_3__* %7 to i64*
store i64 %4, i64* %13
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %5, i32* %12
%14 = load i32*, i32** %8
%15 = load i32, i32* %11
%16 = load i32, i32* %12
%17 = call i32 @XSetClipMask(i32* %14, i32 %15, i32 %16)
%18 = load i32*, i32** %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i32, i32* %11
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @XCopyArea(i32* %18, i32 %19, i32 %20, i32 %21, i32 0, i32 0, i32 %23, i32 %25, i32 0, i32 0)
%27 = load i32*, i32** %8
%28 = load i32, i32* %11
%29 = load i32, i32* @None
%30 = call i32 @XSetClipMask(i32* %27, i32 %28, i32 %29)
ret void
}

LLVM IR (-O2):
@None = global i32 0
define void @copy(i32* %0, i32 %1, i32 %2, i32 %3, i64 %4, i32 %5) {
%7 = trunc i64 %4 to i32
%8 = lshr i64 %4, 32
%9 = trunc i64 %8 to i32
%10 = tail call i32 @XSetClipMask(i32* %0, i32 %3, i32 %5)
%11 = tail call i32 @XCopyArea(i32* %0, i32 %1, i32 %2, i32 %3, i32 0, i32 0, i32 %9, i32 %7, i32 0, i32 0)
%12 = load i32, i32* @None
%13 = tail call i32 @XSetClipMask(i32* %0, i32 %3, i32 %12)
ret void
}