#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*/ False;
int Success;
scalar_t__ XA_ATOM;
int /*<<< orphan*/ XFree(char *);
char *XGetAtomName(int /*<<< orphan*/ *, scalar_t__);
int XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/, scalar_t__,
                       int /*<<< orphan*/, int, int /*<<< orphan*/, scalar_t__,
                       scalar_t__ *, int *, unsigned long *, unsigned long *,
                       unsigned char **);
char *strdup(char *);
char *get_atom_prop(Display *dpy, Window w, Atom atom) {
  Atom type;
  int format, rc;
  unsigned long items;
  unsigned long left;
  Atom *value;
  char *copy;
  rc = XGetWindowProperty(dpy, w, atom, 0, 1, False, XA_ATOM, &type, &format,
                          &items, &left, (unsigned char **)&value);
  if (type != XA_ATOM || format == 0 || rc != Success) {
    copy = strdup("");
  } else {
    char *s = XGetAtomName(dpy, *value);
    copy = strdup(s);
    XFree(s);
  }
  return copy;
}


x86 assembly (clang, -O0):
<get_atom_prop>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%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    0x2e6b(%rip),%rax
mov    (%rax),%r9d
mov    0x2e69(%rip),%rax
mov    (%rax),%r15
lea    -0x58(%rbp),%rax
xor    %ecx,%ecx
mov    $0x1,%r8d
lea    -0x38(%rbp),%r14
lea    -0x3c(%rbp),%rbx
lea    -0x48(%rbp),%r11
lea    -0x50(%rbp),%r10
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,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%rax
jne    11eb <get_atom_prop+0xab>
cmpl   $0x0,-0x3c(%rbp)
je     11eb <get_atom_prop+0xab>
mov    -0x40(%rbp),%eax
mov    0x2e15(%rip),%rcx
cmp    (%rcx),%eax
je     1200 <get_atom_prop+0xc0>
lea    0xe0e(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x60(%rbp)
jmp    122a <get_atom_prop+0xea>
mov    -0x20(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    (%rax),%rsi
call   1040 <XGetAtomName@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x60(%rbp)
mov    -0x68(%rbp),%rdi
call   1030 <XFree@plt>
mov    -0x60(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_atom_prop>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
mov    0x2e83(%rip),%rax
mov    (%rax),%r9d
mov    0x2e81(%rip),%r14
lea    0x8(%rsp),%rax
lea    0x18(%rsp),%r10
lea    0x20(%rsp),%r11
lea    0x4(%rsp),%r15
lea    0x10(%rsp),%r12
xor    %ecx,%ecx
mov    $0x1,%r8d
push   %rax
push   %r10
push   %r11
push   %r15
push   %r12
push   (%r14)
call   1050 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x10(%rsp),%rcx
cmp    (%r14),%rcx
jne    11d9 <get_atom_prop+0x99>
cmpl   $0x0,0x4(%rsp)
je     11d9 <get_atom_prop+0x99>
mov    0x2e4b(%rip),%rcx
cmp    (%rcx),%eax
jne    11d9 <get_atom_prop+0x99>
mov    0x8(%rsp),%rax
mov    (%rax),%rsi
mov    %rbx,%rdi
call   1040 <XGetAtomName@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <XFree@plt>
jmp    11e8 <get_atom_prop+0xa8>
lea    0xe20(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@False = global i32 0
@XA_ATOM = global i64 0
@Success = global i32 0
@.str = [1 x i8] zeroinitializer
define i8* @get_atom_prop(i32* %0, i32 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64*
%13 = alloca i8*
%14 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = load i64, i64* %6
%18 = load i32, i32* @False
%19 = load i64, i64* @XA_ATOM
%20 = bitcast i64** %12 to i8**
%21 = call i32 @XGetWindowProperty(i32* %15, i32 %16, i64 %17, i32 0, i32 1, i32 %18, i64 %19, i64* %7, i32* %8, i64* %10, i64* %11, i8** %20)
store i32 %21, i32* %9
%22 = load i64, i64* %7
%23 = load i64, i64* @XA_ATOM
%24 = icmp ne i64 %22, %23
br i1 %24, label %32, label %25
25: ; preds = %3
%26 = load i32, i32* %8
%27 = icmp eq i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = load i32, i32* %9
%30 = load i32, i32* @Success
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28, %25, %3
%33 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %33, i8** %13
br label %43
34: ; preds = %28
%35 = load i32*, i32** %4
%36 = load i64*, i64** %12
%37 = load i64, i64* %36
%38 = call i8* @XGetAtomName(i32* %35, i64 %37)
store i8* %38, i8** %14
%39 = load i8*, i8** %14
%40 = call i8* @strdup(i8* %39)
store i8* %40, i8** %13
%41 = load i8*, i8** %14
%42 = call i32 @XFree(i8* %41)
br label %43
43: ; preds = %34, %32
%44 = load i8*, i8** %13
ret i8* %44
}

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