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


x86 assembly (clang, -O0):
<get_str_prop>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %rdx,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    0x2e7b(%rip),%rax
mov    (%rax),%r9d
mov    0x2e79(%rip),%rax
mov    (%rax),%r15d
xor    %ecx,%ecx
mov    $0xc8,%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   1040 <XGetWindowProperty@plt>
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%rax
je     11d1 <get_str_prop+0xa1>
mov    -0x48(%rbp),%eax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%eax
je     11de <get_str_prop+0xae>
movq   $0x0,-0x20(%rbp)
jmp    11fc <get_str_prop+0xcc>
mov    -0x60(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <XFree@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_str_prop>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e96(%rip),%rax
mov    (%rax),%r9d
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
lea    0x18(%rsp),%r10
lea    0x20(%rsp),%r11
lea    0x14(%rsp),%r15
lea    0x8(%rsp),%r12
xor    %r14d,%r14d
xor    %ecx,%ecx
mov    $0xc8,%r8d
push   %rbx
push   %r10
push   %r11
push   %r15
push   %r12
push   %rax
call   1040 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x8(%rsp),%rcx
mov    0x2e41(%rip),%rdx
cmp    (%rdx),%rcx
je     11b6 <get_str_prop+0x86>
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
jne    11b6 <get_str_prop+0x86>
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <XFree@plt>
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@False = global i32 0
@XA_STRING = global i32 0
@None = global i64 0
@Success = global i32 0
define i8* @get_str_prop(i32* %0, i32 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i8*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i64 %2, i64* %7
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = load i64, i64* %7
%18 = load i32, i32* @False
%19 = load i32, i32* @XA_STRING
%20 = call i32 @XGetWindowProperty(i32* %15, i32 %16, i64 %17, i32 0, i32 200, i32 %18, i32 %19, i64* %8, i32* %9, i64* %11, i64* %12, i8** %13)
store i32 %20, i32* %10
%21 = load i64, i64* %8
%22 = load i64, i64* @None
%23 = icmp eq i64 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %3
%25 = load i32, i32* %10
%26 = load i32, i32* @Success
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24, %3
store i8* null, i8** %4
br label %35
29: ; preds = %24
%30 = load i8*, i8** %13
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %14
%32 = load i8*, i8** %13
%33 = call i32 @XFree(i8* %32)
%34 = load i8*, i8** %14
store i8* %34, i8** %4
br label %35
35: ; preds = %29, %28
%36 = load i8*, i8** %4
ret i8* %36
}

LLVM IR (-O2):
@False = global i32 0
@XA_STRING = global i32 0
@None = global i64 0
@Success = global i32 0
define noalias i8* @get_str_prop(i32* %0, i32 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%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 i8** %8 to i8*
%14 = load i32, i32* @False
%15 = load i32, i32* @XA_STRING
%16 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %2, i32 0, i32 200, i32 %14, i32 %15, i64* %4, i32* %5, i64* %6, i64* %7, i8** %8)
%17 = load i64, i64* %4
%18 = load i64, i64* @None
%19 = icmp ne i64 %17, %18
%20 = load i32, i32* @Success
%21 = icmp eq i32 %16, %20
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %23, label %27
23: ; preds = %3
%24 = load i8*, i8** %8
%25 = call i8* @strdup(i8* %24)
%26 = call i32 @XFree(i8* %24)
br label %27
27: ; preds = %3, %23
%28 = phi i8* [ %25, %23 ], [ null, %3 ]
ret i8* %28
}