#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*/ Display;
typedef scalar_t__ Atom;

/* Variables and functions */
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ False;
int /*<<< orphan*/ XA_ATOM;
scalar_t__ XInternAtom(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(scalar_t__ *);
scalar_t__ get_property(int /*<<< orphan*/ *, int /*<<< orphan*/,
                        int /*<<< orphan*/, char *, unsigned long *,
                        unsigned long *);
int /*<<< orphan*/ stderr;
int wm_supports(Display *disp, const char *prop) {
  Atom xa_prop = XInternAtom(disp, prop, False);
  Atom *list;
  unsigned long size, items;
  int i;
  if (!(list = (Atom *)get_property(disp, DefaultRootWindow(disp), XA_ATOM,
                                    "_NET_SUPPORTED", &size, &items))) {
    fprintf(stderr, "Cannot get _NET_SUPPORTED property.\n");
    return 0;
  }
  size *= items;
  for (i = 0; i < size / sizeof(Atom); i++) {
    if (list[i] == xa_prop) {
      free(list);
      return 1;
    }
  }
  free(list);
  return 0;
}


x86 assembly (clang, -O0):
<wm_supports>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
call   1070 <XInternAtom@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <DefaultRootWindow@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
lea    0xe5f(%rip),%rcx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
call   1040 <get_property@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11dd <wm_supports+0x8d>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1254 <wm_supports+0x104>
mov    -0x38(%rbp),%rax
imul   -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp),%rcx
shr    $0x3,%rcx
cmp    %rcx,%rax
jae    1244 <wm_supports+0xf4>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x20(%rbp),%rax
jne    1231 <wm_supports+0xe1>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1254 <wm_supports+0x104>
jmp    1236 <wm_supports+0xe6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11f1 <wm_supports+0xa1>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wm_supports>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
call   1070 <XInternAtom@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <DefaultRootWindow@plt>
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%edx
lea    0xe7d(%rip),%rcx
lea    0x8(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <get_property@plt>
test   %rax,%rax
je     11d9 <wm_supports+0x89>
mov    0x8(%rsp),%rcx
imul   0x10(%rsp),%rcx
mov    %rcx,0x8(%rsp)
cmp    $0x8,%rcx
jb     11cf <wm_supports+0x7f>
shr    $0x3,%rcx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
cmp    %r14,(%rax,%rdx,8)
je     11f8 <wm_supports+0xa8>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    11c0 <wm_supports+0x70>
mov    %rax,%rdi
call   1030 <free@plt>
jmp    11ee <wm_supports+0x9e>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
jmp    11f0 <wm_supports+0xa0>

LLVM IR (-O0):
@False = global i32 0
@XA_ATOM = global i32 0
@.str = [15 x i8] c"_NET_SUPPORTED\00"
@stderr = global i32 0
@.str.1 = [37 x i8] c"Cannot get _NET_SUPPORTED property.\0A\00"
define i32 @wm_supports(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%11 = load i32*, i32** %4
%12 = load i8*, i8** %5
%13 = load i32, i32* @False
%14 = call i64 @XInternAtom(i32* %11, i8* %12, i32 %13)
store i64 %14, i64* %6
%15 = load i32*, i32** %4
%16 = load i32*, i32** %4
%17 = call i32 @DefaultRootWindow(i32* %16)
%18 = load i32, i32* @XA_ATOM
%19 = call i64 @get_property(i32* %15, i32 %17, i32 %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64* %8, i64* %9)
%20 = inttoptr i64 %19 to i64*
store i64* %20, i64** %7
%21 = icmp ne i64* %20, null
br i1 %21, label %25, label %22
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %53
25: ; preds = %2
%26 = load i64, i64* %9
%27 = load i64, i64* %8
%28 = mul i64 %27, %26
store i64 %28, i64* %8
store i32 0, i32* %10
br label %29
29: ; preds = %47, %25
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = load i64, i64* %8
%33 = udiv i64 %32, 8
%34 = icmp ult i64 %31, %33
br i1 %34, label %35, label %50
35: ; preds = %29
%36 = load i64*, i64** %7
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i64, i64* %36, i64 %38
%40 = load i64, i64* %39
%41 = load i64, i64* %6
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = load i64*, i64** %7
%45 = call i32 @free(i64* %44)
store i32 1, i32* %3
br label %53
46: ; preds = %35
br label %47
47: ; preds = %46
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %29
50: ; preds = %29
%51 = load i64*, i64** %7
%52 = call i32 @free(i64* %51)
store i32 0, i32* %3
br label %53
53: ; preds = %50, %43, %22
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@False = global i32 0
@XA_ATOM = global i32 0
@.str = [15 x i8] c"_NET_SUPPORTED\00"
@stderr = global i32 0
@.str.1 = [37 x i8] c"Cannot get _NET_SUPPORTED property.\0A\00"
define i32 @wm_supports(i32* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i64
%5 = load i32, i32* @False
%6 = tail call i64 @XInternAtom(i32* %0, i8* %1, i32 %5)
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = tail call i32 @DefaultRootWindow(i32* %0)
%10 = load i32, i32* @XA_ATOM
%11 = call i64 @get_property(i32* %0, i32 %9, i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64* %3, i64* %4)
%12 = inttoptr i64 %11 to i64*
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %36
17: ; preds = %2
%18 = load i64, i64* %4
%19 = load i64, i64* %3
%20 = mul i64 %19, %18
store i64 %20, i64* %3
%21 = icmp ult i64 %20, 8
br i1 %21, label %34, label %22
22: ; preds = %17
%23 = lshr i64 %20, 3
br label %26
24: ; preds = %26
%25 = icmp eq i64 %31, %23
br i1 %25, label %34, label %26
26: ; preds = %22, %24
%27 = phi i64 [ 0, %22 ], [ %31, %24 ]
%28 = getelementptr inbounds i64, i64* %12, i64 %27
%29 = load i64, i64* %28
%30 = icmp eq i64 %29, %6
%31 = add nuw nsw i64 %27, 1
br i1 %30, label %32, label %24
32: ; preds = %26
%33 = call i32 @free(i64* %12)
br label %36
34: ; preds = %24, %17
%35 = call i32 @free(i64* %12)
br label %36
36: ; preds = %34, %32, %14
%37 = phi i32 [ 1, %32 ], [ 0, %34 ], [ 0, %14 ]
ret i32 %37
}