#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__ {
  int width;
  int height;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ False;
scalar_t__ XGetWindowAttributes(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                TYPE_1__ *);
scalar_t__ XQueryPointer(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/ *, int /*<<< orphan*/ *, int *,
                         int *, int *, int *, unsigned int *);
int QueryInWindow(Display *dpy, Window win) {
  XWindowAttributes win_att;
  Window root, child;
  int X, Y, x, y;
  unsigned int keys;
  if (XGetWindowAttributes(dpy, win, &win_att) == 0)
    return (0);
  if (XQueryPointer(dpy, win, &root, &child, &X, &Y, &x, &y, &keys) == False)
    return (0);
  if ((x > 0) && (x < win_att.width) && (y > 0) && (y < win_att.height))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<QueryInWindow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <XGetWindowAttributes@plt>
cmp    $0x0,%rax
jne    1155 <QueryInWindow+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <QueryInWindow+0xc6>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x34(%rbp),%r11
lea    -0x38(%rbp),%r10
lea    -0x3c(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <XQueryPointer@plt>
mov    0x2e56(%rip),%rcx
cmp    (%rcx),%rax
jne    11a7 <QueryInWindow+0x87>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <QueryInWindow+0xc6>
cmpl   $0x0,-0x34(%rbp)
jle    11df <QueryInWindow+0xbf>
mov    -0x34(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11df <QueryInWindow+0xbf>
cmpl   $0x0,-0x38(%rbp)
jle    11df <QueryInWindow+0xbf>
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11df <QueryInWindow+0xbf>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <QueryInWindow+0xc6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QueryInWindow>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x10(%rsp),%rdx
call   1040 <XGetWindowAttributes@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11aa <QueryInWindow+0x8a>
sub    $0x8,%rsp
lea    0x24(%rsp),%rax
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%r11
lea    0x34(%rsp),%rdx
lea    0x30(%rsp),%rcx
lea    0x2c(%rsp),%r8
lea    0x28(%rsp),%r9
mov    %rbx,%rdi
mov    %ebp,%esi
push   %rax
push   %r10
push   %r11
call   1030 <XQueryPointer@plt>
add    $0x20,%rsp
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
je     11aa <QueryInWindow+0x8a>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11a7 <QueryInWindow+0x87>
cmp    0x10(%rsp),%eax
jge    11a7 <QueryInWindow+0x87>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    11a7 <QueryInWindow+0x87>
mov    $0x1,%r14d
cmp    0x14(%rsp),%eax
jl     11aa <QueryInWindow+0x8a>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@False = global i64 0
define i32 @QueryInWindow(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca %struct.TYPE_3__
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%14 = load i32*, i32** %4
%15 = load i32, i32* %5
%16 = call i64 @XGetWindowAttributes(i32* %14, i32 %15, %struct.TYPE_3__* %6)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 0, i32* %3
br label %44
19: ; preds = %2
%20 = load i32*, i32** %4
%21 = load i32, i32* %5
%22 = call i64 @XQueryPointer(i32* %20, i32 %21, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13)
%23 = load i64, i64* @False
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 0, i32* %3
br label %44
26: ; preds = %19
%27 = load i32, i32* %11
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %43
29: ; preds = %26
%30 = load i32, i32* %11
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%32 = load i32, i32* %31
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %43
34: ; preds = %29
%35 = load i32, i32* %12
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i32, i32* %12
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 1
%40 = load i32, i32* %39
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 1, i32* %3
br label %44
43: ; preds = %37, %34, %29, %26
store i32 0, i32* %3
br label %44
44: ; preds = %43, %42, %25, %18
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@False = global i64 0
define i32 @QueryInWindow(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_3__
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast %struct.TYPE_3__* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = call i64 @XGetWindowAttributes(i32* %0, i32 %1, %struct.TYPE_3__* %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %40, label %21
21: ; preds = %2
%22 = call i64 @XQueryPointer(i32* %0, i32 %1, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%23 = load i64, i64* @False
%24 = icmp eq i64 %22, %23
br i1 %24, label %40, label %25
25: ; preds = %21
%26 = load i32, i32* %8
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%30 = load i32, i32* %29
%31 = icmp slt i32 %26, %30
%32 = load i32, i32* %9
%33 = icmp sgt i32 %32, 0
%34 = select i1 %31, i1 %33, i1 false
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
%36 = load i32, i32* %35
%37 = icmp slt i32 %32, %36
%38 = select i1 %34, i1 %37, i1 false
br i1 %38, label %40, label %39
39: ; preds = %28, %25
br label %40
40: ; preds = %28, %21, %2, %39
%41 = phi i32 [ 0, %39 ], [ 0, %2 ], [ 0, %21 ], [ 1, %28 ]
ret i32 %41
}