#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_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ state;
};
struct TYPE_5__ {
  int /*<<< orphan*/ property;
};
struct TYPE_7__ {
  TYPE_2__ xproperty;
  int /*<<< orphan*/ type;
  TYPE_1__ xselection;
};
typedef TYPE_3__ XEvent;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Atom;

/* Variables and functions */
int /*<<< orphan*/ AnyPropertyType;
int /*<<< orphan*/ CurrentTime;
int /*<<< orphan*/ False;
int /*<<< orphan*/ None;
int /*<<< orphan*/ PropertyNewValue;
int /*<<< orphan*/ PropertyNotify;
int /*<<< orphan*/ SelectionNotify;
int /*<<< orphan*/ XConvertSelection(int /*<<< orphan*/ *, scalar_t__,
                                     scalar_t__, scalar_t__, int /*<<< orphan*/,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ XDeleteProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   scalar_t__);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFree(unsigned char *);
int /*<<< orphan*/ XGetWindowProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                      scalar_t__, int /*<<< orphan*/, long,
                                      int /*<<< orphan*/, int /*<<< orphan*/,
                                      scalar_t__ *, int *, unsigned long *,
                                      unsigned long *, unsigned char **);
scalar_t__ XInternAtom(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(unsigned char *);
unsigned long mach_itemsize(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, unsigned long);
scalar_t__ xcmalloc(unsigned long);
scalar_t__ xcrealloc(unsigned char *, unsigned long);
int xcout(Display *dpy, Window win, XEvent evt, Atom sel, Atom target,
          Atom *type, unsigned char **txt, unsigned long *len,
          unsigned int *context) {
  static Atom pty;
  static Atom inc;
  int pty_format;
  unsigned char *buffer;
  unsigned long pty_size, pty_items, pty_machsize;
  unsigned char *ltxt = *txt;
  if (!pty) {
    pty = XInternAtom(dpy, "XCLIP_OUT", False);
  }
  if (!inc) {
    inc = XInternAtom(dpy, "INCR", False);
  }
  switch (*context) {
  case 0:
    if (*len > 0) {
      free(*txt);
      *len = 0;
    }
    XConvertSelection(dpy, sel, target, pty, win, CurrentTime);
    *context = 1;
    return (0);
  case 1:
    if (evt.type != SelectionNotify)
      return (0);
    if (evt.xselection.property == None) {
      *context = 3;
      return (0);
    }
    XGetWindowProperty(dpy, win, pty, 0, 0, False, AnyPropertyType, type,
                       &pty_format, &pty_items, &pty_size, &buffer);
    XFree(buffer);
    if (*type == inc) {
      XDeleteProperty(dpy, win, pty);
      XFlush(dpy);
      *context = 2;
      return (0);
    }
    XGetWindowProperty(dpy, win, pty, 0, (long)pty_size, False, AnyPropertyType,
                       type, &pty_format, &pty_items, &pty_size, &buffer);
    XDeleteProperty(dpy, win, pty);
    pty_machsize = pty_items * mach_itemsize(pty_format);
    ltxt = (unsigned char *)xcmalloc(pty_machsize);
    memcpy(ltxt, buffer, pty_machsize);
    *len = pty_machsize;
    *txt = ltxt;
    XFree(buffer);
    *context = 0;
    return (1);
  case 2:
    if (evt.type != PropertyNotify)
      return (0);
    if (evt.xproperty.state != PropertyNewValue)
      return (0);
    XGetWindowProperty(dpy, win, pty, 0, 0, False, AnyPropertyType, type,
                       &pty_format, &pty_items, &pty_size,
                       (unsigned char **)&buffer);
    if (pty_size == 0) {
      XFree(buffer);
      XDeleteProperty(dpy, win, pty);
      *context = 0;
      return (1);
    }
    XFree(buffer);
    XGetWindowProperty(dpy, win, pty, 0, (long)pty_size, False, AnyPropertyType,
                       type, &pty_format, &pty_items, &pty_size,
                       (unsigned char **)&buffer);
    pty_machsize = pty_items * mach_itemsize(pty_format);
    if (*len == 0) {
      *len = pty_machsize;
      ltxt = (unsigned char *)xcmalloc(*len);
    } else {
      *len += pty_machsize;
      ltxt = (unsigned char *)xcrealloc(ltxt, *len);
    }
    memcpy(&ltxt[*len - pty_machsize], buffer, pty_machsize);
    *txt = ltxt;
    XFree(buffer);
    XDeleteProperty(dpy, win, pty);
    XFlush(dpy);
    return (0);
  }
  return (0);
}


x86 assembly (clang, -O0):
<xcout>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0xb8,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdx,-0x38(%rbp)
mov    %ecx,-0x30(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    %rdi,-0x40(%rbp)
mov    %esi,-0x44(%rbp)
mov    %r8,-0x50(%rbp)
mov    %r9,-0x58(%rbp)
mov    0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x88(%rbp)
cmpq   $0x0,0x2e76(%rip)
jne    1230 <xcout+0x80>
mov    -0x40(%rbp),%rdi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
lea    0xddc(%rip),%rsi
call   1090 <XInternAtom@plt>
mov    %rax,0x2e50(%rip)
cmpq   $0x0,0x2e50(%rip)
jne    125e <xcout+0xae>
mov    -0x40(%rbp),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
lea    0xdb8(%rip),%rsi
call   1090 <XInternAtom@plt>
mov    %rax,0x2e2a(%rip)
mov    0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
test   %eax,%eax
je     129f <xcout+0xef>
jmp    1277 <xcout+0xc7>
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
je     1300 <xcout+0x150>
jmp    128b <xcout+0xdb>
mov    -0x8c(%rbp),%eax
sub    $0x2,%eax
je     14e6 <xcout+0x336>
jmp    1704 <xcout+0x554>
mov    0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jbe    12c4 <xcout+0x114>
mov    0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <free@plt>
mov    0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    0x2da9(%rip),%rcx
mov    -0x44(%rbp),%r8d
mov    0x2cf6(%rip),%rax
mov    (%rax),%r9d
call   10d0 <XConvertSelection@plt>
mov    0x28(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x24(%rbp),%eax
mov    0x2cee(%rip),%rcx
cmp    (%rcx),%eax
je     131e <xcout+0x16e>
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x20(%rbp),%eax
mov    0x2c98(%rip),%rcx
cmp    (%rcx),%eax
jne    1346 <xcout+0x196>
mov    0x28(%rbp),%rax
movl   $0x3,(%rax)
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2d2c(%rip),%rdx
mov    0x2c75(%rip),%rax
mov    (%rax),%r9d
mov    0x2c83(%rip),%rax
mov    (%rax),%r15d
mov    0x10(%rbp),%r14
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x5c(%rbp),%rbx
lea    -0x78(%rbp),%r11
lea    -0x70(%rbp),%r10
lea    -0x68(%rbp),%rax
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   10c0 <XGetWindowProperty@plt>
mov    -0x68(%rbp),%rdi
call   1050 <XFree@plt>
mov    0x10(%rbp),%rax
mov    (%rax),%rax
cmp    0x2ccc(%rip),%rax
jne    13f4 <xcout+0x244>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2cb0(%rip),%rdx
call   1060 <XDeleteProperty@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <XFlush@plt>
mov    0x28(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2c7e(%rip),%rdx
mov    -0x70(%rbp),%r8
mov    0x2bc3(%rip),%rax
mov    (%rax),%r9d
mov    0x2bd1(%rip),%rax
mov    (%rax),%r15d
mov    0x10(%rbp),%r14
xor    %ecx,%ecx
lea    -0x5c(%rbp),%rbx
lea    -0x78(%rbp),%r11
lea    -0x70(%rbp),%r10
lea    -0x68(%rbp),%rax
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   10c0 <XGetWindowProperty@plt>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2c20(%rip),%rdx
call   1060 <XDeleteProperty@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x5c(%rbp),%edi
call   1030 <mach_itemsize@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
call   10a0 <xcmalloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x80(%rbp),%rdx
call   1070 <memcpy@plt>
mov    -0x80(%rbp),%rcx
mov    0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x88(%rbp),%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x68(%rbp),%rdi
call   1050 <XFree@plt>
mov    0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x24(%rbp),%eax
mov    0x2ac0(%rip),%rcx
cmp    (%rcx),%eax
je     1504 <xcout+0x354>
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x28(%rbp),%eax
mov    0x2aba(%rip),%rcx
cmp    (%rcx),%eax
je     1522 <xcout+0x372>
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2b50(%rip),%rdx
mov    0x2a99(%rip),%rax
mov    (%rax),%r9d
mov    0x2aa7(%rip),%rax
mov    (%rax),%r15d
mov    0x10(%rbp),%r14
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x5c(%rbp),%rbx
lea    -0x78(%rbp),%r11
lea    -0x70(%rbp),%r10
lea    -0x68(%rbp),%rax
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   10c0 <XGetWindowProperty@plt>
cmpq   $0x0,-0x70(%rbp)
jne    15be <xcout+0x40e>
mov    -0x68(%rbp),%rdi
call   1050 <XFree@plt>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2add(%rip),%rdx
call   1060 <XDeleteProperty@plt>
mov    0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
mov    -0x68(%rbp),%rdi
call   1050 <XFree@plt>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2aab(%rip),%rdx
mov    -0x70(%rbp),%r8
mov    0x29f0(%rip),%rax
mov    (%rax),%r9d
mov    0x29fe(%rip),%rax
mov    (%rax),%r15d
mov    0x10(%rbp),%r14
xor    %ecx,%ecx
lea    -0x5c(%rbp),%rbx
lea    -0x78(%rbp),%r11
lea    -0x70(%rbp),%r10
lea    -0x68(%rbp),%rax
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   10c0 <XGetWindowProperty@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x5c(%rbp),%edi
call   1030 <mach_itemsize@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    167b <xcout+0x4cb>
mov    -0x80(%rbp),%rcx
mov    0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    0x20(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <xcmalloc@plt>
mov    %rax,-0x88(%rbp)
jmp    16a3 <xcout+0x4f3>
mov    -0x80(%rbp),%rcx
mov    0x20(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x88(%rbp),%rdi
mov    0x20(%rbp),%rax
mov    (%rax),%rsi
call   1080 <xcrealloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
mov    0x20(%rbp),%rax
mov    (%rax),%rax
sub    -0x80(%rbp),%rax
add    %rax,%rdi
mov    -0x68(%rbp),%rsi
mov    -0x80(%rbp),%rdx
call   1070 <memcpy@plt>
mov    -0x88(%rbp),%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x68(%rbp),%rdi
call   1050 <XFree@plt>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x2996(%rip),%rdx
call   1060 <XDeleteProperty@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <XFlush@plt>
movl   $0x0,-0x1c(%rbp)
jmp    170b <xcout+0x55b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcout>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r13
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %esi,0x14(%rsp)
mov    %rdi,%rbp
mov    0x78(%rsp),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
cmpq   $0x0,0x2e9a(%rip)
jne    1207 <xcout+0x57>
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
lea    0xe08(%rip),%rsi
mov    %rbp,%rdi
call   1090 <XInternAtom@plt>
mov    %rax,0x2e79(%rip)
mov    %r12,%r15
shr    $0x20,%r15
mov    0x88(%rsp),%rdx
cmpq   $0x0,0x2e6a(%rip)
jne    1247 <xcout+0x97>
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
lea    0xdda(%rip),%rsi
mov    %rbp,%rdi
call   1090 <XInternAtom@plt>
mov    0x88(%rsp),%rdx
mov    %rax,0x2e41(%rip)
mov    %rbp,0x28(%rsp)
mov    0x80(%rsp),%rcx
mov    0x70(%rsp),%r10
mov    (%rdx),%eax
xor    %ebp,%ebp
cmp    $0x2,%eax
je     12c5 <xcout+0x115>
cmp    $0x1,%eax
je     13d8 <xcout+0x228>
test   %eax,%eax
jne    15c6 <xcout+0x416>
mov    %rdx,%r15
cmpq   $0x0,(%rcx)
je     1293 <xcout+0xe3>
mov    0x78(%rsp),%rax
mov    (%rax),%rdi
mov    %rcx,%r14
call   1040 <free@plt>
movq   $0x0,(%r14)
mov    0x2de6(%rip),%rcx
mov    0x2d37(%rip),%rax
mov    (%rax),%r9d
mov    0x28(%rsp),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    0x14(%rsp),%r8d
call   10d0 <XConvertSelection@plt>
movl   $0x1,(%r15)
jmp    15c6 <xcout+0x416>
mov    0x2ce4(%rip),%rax
cmp    %r15d,(%rax)
jne    15c6 <xcout+0x416>
mov    0x2cec(%rip),%rax
cmp    %r12d,(%rax)
jne    15c6 <xcout+0x416>
mov    0x2d94(%rip),%rdx
mov    0x2cdd(%rip),%rax
mov    (%rax),%r9d
mov    0x2ceb(%rip),%r14
mov    (%r14),%eax
lea    0x8(%rsp),%r12
lea    0x18(%rsp),%rbp
lea    0x20(%rsp),%rbx
lea    0x4(%rsp),%r11
mov    0x28(%rsp),%r15
mov    %r15,%rdi
mov    0x14(%rsp),%r13d
mov    %r13d,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
push   %r12
push   %rbp
push   %rbx
push   %r11
push   %r10
push   %rax
mov    %r10,%rbx
call   10c0 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x18(%rsp),%rbp
mov    0x8(%rsp),%rdi
call   1050 <XFree@plt>
mov    0x2d2c(%rip),%rdx
test   %rbp,%rbp
je     149f <xcout+0x2ef>
mov    0x18(%rsp),%r8
mov    0x2c67(%rip),%rax
mov    (%rax),%r9d
mov    (%r14),%eax
mov    %r15,%rdi
mov    %r13d,%esi
xor    %ecx,%ecx
lea    0x8(%rsp),%rbp
push   %rbp
lea    0x20(%rsp),%rbp
push   %rbp
lea    0x30(%rsp),%rbp
push   %rbp
lea    0x1c(%rsp),%rbp
push   %rbp
push   %rbx
push   %rax
call   10c0 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x20(%rsp),%rbp
mov    0x4(%rsp),%edi
call   1030 <mach_itemsize@plt>
mov    %rax,%rbx
imul   %rbp,%rbx
mov    0x80(%rsp),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1567 <xcout+0x3b7>
add    %rbx,%rsi
mov    %rsi,(%rax)
mov    0x30(%rsp),%rdi
call   1080 <xcrealloc@plt>
jmp    1572 <xcout+0x3c2>
mov    0x2c19(%rip),%rax
cmp    %r15d,(%rax)
jne    15c6 <xcout+0x416>
mov    0x2bd1(%rip),%rax
cmp    %r14d,(%rax)
jne    13ff <xcout+0x24f>
movl   $0x3,(%rdx)
jmp    15c6 <xcout+0x416>
mov    0x2c7a(%rip),%rdx
mov    0x2bc3(%rip),%rax
mov    (%rax),%r9d
mov    0x2bd1(%rip),%rax
mov    (%rax),%eax
lea    0x8(%rsp),%r15
lea    0x18(%rsp),%r14
lea    0x20(%rsp),%r12
lea    0x4(%rsp),%r11
xor    %ebp,%ebp
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
mov    0x14(%rsp),%r13d
mov    %r13d,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
push   %r15
push   %r14
push   %r12
push   %r11
push   %r10
push   %rax
mov    %r10,%r12
call   10c0 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x8(%rsp),%rdi
call   1050 <XFree@plt>
mov    (%r12),%rax
mov    0x2c10(%rip),%rdx
cmp    0x2c11(%rip),%rax
jne    14af <xcout+0x2ff>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1060 <XDeleteProperty@plt>
mov    %rbx,%rdi
call   10b0 <XFlush@plt>
mov    0x88(%rsp),%rax
movl   $0x2,(%rax)
jmp    15c6 <xcout+0x416>
mov    %r15,%rdi
mov    %r13d,%esi
call   1060 <XDeleteProperty@plt>
jmp    1552 <xcout+0x3a2>
mov    0x18(%rsp),%r8
mov    0x2b15(%rip),%rax
mov    (%rax),%r9d
mov    0x2b23(%rip),%rax
mov    (%rax),%eax
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %ecx,%ecx
lea    0x8(%rsp),%rbp
push   %rbp
lea    0x20(%rsp),%rbp
push   %rbp
lea    0x30(%rsp),%rbp
push   %rbp
lea    0x1c(%rsp),%rbp
push   %rbp
push   %r12
push   %rax
call   10c0 <XGetWindowProperty@plt>
add    $0x30,%rsp
mov    0x2b86(%rip),%rdx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1060 <XDeleteProperty@plt>
mov    0x20(%rsp),%rbp
mov    0x4(%rsp),%edi
call   1030 <mach_itemsize@plt>
mov    %rax,%rbx
imul   %rbp,%rbx
mov    %rbx,%rdi
call   10a0 <xcmalloc@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1070 <memcpy@plt>
mov    0x80(%rsp),%rax
mov    %rbx,(%rax)
mov    0x78(%rsp),%rax
mov    %rbp,(%rax)
mov    0x8(%rsp),%rdi
call   1050 <XFree@plt>
mov    0x88(%rsp),%rax
movl   $0x0,(%rax)
mov    $0x1,%ebp
jmp    15c6 <xcout+0x416>
mov    %rbx,(%rax)
mov    %rbx,%rdi
call   10a0 <xcmalloc@plt>
mov    0x80(%rsp),%rcx
mov    %rax,%rbp
mov    0x78(%rsp),%r14
mov    (%rcx),%rdi
sub    %rbx,%rdi
add    %rax,%rdi
mov    0x8(%rsp),%rsi
mov    %rbx,%rdx
call   1070 <memcpy@plt>
mov    %rbp,(%r14)
mov    0x8(%rsp),%rdi
call   1050 <XFree@plt>
mov    0x2ad4(%rip),%rdx
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1060 <XDeleteProperty@plt>
mov    %rbx,%rdi
call   10b0 <XFlush@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { %struct.TYPE_6__, i32, %struct.TYPE_5__ }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
@xcout.pty = internal global i64 0
@xcout.inc = internal global i64 0
@.str = [10 x i8] c"XCLIP_OUT\00"
@False = global i32 0
@.str.1 = [5 x i8] c"INCR\00"
@CurrentTime = global i32 0
@SelectionNotify = global i32 0
@None = global i32 0
@AnyPropertyType = global i32 0
@PropertyNotify = global i32 0
@PropertyNewValue = global i32 0
define i32 @xcout(i32* %0, i32 %1, i64 %2, i32 %3, i64 %4, i64 %5, i64* %6, i8** %7, i64* %8, i32* %9) {
%11 = alloca i32
%12 = alloca %struct.TYPE_7__
%13 = alloca { i64, i32 }
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64*
%19 = alloca i8**
%20 = alloca i64*
%21 = alloca i32*
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i64
%25 = alloca i64
%26 = alloca i64
%27 = alloca i8*
%28 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %13, i32 0, i32 0
store i64 %2, i64* %28
%29 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %13, i32 0, i32 1
store i32 %3, i32* %29
%30 = bitcast %struct.TYPE_7__* %12 to i8*
%31 = bitcast { i64, i32 }* %13 to i8*
store i32* %0, i32** %14
store i32 %1, i32* %15
store i64 %4, i64* %16
store i64 %5, i64* %17
store i64* %6, i64** %18
store i8** %7, i8*** %19
store i64* %8, i64** %20
store i32* %9, i32** %21
%32 = load i8**, i8*** %19
%33 = load i8*, i8** %32
store i8* %33, i8** %27
%34 = load i64, i64* @xcout.pty
%35 = icmp ne i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %10
%37 = load i32*, i32** %14
%38 = load i32, i32* @False
%39 = call i64 @XInternAtom(i32* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %38)
store i64 %39, i64* @xcout.pty
br label %40
40: ; preds = %36, %10
%41 = load i64, i64* @xcout.inc
%42 = icmp ne i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %40
%44 = load i32*, i32** %14
%45 = load i32, i32* @False
%46 = call i64 @XInternAtom(i32* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %45)
store i64 %46, i64* @xcout.inc
br label %47
47: ; preds = %43, %40
%48 = load i32*, i32** %21
%49 = load i32, i32* %48
switch i32 %49, label %221 [
i32 0, label %50
i32 1, label %68
i32 2, label %135
]
50: ; preds = %47
%51 = load i64*, i64** %20
%52 = load i64, i64* %51
%53 = icmp ugt i64 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = load i8**, i8*** %19
%56 = load i8*, i8** %55
%57 = call i32 @free(i8* %56)
%58 = load i64*, i64** %20
store i64 0, i64* %58
br label %59
59: ; preds = %54, %50
%60 = load i32*, i32** %14
%61 = load i64, i64* %16
%62 = load i64, i64* %17
%63 = load i64, i64* @xcout.pty
%64 = load i32, i32* %15
%65 = load i32, i32* @CurrentTime
%66 = call i32 @XConvertSelection(i32* %60, i64 %61, i64 %62, i64 %63, i32 %64, i32 %65)
%67 = load i32*, i32** %21
store i32 1, i32* %67
store i32 0, i32* %11
br label %222
68: ; preds = %47
%69 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %12, i32 0, i32 1
%70 = load i32, i32* %69
%71 = load i32, i32* @SelectionNotify
%72 = icmp ne i32 %70, %71
br i1 %72, label %73, label %74
73: ; preds = %68
store i32 0, i32* %11
br label %222
74: ; preds = %68
%75 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %12, i32 0, i32 2
%76 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = load i32, i32* @None
%79 = icmp eq i32 %77, %78
br i1 %79, label %80, label %82
80: ; preds = %74
%81 = load i32*, i32** %21
store i32 3, i32* %81
store i32 0, i32* %11
br label %222
82: ; preds = %74
%83 = load i32*, i32** %14
%84 = load i32, i32* %15
%85 = load i64, i64* @xcout.pty
%86 = load i32, i32* @False
%87 = load i32, i32* @AnyPropertyType
%88 = load i64*, i64** %18
%89 = call i32 @XGetWindowProperty(i32* %83, i32 %84, i64 %85, i32 0, i64 0, i32 %86, i32 %87, i64* %88, i32* %22, i64* %25, i64* %24, i8** %23)
%90 = load i8*, i8** %23
%91 = call i32 @XFree(i8* %90)
%92 = load i64*, i64** %18
%93 = load i64, i64* %92
%94 = load i64, i64* @xcout.inc
%95 = icmp eq i64 %93, %94
br i1 %95, label %96, label %104
96: ; preds = %82
%97 = load i32*, i32** %14
%98 = load i32, i32* %15
%99 = load i64, i64* @xcout.pty
%100 = call i32 @XDeleteProperty(i32* %97, i32 %98, i64 %99)
%101 = load i32*, i32** %14
%102 = call i32 @XFlush(i32* %101)
%103 = load i32*, i32** %21
store i32 2, i32* %103
store i32 0, i32* %11
br label %222
104: ; preds = %82
%105 = load i32*, i32** %14
%106 = load i32, i32* %15
%107 = load i64, i64* @xcout.pty
%108 = load i64, i64* %24
%109 = load i32, i32* @False
%110 = load i32, i32* @AnyPropertyType
%111 = load i64*, i64** %18
%112 = call i32 @XGetWindowProperty(i32* %105, i32 %106, i64 %107, i32 0, i64 %108, i32 %109, i32 %110, i64* %111, i32* %22, i64* %25, i64* %24, i8** %23)
%113 = load i32*, i32** %14
%114 = load i32, i32* %15
%115 = load i64, i64* @xcout.pty
%116 = call i32 @XDeleteProperty(i32* %113, i32 %114, i64 %115)
%117 = load i64, i64* %25
%118 = load i32, i32* %22
%119 = call i64 @mach_itemsize(i32 %118)
%120 = mul i64 %117, %119
store i64 %120, i64* %26
%121 = load i64, i64* %26
%122 = call i64 @xcmalloc(i64 %121)
%123 = inttoptr i64 %122 to i8*
store i8* %123, i8** %27
%124 = load i8*, i8** %27
%125 = load i8*, i8** %23
%126 = load i64, i64* %26
%127 = call i32 @memcpy(i8* %124, i8* %125, i64 %126)
%128 = load i64, i64* %26
%129 = load i64*, i64** %20
store i64 %128, i64* %129
%130 = load i8*, i8** %27
%131 = load i8**, i8*** %19
store i8* %130, i8** %131
%132 = load i8*, i8** %23
%133 = call i32 @XFree(i8* %132)
%134 = load i32*, i32** %21
store i32 0, i32* %134
store i32 1, i32* %11
br label %222
135: ; preds = %47
%136 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %12, i32 0, i32 1
%137 = load i32, i32* %136
%138 = load i32, i32* @PropertyNotify
%139 = icmp ne i32 %137, %138
br i1 %139, label %140, label %141
140: ; preds = %135
store i32 0, i32* %11
br label %222
141: ; preds = %135
%142 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %12, i32 0, i32 0
%143 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %142, i32 0, i32 0
%144 = load i32, i32* %143
%145 = load i32, i32* @PropertyNewValue
%146 = icmp ne i32 %144, %145
br i1 %146, label %147, label %148
147: ; preds = %141
store i32 0, i32* %11
br label %222
148: ; preds = %141
%149 = load i32*, i32** %14
%150 = load i32, i32* %15
%151 = load i64, i64* @xcout.pty
%152 = load i32, i32* @False
%153 = load i32, i32* @AnyPropertyType
%154 = load i64*, i64** %18
%155 = call i32 @XGetWindowProperty(i32* %149, i32 %150, i64 %151, i32 0, i64 0, i32 %152, i32 %153, i64* %154, i32* %22, i64* %25, i64* %24, i8** %23)
%156 = load i64, i64* %24
%157 = icmp eq i64 %156, 0
br i1 %157, label %158, label %166
158: ; preds = %148
%159 = load i8*, i8** %23
%160 = call i32 @XFree(i8* %159)
%161 = load i32*, i32** %14
%162 = load i32, i32* %15
%163 = load i64, i64* @xcout.pty
%164 = call i32 @XDeleteProperty(i32* %161, i32 %162, i64 %163)
%165 = load i32*, i32** %21
store i32 0, i32* %165
store i32 1, i32* %11
br label %222
166: ; preds = %148
%167 = load i8*, i8** %23
%168 = call i32 @XFree(i8* %167)
%169 = load i32*, i32** %14
%170 = load i32, i32* %15
%171 = load i64, i64* @xcout.pty
%172 = load i64, i64* %24
%173 = load i32, i32* @False
%174 = load i32, i32* @AnyPropertyType
%175 = load i64*, i64** %18
%176 = call i32 @XGetWindowProperty(i32* %169, i32 %170, i64 %171, i32 0, i64 %172, i32 %173, i32 %174, i64* %175, i32* %22, i64* %25, i64* %24, i8** %23)
%177 = load i64, i64* %25
%178 = load i32, i32* %22
%179 = call i64 @mach_itemsize(i32 %178)
%180 = mul i64 %177, %179
store i64 %180, i64* %26
%181 = load i64*, i64** %20
%182 = load i64, i64* %181
%183 = icmp eq i64 %182, 0
br i1 %183, label %184, label %191
184: ; preds = %166
%185 = load i64, i64* %26
%186 = load i64*, i64** %20
store i64 %185, i64* %186
%187 = load i64*, i64** %20
%188 = load i64, i64* %187
%189 = call i64 @xcmalloc(i64 %188)
%190 = inttoptr i64 %189 to i8*
store i8* %190, i8** %27
br label %201
191: ; preds = %166
%192 = load i64, i64* %26
%193 = load i64*, i64** %20
%194 = load i64, i64* %193
%195 = add i64 %194, %192
store i64 %195, i64* %193
%196 = load i8*, i8** %27
%197 = load i64*, i64** %20
%198 = load i64, i64* %197
%199 = call i64 @xcrealloc(i8* %196, i64 %198)
%200 = inttoptr i64 %199 to i8*
store i8* %200, i8** %27
br label %201
201: ; preds = %191, %184
%202 = load i8*, i8** %27
%203 = load i64*, i64** %20
%204 = load i64, i64* %203
%205 = load i64, i64* %26
%206 = sub i64 %204, %205
%207 = getelementptr inbounds i8, i8* %202, i64 %206
%208 = load i8*, i8** %23
%209 = load i64, i64* %26
%210 = call i32 @memcpy(i8* %207, i8* %208, i64 %209)
%211 = load i8*, i8** %27
%212 = load i8**, i8*** %19
store i8* %211, i8** %212
%213 = load i8*, i8** %23
%214 = call i32 @XFree(i8* %213)
%215 = load i32*, i32** %14
%216 = load i32, i32* %15
%217 = load i64, i64* @xcout.pty
%218 = call i32 @XDeleteProperty(i32* %215, i32 %216, i64 %217)
%219 = load i32*, i32** %14
%220 = call i32 @XFlush(i32* %219)
store i32 0, i32* %11
br label %222
221: ; preds = %47
store i32 0, i32* %11
br label %222
222: ; preds = %221, %201, %158, %147, %140, %104, %96, %80, %73, %59
%223 = load i32, i32* %11
ret i32 %223
}

LLVM IR (-O2):
@xcout.pty = internal unnamed_addr global i64 0
@xcout.inc = internal unnamed_addr global i64 0
@.str = [10 x i8] c"XCLIP_OUT\00"
@False = global i32 0
@.str.1 = [5 x i8] c"INCR\00"
@CurrentTime = global i32 0
@SelectionNotify = global i32 0
@None = global i32 0
@AnyPropertyType = global i32 0
@PropertyNotify = global i32 0
@PropertyNewValue = global i32 0
define i32 @xcout(i32* %0, i32 %1, i64 %2, i32 %3, i64 %4, i64 %5, i64* %6, i8** nocapture %7, i64* nocapture %8, i32* nocapture %9) {
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = trunc i64 %2 to i32
%16 = lshr i64 %2, 32
%17 = trunc i64 %16 to i32
%18 = bitcast i32* %11 to i8*
%19 = bitcast i8** %12 to i8*
%20 = bitcast i64* %13 to i8*
%21 = bitcast i64* %14 to i8*
%22 = load i8*, i8** %7
%23 = load i64, i64* @xcout.pty
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %10
%26 = load i32, i32* @False
%27 = tail call i64 @XInternAtom(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %26)
store i64 %27, i64* @xcout.pty
br label %28
28: ; preds = %25, %10
%29 = load i64, i64* @xcout.inc
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @False
%33 = tail call i64 @XInternAtom(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %32)
store i64 %33, i64* @xcout.inc
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %9
switch i32 %35, label %131 [
i32 0, label %36
i32 1, label %46
i32 2, label %84
]
36: ; preds = %34
%37 = load i64, i64* %8
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i8*, i8** %7
%41 = tail call i32 @free(i8* %40)
store i64 0, i64* %8
br label %42
42: ; preds = %39, %36
%43 = load i64, i64* @xcout.pty
%44 = load i32, i32* @CurrentTime
%45 = tail call i32 @XConvertSelection(i32* %0, i64 %4, i64 %5, i64 %43, i32 %1, i32 %44)
store i32 1, i32* %9
br label %131
46: ; preds = %34
%47 = load i32, i32* @SelectionNotify
%48 = icmp eq i32 %47, %17
br i1 %48, label %49, label %131
49: ; preds = %46
%50 = load i32, i32* @None
%51 = icmp eq i32 %50, %3
br i1 %51, label %52, label %53
52: ; preds = %49
store i32 3, i32* %9
br label %131
53: ; preds = %49
%54 = load i64, i64* @xcout.pty
%55 = load i32, i32* @False
%56 = load i32, i32* @AnyPropertyType
%57 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %54, i32 0, i64 0, i32 %55, i32 %56, i64* %6, i32* %11, i64* %14, i64* %13, i8** %12)
%58 = load i8*, i8** %12
%59 = call i32 @XFree(i8* %58)
%60 = load i64, i64* %6
%61 = load i64, i64* @xcout.inc
%62 = icmp eq i64 %60, %61
%63 = load i64, i64* @xcout.pty
br i1 %62, label %64, label %67
64: ; preds = %53
%65 = call i32 @XDeleteProperty(i32* %0, i32 %1, i64 %63)
%66 = call i32 @XFlush(i32* %0)
store i32 2, i32* %9
br label %131
67: ; preds = %53
%68 = load i64, i64* %13
%69 = load i32, i32* @False
%70 = load i32, i32* @AnyPropertyType
%71 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %63, i32 0, i64 %68, i32 %69, i32 %70, i64* %6, i32* %11, i64* %14, i64* %13, i8** %12)
%72 = load i64, i64* @xcout.pty
%73 = call i32 @XDeleteProperty(i32* %0, i32 %1, i64 %72)
%74 = load i64, i64* %14
%75 = load i32, i32* %11
%76 = call i64 @mach_itemsize(i32 %75)
%77 = mul i64 %76, %74
%78 = call i64 @xcmalloc(i64 %77)
%79 = inttoptr i64 %78 to i8*
%80 = load i8*, i8** %12
%81 = call i32 @memcpy(i8* %79, i8* %80, i64 %77)
store i64 %77, i64* %8
store i8* %79, i8** %7
%82 = load i8*, i8** %12
%83 = call i32 @XFree(i8* %82)
store i32 0, i32* %9
br label %131
84: ; preds = %34
%85 = load i32, i32* @PropertyNotify
%86 = icmp eq i32 %85, %17
%87 = load i32, i32* @PropertyNewValue
%88 = icmp eq i32 %87, %15
%89 = select i1 %86, i1 %88, i1 false
br i1 %89, label %90, label %131
90: ; preds = %84
%91 = load i64, i64* @xcout.pty
%92 = load i32, i32* @False
%93 = load i32, i32* @AnyPropertyType
%94 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %91, i32 0, i64 0, i32 %92, i32 %93, i64* %6, i32* %11, i64* %14, i64* %13, i8** %12)
%95 = load i64, i64* %13
%96 = icmp eq i64 %95, 0
%97 = load i8*, i8** %12
%98 = call i32 @XFree(i8* %97)
%99 = load i64, i64* @xcout.pty
br i1 %96, label %100, label %102
100: ; preds = %90
%101 = call i32 @XDeleteProperty(i32* %0, i32 %1, i64 %99)
store i32 0, i32* %9
br label %131
102: ; preds = %90
%103 = load i64, i64* %13
%104 = load i32, i32* @False
%105 = load i32, i32* @AnyPropertyType
%106 = call i32 @XGetWindowProperty(i32* %0, i32 %1, i64 %99, i32 0, i64 %103, i32 %104, i32 %105, i64* %6, i32* %11, i64* %14, i64* %13, i8** %12)
%107 = load i64, i64* %14
%108 = load i32, i32* %11
%109 = call i64 @mach_itemsize(i32 %108)
%110 = mul i64 %109, %107
%111 = load i64, i64* %8
%112 = icmp eq i64 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %102
store i64 %110, i64* %8
%114 = call i64 @xcmalloc(i64 %110)
br label %118
115: ; preds = %102
%116 = add i64 %111, %110
store i64 %116, i64* %8
%117 = call i64 @xcrealloc(i8* %22, i64 %116)
br label %118
118: ; preds = %115, %113
%119 = phi i64 [ %114, %113 ], [ %117, %115 ]
%120 = inttoptr i64 %119 to i8*
%121 = load i64, i64* %8
%122 = sub i64 %121, %110
%123 = getelementptr inbounds i8, i8* %120, i64 %122
%124 = load i8*, i8** %12
%125 = call i32 @memcpy(i8* %123, i8* %124, i64 %110)
store i8* %120, i8** %7
%126 = load i8*, i8** %12
%127 = call i32 @XFree(i8* %126)
%128 = load i64, i64* @xcout.pty
%129 = call i32 @XDeleteProperty(i32* %0, i32 %1, i64 %128)
%130 = call i32 @XFlush(i32* %0)
br label %131
131: ; preds = %34, %84, %46, %118, %100, %67, %64, %52, %42
%132 = phi i32 [ 1, %100 ], [ 0, %118 ], [ 0, %52 ], [ 0, %64 ], [ 1, %67 ], [ 0, %42 ], [ 0, %46 ], [ 0, %84 ], [ 0, %34 ]
ret i32 %132
}