#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 */

/* Type definitions */
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Atom;

/* Variables and functions */
int /*<<< orphan*/ AnyPropertyType;
int False;
int /*<<< orphan*/ PropModeReplace;
scalar_t__ Success;
int True;
int /*<<< orphan*/ XChangeProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   scalar_t__, scalar_t__, int,
                                   int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ XFree(unsigned char *);
scalar_t__ XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              scalar_t__, long, int, int, int /*<<< orphan*/,
                              scalar_t__ *, int *, unsigned long *,
                              unsigned long *, unsigned char **);
int CopyProperty(Display *dpy, Atom property, Window old_win, Window new_win) {
  Atom type;
  int format;
  unsigned long length, bytes_after;
  unsigned char *data;
  if (property &&
      (XGetWindowProperty(dpy, old_win, property, 0L, 1000000, False,
                          AnyPropertyType, &type, &format, &length,
                          &bytes_after, (unsigned char **)&data) == Success) &&
      format) {
    XChangeProperty(dpy, new_win, property, type, format, PropModeReplace, data,
                    (int)length);
    XFree(data);
    return True;
  } else
    return False;
}


x86 assembly (clang, -O0):
<CopyProperty>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %edx,-0x34(%rbp)
mov    %ecx,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     121b <CopyProperty+0xeb>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    0x2e70(%rip),%rax
mov    (%rax),%r9d
mov    0x2e76(%rip),%rax
mov    (%rax),%r15d
xor    %eax,%eax
mov    %eax,%ecx
mov    $0xf4240,%r8d
lea    -0x40(%rbp),%r14
lea    -0x44(%rbp),%rbx
lea    -0x50(%rbp),%r11
lea    -0x58(%rbp),%r10
lea    -0x60(%rbp),%rax
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1050 <XGetWindowProperty@plt>
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
jne    121b <CopyProperty+0xeb>
cmpl   $0x0,-0x44(%rbp)
je     121b <CopyProperty+0xeb>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x44(%rbp),%r8d
mov    0x2dd7(%rip),%rax
mov    (%rax),%r9d
mov    -0x60(%rbp),%r10
mov    -0x50(%rbp),%rax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <XChangeProperty@plt>
mov    -0x60(%rbp),%rdi
call   1030 <XFree@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1227 <CopyProperty+0xf7>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyProperty>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rsi,%rsi
je     11f1 <CopyProperty+0xc1>
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x2e81(%rip),%rbp
mov    0x0(%rbp),%r9d
mov    0x2e86(%rip),%rax
mov    (%rax),%r13d
lea    0x8(%rsp),%r10
lea    0x20(%rsp),%r11
lea    0x10(%rsp),%r12
lea    0x4(%rsp),%rax
mov    %edx,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    $0xf4240,%r8d
push   %r10
push   %r11
push   %r12
push   %rax
lea    0x38(%rsp),%rax
push   %rax
push   %r13
call   1050 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
jne    11f8 <CopyProperty+0xc8>
mov    0x4(%rsp),%r8d
test   %r8d,%r8d
je     11f8 <CopyProperty+0xc8>
mov    0x18(%rsp),%rcx
mov    0x2e00(%rip),%rax
mov    (%rax),%r9d
mov    0x10(%rsp),%eax
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
push   %rax
push   0x10(%rsp)
call   1040 <XChangeProperty@plt>
add    $0x10,%rsp
mov    0x8(%rsp),%rdi
call   1030 <XFree@plt>
mov    0x2de1(%rip),%rbp
jmp    11f8 <CopyProperty+0xc8>
mov    0x2de0(%rip),%rbp
mov    0x0(%rbp),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@False = global i32 0
@AnyPropertyType = global i32 0
@Success = global i64 0
@PropModeReplace = global i32 0
@True = global i32 0
define i32 @CopyProperty(i32* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
%14 = alloca i8*
store i32* %0, i32** %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%15 = load i64, i64* %7
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %43
17: ; preds = %4
%18 = load i32*, i32** %6
%19 = load i32, i32* %8
%20 = load i64, i64* %7
%21 = load i32, i32* @False
%22 = load i32, i32* @AnyPropertyType
%23 = call i64 @XGetWindowProperty(i32* %18, i32 %19, i64 %20, i64 0, i32 1000000, i32 %21, i32 %22, i64* %10, i32* %11, i64* %12, i64* %13, i8** %14)
%24 = load i64, i64* @Success
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %43
26: ; preds = %17
%27 = load i32, i32* %11
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %43
29: ; preds = %26
%30 = load i32*, i32** %6
%31 = load i32, i32* %9
%32 = load i64, i64* %7
%33 = load i64, i64* %10
%34 = load i32, i32* %11
%35 = load i32, i32* @PropModeReplace
%36 = load i8*, i8** %14
%37 = load i64, i64* %12
%38 = trunc i64 %37 to i32
%39 = call i32 @XChangeProperty(i32* %30, i32 %31, i64 %32, i64 %33, i32 %34, i32 %35, i8* %36, i32 %38)
%40 = load i8*, i8** %14
%41 = call i32 @XFree(i8* %40)
%42 = load i32, i32* @True
store i32 %42, i32* %5
br label %45
43: ; preds = %26, %17, %4
%44 = load i32, i32* @False
store i32 %44, i32* %5
br label %45
45: ; preds = %43, %29
%46 = load i32, i32* %5
ret i32 %46
}

LLVM IR (-O2):
@False = global i32 0
@AnyPropertyType = global i32 0
@Success = global i64 0
@PropModeReplace = global i32 0
@True = global i32 0
define i32 @CopyProperty(i32* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = bitcast i64* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = bitcast i64* %8 to i8*
%14 = bitcast i8** %9 to i8*
%15 = icmp eq i64 %1, 0
br i1 %15, label %34, label %16
16: ; preds = %4
%17 = load i32, i32* @False
%18 = load i32, i32* @AnyPropertyType
%19 = call i64 @XGetWindowProperty(i32* %0, i32 %2, i64 %1, i64 0, i32 1000000, i32 %17, i32 %18, i64* %5, i32* %6, i64* %7, i64* %8, i8** %9)
%20 = load i64, i64* @Success
%21 = icmp eq i64 %19, %20
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
%24 = select i1 %21, i1 %23, i1 false
br i1 %24, label %25, label %34
25: ; preds = %16
%26 = load i64, i64* %5
%27 = load i32, i32* @PropModeReplace
%28 = load i8*, i8** %9
%29 = load i64, i64* %7
%30 = trunc i64 %29 to i32
%31 = call i32 @XChangeProperty(i32* %0, i32 %3, i64 %1, i64 %26, i32 %22, i32 %27, i8* %28, i32 %30)
%32 = load i8*, i8** %9
%33 = call i32 @XFree(i8* %32)
br label %34
34: ; preds = %4, %16, %25
%35 = phi i32* [ @True, %25 ], [ @False, %16 ], [ @False, %4 ]
%36 = load i32, i32* %35
ret i32 %36
}