#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ class;
  scalar_t__ map_state;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef int Bool;

/* Variables and functions */
scalar_t__ InputOutput;
scalar_t__ IsViewable;
int /*<<< orphan*/ XGetWindowAttributes(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, TYPE_1__ *);
Bool Window_Is_Viewable(Display *dpy, Window win) {
  Bool ok;
  XWindowAttributes xwa;
  XGetWindowAttributes(dpy, win, &xwa);
  ok = (xwa.class == InputOutput) && (xwa.map_state == IsViewable);
  return ok;
}


x86 assembly (clang, -O0):
<Window_Is_Viewable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1030 <XGetWindowAttributes@plt>
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    0x2ea4(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x21(%rbp)
jne    115c <Window_Is_Viewable+0x4c>
mov    -0x18(%rbp),%rax
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Window_Is_Viewable>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdx
call   1030 <XGetWindowAttributes@plt>
mov    0x2ebb(%rip),%rax
mov    0x8(%rsp),%rcx
xor    (%rax),%rcx
mov    0x10(%rsp),%rdx
mov    0x2e9f(%rip),%rax
xor    (%rax),%rdx
xor    %eax,%eax
or     %rcx,%rdx
sete   %al
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i64 }
@InputOutput = global i64 0
@IsViewable = global i64 0
define i32 @Window_Is_Viewable(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.TYPE_3__
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %4
%9 = call i32 @XGetWindowAttributes(i32* %7, i32 %8, %struct.TYPE_3__* %6)
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%11 = load i64, i64* %10
%12 = load i64, i64* @InputOutput
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 1
%16 = load i64, i64* %15
%17 = load i64, i64* @IsViewable
%18 = icmp eq i64 %16, %17
br label %19
19: ; preds = %14, %2
%20 = phi i1 [ false, %2 ], [ %18, %14 ]
%21 = zext i1 %20 to i32
store i32 %21, i32* %5
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64 }
@InputOutput = global i64 0
@IsViewable = global i64 0
define i32 @Window_Is_Viewable(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_3__
%4 = bitcast %struct.TYPE_3__* %3 to i8*
%5 = call i32 @XGetWindowAttributes(i32* %0, i32 %1, %struct.TYPE_3__* %3)
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%7 = load i64, i64* %6
%8 = load i64, i64* @InputOutput
%9 = icmp eq i64 %7, %8
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
%11 = load i64, i64* %10
%12 = load i64, i64* @IsViewable
%13 = icmp eq i64 %11, %12
%14 = select i1 %9, i1 %13, i1 false
%15 = zext i1 %14 to i32
ret i32 %15
}