#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ ev;
typedef int /*<<< orphan*/ XID;
typedef int /*<<< orphan*/ XEvent;
struct TYPE_4__ {
  void **l;
};
struct TYPE_5__ {
  int format;
  int /*<<< orphan*/ window;
  int /*<<< orphan*/ *display;
  TYPE_1__ data;
  void *message_type;
  int /*<<< orphan*/ type;
};
typedef TYPE_2__ XClientMessageEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ ClientMessage;
int /*<<< orphan*/ False;
int /*<<< orphan*/ True;
void *XInternAtom(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int XSendEvent(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
               int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(TYPE_2__ *, int /*<<< orphan*/, int);
int close_window(Display *d, XID window) {
  XClientMessageEvent ev;
  memset(&ev, 0, sizeof(ev));
  ev.type = ClientMessage;
  ev.display = d;
  ev.window = window;
  ev.format = 32;
  ev.message_type = XInternAtom(d, "WM_PROTOCOLS", False);
  ev.data.l[0] = XInternAtom(d, "WM_DELETE_WINDOW", False);
  ;
  return XSendEvent(ev.display, ev.window, True, 0, (XEvent *)&ev);
}


x86 assembly (clang, -O0):
<close_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x20,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
lea    0xe7c(%rip),%rsi
call   1050 <XInternAtom@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
lea    0xe6c(%rip),%rsi
call   1050 <XInternAtom@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    0x2e22(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%r8
xor    %ecx,%ecx
call   1030 <XSendEvent@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_window>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    %rbx,0x10(%rsp)
mov    %ebp,0xc(%rsp)
movl   $0x20,0x8(%rsp)
mov    0x2e72(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1050 <XInternAtom@plt>
mov    %rax,0x20(%rsp)
mov    0x0(%rbp),%edx
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <XInternAtom@plt>
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   1030 <XSendEvent@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32, i32*, %struct.TYPE_4__, i8*, i32 }
%struct.TYPE_4__ = type { i8** }
@ClientMessage = global i32 0
@.str = [13 x i8] c"WM_PROTOCOLS\00"
@False = global i32 0
@.str.1 = [17 x i8] c"WM_DELETE_WINDOW\00"
@True = global i32 0
define i32 @close_window(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.TYPE_5__
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 @memset(%struct.TYPE_5__* %5, i32 0, i32 40)
%7 = load i32, i32* @ClientMessage
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 5
store i32 %7, i32* %8
%9 = load i32*, i32** %3
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 2
store i32* %9, i32** %10
%11 = load i32, i32* %4
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 0
store i32 32, i32* %13
%14 = load i32*, i32** %3
%15 = load i32, i32* @False
%16 = call i8* @XInternAtom(i32* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 4
store i8* %16, i8** %17
%18 = load i32*, i32** %3
%19 = load i32, i32* @False
%20 = call i8* @XInternAtom(i32* %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 3
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load i8**, i8*** %22
%24 = getelementptr inbounds i8*, i8** %23, i64 0
store i8* %20, i8** %24
%25 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 2
%26 = load i32*, i32** %25
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
%28 = load i32, i32* %27
%29 = load i32, i32* @True
%30 = bitcast %struct.TYPE_5__* %5 to i32*
%31 = call i32 @XSendEvent(i32* %26, i32 %28, i32 %29, i32 0, i32* %30)
ret i32 %31
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32, i32*, %struct.TYPE_4__, i8*, i32 }
%struct.TYPE_4__ = type { i8** }
@ClientMessage = global i32 0
@.str = [13 x i8] c"WM_PROTOCOLS\00"
@False = global i32 0
@.str.1 = [17 x i8] c"WM_DELETE_WINDOW\00"
@True = global i32 0
define i32 @close_window(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_5__
%4 = bitcast %struct.TYPE_5__* %3 to i8*
%5 = call i32 @memset(%struct.TYPE_5__* %3, i32 0, i32 40)
%6 = load i32, i32* @ClientMessage
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 5
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
store i32* %0, i32** %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
store i32 %1, i32* %9
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
store i32 32, i32* %10
%11 = load i32, i32* @False
%12 = call i8* @XInternAtom(i32* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 4
store i8* %12, i8** %13
%14 = load i32, i32* @False
%15 = call i8* @XInternAtom(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3, i32 0
%17 = load i8**, i8*** %16
store i8* %15, i8** %17
%18 = load i32*, i32** %8
%19 = load i32, i32* %9
%20 = load i32, i32* @True
%21 = call i32 @XSendEvent(i32* %18, i32 %19, i32 %20, i32 0, i32* %10)
ret i32 %21
}