#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 Success;
scalar_t__ XA_STRING;
int /*<<< orphan*/ XFree(char *);
int XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/, scalar_t__,
                       int /*<<< orphan*/, int, int /*<<< orphan*/, scalar_t__,
                       scalar_t__ *, int *, unsigned long *, unsigned long *,
                       unsigned char **);
int /*<<< orphan*/ printf(char *, char *);
void handle_propchange(Display *d, Window w, Atom a) {
  char *result;
  Atom type;
  int format, res;
  unsigned long nitems, nleft;
  res = XGetWindowProperty(d, w, a, 0, 512, 0, XA_STRING, &type, &format,
                           &nitems, &nleft, (unsigned char **)&result);
  if (res != Success) {
    return;
  } else if (type != XA_STRING) {
    XFree(result);
    return;
  }
  printf("%s\n", result);
  XFree(result);
}


x86 assembly (clang, -O0):
<handle_propchange>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    0x2e86(%rip),%rax
mov    (%rax),%r15
xor    %r9d,%r9d
mov    $0x200,%r8d
lea    -0x40(%rbp),%r14
lea    -0x44(%rbp),%rbx
lea    -0x50(%rbp),%r11
lea    -0x58(%rbp),%r10
lea    -0x38(%rbp),%rax
mov    %r9d,%ecx
mov    %r15,(%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    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%eax
je     11b9 <handle_propchange+0x89>
jmp    11f9 <handle_propchange+0xc9>
mov    -0x40(%rbp),%rax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%rax
je     11db <handle_propchange+0xab>
mov    -0x38(%rbp),%rdi
call   1040 <XFree@plt>
jmp    11f9 <handle_propchange+0xc9>
jmp    11e0 <handle_propchange+0xb0>
mov    -0x38(%rbp),%rsi
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <XFree@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_propchange>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0x2ea0(%rip),%r14
lea    0x8(%rsp),%rax
lea    0x20(%rsp),%rbx
lea    0x28(%rsp),%r10
lea    0x1c(%rsp),%r11
lea    0x10(%rsp),%r15
xor    %ecx,%ecx
mov    $0x200,%r8d
xor    %r9d,%r9d
push   %rax
push   %rbx
push   %r10
push   %r11
push   %r15
push   (%r14)
call   1050 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
jne    11ab <handle_propchange+0x7b>
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rsi
cmp    (%r14),%rax
jne    11a3 <handle_propchange+0x73>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
mov    %rsi,%rdi
call   1040 <XFree@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@XA_STRING = global i64 0
@Success = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @handle_propchange(i32* %0, i32 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = load i64, i64* %6
%16 = load i64, i64* @XA_STRING
%17 = call i32 @XGetWindowProperty(i32* %13, i32 %14, i64 %15, i32 0, i32 512, i32 0, i64 %16, i64* %8, i32* %9, i64* %11, i64* %12, i8** %7)
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = load i32, i32* @Success
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %3
br label %35
22: ; preds = %3
%23 = load i64, i64* %8
%24 = load i64, i64* @XA_STRING
%25 = icmp ne i64 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i8*, i8** %7
%28 = call i32 @XFree(i8* %27)
br label %35
29: ; preds = %22
br label %30
30: ; preds = %29
%31 = load i8*, i8** %7
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %7
%34 = call i32 @XFree(i8* %33)
br label %35
35: ; preds = %30, %26, %21
ret void
}

LLVM IR (-O2):
@XA_STRING = global i64 0
@Success = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @handle_propchange(i32* %0, i32 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = bitcast i8** %4 to 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 = load i64, i64* @XA_STRING
%15 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %2, i32 0, i32 512, i32 0, i64 %14, i64* %5, i32* %6, i64* %7, i64* %8, i8** %4)
%16 = load i32, i32* @Success
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %3
%19 = load i64, i64* %5
%20 = load i64, i64* @XA_STRING
%21 = icmp eq i64 %19, %20
%22 = load i8*, i8** %4
br i1 %21, label %23, label %26
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%25 = load i8*, i8** %4
br label %26
26: ; preds = %18, %23
%27 = phi i8* [ %25, %23 ], [ %22, %18 ]
%28 = call i32 @XFree(i8* %27)
br label %29
29: ; preds = %26, %3
ret void
}