#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*/ XID;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ False;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSync(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ close_window(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
scalar_t__ is_window_visible(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int i;
  Display *d;
  XID w;
  d = XOpenDisplay(NULL);
  if (!d)
    exit(1);
  for (i = 1; i < argc; i++) {
    w = strtoul(argv[i], NULL, 0);
    if (is_window_visible(d, w))
      close_window(d, w);
  }
  XSync(d, False);
  XCloseDisplay(d);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a8 <main+0x38>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120a <main+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <is_window_visible@plt>
cmp    $0x0,%rax
je     11f7 <main+0x87>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <close_window@plt>
jmp    11fc <main+0x8c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11af <main+0x3f>
mov    -0x20(%rbp),%rdi
mov    0x2dd3(%rip),%rax
mov    (%rax),%esi
call   1040 <XSync@plt>
mov    -0x20(%rbp),%rdi
call   1080 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %edi,%edi
call   1030 <XOpenDisplay@plt>
test   %rax,%rax
je     11f7 <main+0x87>
mov    %rax,%r12
cmp    $0x2,%ebp
jl     11d3 <main+0x63>
mov    %ebp,%r15d
mov    $0x1,%ebx
jmp    11a9 <main+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     11d3 <main+0x63>
mov    (%r14,%rbx,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %eax,%esi
call   1090 <is_window_visible@plt>
test   %rax,%rax
je     11a0 <main+0x30>
mov    %r12,%rdi
mov    %ebp,%esi
call   1050 <close_window@plt>
jmp    11a0 <main+0x30>
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   1040 <XSync@plt>
mov    %r12,%rdi
call   1080 <XCloseDisplay@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@False = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @XOpenDisplay(i32* null)
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp ne i32* %10, null
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
store i32 1, i32* %6
br label %15
15: ; preds = %35, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %38
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @strtoul(i8* %24, i32* null, i32 0)
store i32 %25, i32* %8
%26 = load i32*, i32** %7
%27 = load i32, i32* %8
%28 = call i64 @is_window_visible(i32* %26, i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %19
%31 = load i32*, i32** %7
%32 = load i32, i32* %8
%33 = call i32 @close_window(i32* %31, i32 %32)
br label %34
34: ; preds = %30, %19
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %15
38: ; preds = %15
%39 = load i32*, i32** %7
%40 = load i32, i32* @False
%41 = call i32 @XSync(i32* %39, i32 %40)
%42 = load i32*, i32** %7
%43 = call i32 @XCloseDisplay(i32* %42)
ret i32 0
}

LLVM IR (-O2):
@False = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32* @XOpenDisplay(i32* null)
%4 = icmp eq i32* %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %23
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %2
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %7, %20
%12 = phi i64 [ 1, %7 ], [ %21, %20 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strtoul(i8* nocapture %14, i32* null, i32 0)
%16 = tail call i64 @is_window_visible(i32* %3, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = tail call i32 @close_window(i32* %3, i32 %15)
br label %20
20: ; preds = %11, %18
%21 = add nuw nsw i64 %12, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %11
23: ; preds = %20, %5
%24 = load i32, i32* @False
%25 = tail call i32 @XSync(i32* %3, i32 %24)
%26 = tail call i32 @XCloseDisplay(i32* %3)
ret i32 0
}