#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 */
struct sockaddr_un {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
struct pollfd {
  int member_0;
  int member_1;
  int revents;
  int /*<<< orphan*/ member_2;
};
typedef int /*<<< orphan*/ sock_address;
typedef int /*<<< orphan*/ rsp;
typedef int /*<<< orphan*/ msg;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int BUFSIZ;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int POLLERR;
int POLLHUP;
int POLLIN;
int /*<<< orphan*/ SOCK_STREAM;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ err(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
scalar_t__ poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int snprintf(char *, int, char *, char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
scalar_t__ xcb_parse_display(int /*<<< orphan*/ *, char **, int *, int *);
int main(int argc, char *argv[]) {
  int sock_fd;
  struct sockaddr_un sock_address;
  char msg[BUFSIZ], rsp[BUFSIZ];
  if (argc < 2) {
    err("No arguments given.\n");
  }
  sock_address.sun_family = AF_UNIX;
  char *sp;
  if ((sock_fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
    err("Failed to create the socket.\n");
  }
  sp = getenv("BSPWM_SOCKET");
  if (sp != NULL) {
    snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", sp);
  } else {
    char *host = NULL;
    int dn = 0, sn = 0;
    if (xcb_parse_display(NULL, &host, &dn, &sn) != 0) {
      snprintf(sock_address.sun_path, sizeof(sock_address.sun_path),
               "/tmp/bspwm%s_%i_%i-socket", host, dn, sn);
    }
    free(host);
  }
  if (connect(sock_fd, (struct sockaddr *)&sock_address,
              sizeof(sock_address)) == -1) {
    err("Failed to connect to the socket.\n");
  }
  argc--, argv++;
  int msg_len = 0;
  for (int offset = 0, rem = sizeof(msg), n = 0; argc > 0 && rem > 0;
       offset += n, rem -= n, argc--, argv++) {
    n = snprintf(msg + offset, rem, "%s%c", *argv, 0);
    msg_len += n;
  }
  if (send(sock_fd, msg, msg_len, 0) == -1) {
    err("Failed to send the data.\n");
  }
  int ret = EXIT_SUCCESS, nb;
  struct pollfd fds[] = {
      {sock_fd, POLLIN, 0},
      {STDOUT_FILENO, POLLHUP, 0},
  };
  while (poll(fds, 2, -1) > 0) {
    if (fds[1].revents & (POLLERR | POLLHUP)) {
      break;
    }
    if (fds[0].revents & POLLIN) {
      if ((nb = recv(sock_fd, rsp, sizeof(rsp) - 1, 0)) > 0) {
        rsp[nb] = '\0';
        if (rsp[0] == "\x07"[0]) {
          ret = EXIT_FAILURE;
          printf("%s", rsp + 1);
        } else {
          printf("%s", rsp);
        }
        fflush(stdout);
      } else {
        break;
      }
    }
  }
  close(sock_fd);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0xb0(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0xa8(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x30(%rbp)
mov    (%rax),%eax
mov    %rax,-0xa0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    125d <main+0x8d>
lea    0xda8(%rip),%rdi
call   10a0 <err@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    129a <main+0xca>
lea    0xd80(%rip),%rdi
call   10a0 <err@plt>
lea    0xd92(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     12d5 <main+0x105>
movslq -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0x4,%esi
lea    0xd77(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
jmp    1336 <main+0x166>
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x48(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10e0 <xcb_parse_display@plt>
cmp    $0x0,%rax
je     132d <main+0x15d>
movslq -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    -0x4c(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    $0x4,%esi
lea    0xd1d(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    135c <main+0x18c>
lea    0xd06(%rip),%rdi
call   10a0 <err@plt>
mov    -0xb0(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
mov    -0x10(%rbp),%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xb1(%rbp)
jle    13af <main+0x1df>
cmpl   $0x0,-0x5c(%rbp)
setg   %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    13c2 <main+0x1f2>
jmp    1425 <main+0x255>
mov    -0xa8(%rbp),%rdi
movslq -0x58(%rbp),%rax
add    %rax,%rdi
mov    -0x5c(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xc9e(%rip),%rdx
xor    %r8d,%r8d
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x60(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x60(%rbp),%ecx
mov    -0x5c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1390 <main+0x1c0>
mov    -0xa8(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x54(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    144e <main+0x27e>
lea    0xc3b(%rip),%rdi
call   10a0 <err@plt>
mov    0x2b43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    0x2b5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0x0,-0x84(%rbp)
mov    0x2b63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    0x2b47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   10c0 <poll@plt>
cmp    $0x0,%rax
jle    15b1 <main+0x3e1>
mov    -0x78(%rbp),%eax
mov    0x2b02(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2b01(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     14f1 <main+0x321>
jmp    15b1 <main+0x3e1>
mov    -0x88(%rbp),%eax
mov    0x2aca(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     15ac <main+0x3dc>
mov    -0x98(%rbp),%rsi
mov    -0xa0(%rbp),%rax
mov    -0x14(%rbp),%edi
sub    $0x1,%rax
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <recv@plt>
mov    %eax,-0x68(%rbp)
cmp    $0x0,%eax
jle    15a2 <main+0x3d2>
mov    -0x98(%rbp),%rax
movslq -0x68(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl (%rax),%eax
movsbl 0xb52(%rip),%ecx
cmp    %ecx,%eax
jne    157c <main+0x3ac>
mov    -0x98(%rbp),%rsi
mov    0x2a46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
add    $0x1,%rsi
lea    0xace(%rip),%rdi
call   1070 <printf@plt>
jmp    158f <main+0x3bf>
mov    -0x98(%rbp),%rsi
lea    0xab6(%rip),%rdi
call   1070 <printf@plt>
mov    0x2a0a(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    15a7 <main+0x3d7>
jmp    15b1 <main+0x3e1>
jmp    15ac <main+0x3dc>
jmp    14ac <main+0x2dc>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x64(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%r13
mov    0x2dbf(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rdx
lea    0xf(%r15),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rdx,%rsp
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rax,-0x48(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
cmp    $0x1,%edi
jg     1235 <main+0x65>
lea    0xdd0(%rip),%rdi
call   10a0 <err@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    %edi,-0x84(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    1268 <main+0x98>
lea    0xdb2(%rip),%rdi
call   10a0 <err@plt>
lea    0xdc4(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1293 <main+0xc3>
lea    0xdc0(%rip),%rdx
xor    %edi,%edi
mov    $0x4,%esi
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <snprintf@plt>
jmp    12eb <main+0x11b>
movq   $0x0,-0x70(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    -0x70(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
xor    %edi,%edi
call   10e0 <xcb_parse_display@plt>
test   %rax,%rax
je     12e2 <main+0x112>
mov    -0x70(%rbp),%rcx
mov    -0x40(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
lea    0xd6f(%rip),%rdx
xor    %edi,%edi
mov    $0x4,%esi
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
lea    -0x88(%rbp),%rsi
mov    -0x2c(%rbp),%edi
mov    $0x8,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1310 <main+0x140>
lea    0xd52(%rip),%rdi
call   10a0 <err@plt>
xor    %r12d,%r12d
cmp    $0x2,%r14d
mov    %r13,-0x78(%rbp)
jl     136a <main+0x19a>
test   %r15d,%r15d
jle    136a <main+0x19a>
add    $0x8,%rbx
xor    %r13d,%r13d
xor    %r12d,%r12d
nopl   0x0(%rax)
movslq %r13d,%rdi
add    -0x38(%rbp),%rdi
mov    (%rbx),%rcx
mov    %r15d,%esi
lea    0xd3b(%rip),%rdx
xor    %r8d,%r8d
xor    %eax,%eax
call   1080 <snprintf@plt>
add    %eax,%r12d
cmp    $0x3,%r14d
jb     136a <main+0x19a>
add    $0xffffffff,%r14d
add    %eax,%r13d
sub    %eax,%r15d
add    $0x8,%rbx
test   %r15d,%r15d
jg     1330 <main+0x160>
mov    -0x2c(%rbp),%ebx
mov    %ebx,%edi
mov    -0x38(%rbp),%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    138e <main+0x1be>
lea    0xcfb(%rip),%rdi
call   10a0 <err@plt>
mov    0x2c03(%rip),%rax
mov    (%rax),%r14d
mov    %ebx,-0x70(%rbp)
mov    0x2c26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
movq   $0x0,-0x68(%rbp)
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2c1e(%rip),%r12
mov    (%r12),%eax
mov    %eax,-0x5c(%rbp)
movq   $0x0,-0x58(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   10c0 <poll@plt>
test   %rax,%rax
mov    %r14d,-0x38(%rbp)
jle    149e <main+0x2ce>
mov    -0x48(%rbp),%rax
add    $0xffffffff,%eax
mov    %rax,-0x48(%rbp)
mov    0x2bd5(%rip),%r15
lea    -0x70(%rbp),%r13
mov    -0x80(%rbp),%r14
jmp    144a <main+0x27a>
nopl   (%rax)
mov    %al,%sil
add    %r14,%rsi
lea    0xc23(%rip),%rdi
call   1070 <printf@plt>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    -0x2c(%rbp),%ebx
mov    %r13,%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   10c0 <poll@plt>
test   %rax,%rax
jle    149e <main+0x2ce>
mov    (%r12),%eax
or     (%r15),%eax
test   %eax,-0x58(%rbp)
jne    149e <main+0x2ce>
mov    0x2b6b(%rip),%rax
mov    (%rax),%eax
test   %eax,-0x68(%rbp)
je     1433 <main+0x263>
mov    %ebx,%edi
mov    %r14,%rsi
mov    -0x48(%rbp),%rdx
xor    %ecx,%ecx
call   1050 <recv@plt>
test   %eax,%eax
jle    149b <main+0x2cb>
mov    %eax,%eax
movb   $0x0,(%r14,%rax,1)
xor    %esi,%esi
cmpb   $0x7,(%r14)
sete   %al
jne    1410 <main+0x240>
mov    0x2b17(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,-0x38(%rbp)
jmp    1410 <main+0x240>
mov    -0x2c(%rbp),%ebx
mov    %ebx,%edi
call   1090 <close@plt>
mov    -0x78(%rbp),%rsp
mov    -0x38(%rbp),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.pollfd = type { i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@.str = [21 x i8] c"No arguments given.\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [30 x i8] c"Failed to create the socket.\0A\00"
@.str.2 = [13 x i8] c"BSPWM_SOCKET\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [26 x i8] c"/tmp/bspwm%s_%i_%i-socket\00"
@.str.5 = [34 x i8] c"Failed to connect to the socket.\0A\00"
@.str.6 = [5 x i8] c"%s%c\00"
@.str.7 = [26 x i8] c"Failed to send the data.\0A\00"
@EXIT_SUCCESS = global i32 0
@POLLIN = global i32 0
@STDOUT_FILENO = global i32 0
@POLLHUP = global i32 0
@POLLERR = global i32 0
@.str.8 = [2 x i8] c"\07\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_un
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca [2 x %struct.pollfd]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* @BUFSIZ
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %8
%25 = alloca i8, i64 %23
store i64 %23, i64* %9
%26 = load i32, i32* @BUFSIZ
%27 = zext i32 %26 to i64
%28 = alloca i8, i64 %27
store i64 %27, i64* %10
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 2
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 @err(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %2
%34 = load i32, i32* @AF_UNIX
%35 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 1
store i32 %34, i32* %35
%36 = load i32, i32* @AF_UNIX
%37 = load i32, i32* @SOCK_STREAM
%38 = call i32 @socket(i32 %36, i32 %37, i32 0)
store i32 %38, i32* %6
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %33
%41 = call i32 @err(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %42
42: ; preds = %40, %33
%43 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i8* %43, i8** %11
%44 = load i8*, i8** %11
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %53
46: ; preds = %42
%47 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%48 = load i32, i32* %47
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i8*
%51 = load i8*, i8** %11
%52 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %50, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %68
53: ; preds = %42
store i8* null, i8** %12
store i32 0, i32* %13
store i32 0, i32* %14
%54 = call i64 @xcb_parse_display(i32* null, i8** %12, i32* %13, i32* %14)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%58 = load i32, i32* %57
%59 = sext i32 %58 to i64
%60 = inttoptr i64 %59 to i8*
%61 = load i8*, i8** %12
%62 = load i32, i32* %13
%63 = load i32, i32* %14
%64 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %60, i32 4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %61, i32 %62, i32 %63)
br label %65
65: ; preds = %56, %53
%66 = load i8*, i8** %12
%67 = call i32 @free(i8* %66)
br label %68
68: ; preds = %65, %46
%69 = load i32, i32* %6
%70 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%71 = call i32 @connect(i32 %69, %struct.sockaddr* %70, i32 8)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = call i32 @err(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %73, %68
%76 = load i32, i32* %4
%77 = add nsw i32 %76, -1
store i32 %77, i32* %4
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i32 1
store i8** %79, i8*** %5
store i32 0, i32* %15
store i32 0, i32* %16
%80 = trunc i64 %23 to i32
store i32 %80, i32* %17
store i32 0, i32* %18
br label %81
81: ; preds = %100, %75
%82 = load i32, i32* %4
%83 = icmp sgt i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i32, i32* %17
%86 = icmp sgt i32 %85, 0
br label %87
87: ; preds = %84, %81
%88 = phi i1 [ false, %81 ], [ %86, %84 ]
br i1 %88, label %89, label %111
89: ; preds = %87
%90 = load i32, i32* %16
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %25, i64 %91
%93 = load i32, i32* %17
%94 = load i8**, i8*** %5
%95 = load i8*, i8** %94
%96 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %92, i32 %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %95, i32 0)
store i32 %96, i32* %18
%97 = load i32, i32* %18
%98 = load i32, i32* %15
%99 = add nsw i32 %98, %97
store i32 %99, i32* %15
br label %100
100: ; preds = %89
%101 = load i32, i32* %18
%102 = load i32, i32* %16
%103 = add nsw i32 %102, %101
store i32 %103, i32* %16
%104 = load i32, i32* %18
%105 = load i32, i32* %17
%106 = sub nsw i32 %105, %104
store i32 %106, i32* %17
%107 = load i32, i32* %4
%108 = add nsw i32 %107, -1
store i32 %108, i32* %4
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i32 1
store i8** %110, i8*** %5
br label %81
111: ; preds = %87
%112 = load i32, i32* %6
%113 = load i32, i32* %15
%114 = call i32 @send(i32 %112, i8* %25, i32 %113, i32 0)
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %118
116: ; preds = %111
%117 = call i32 @err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
br label %118
118: ; preds = %116, %111
%119 = load i32, i32* @EXIT_SUCCESS
store i32 %119, i32* %19
%120 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %21, i64 0, i64 0
%121 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %120, i32 0, i32 0
%122 = load i32, i32* %6
store i32 %122, i32* %121
%123 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %120, i32 0, i32 1
%124 = load i32, i32* @POLLIN
store i32 %124, i32* %123
%125 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %120, i32 0, i32 2
store i32 0, i32* %125
%126 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %120, i32 0, i32 3
store i32 0, i32* %126
%127 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %120, i64 1
%128 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %127, i32 0, i32 0
%129 = load i32, i32* @STDOUT_FILENO
store i32 %129, i32* %128
%130 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %127, i32 0, i32 1
%131 = load i32, i32* @POLLHUP
store i32 %131, i32* %130
%132 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %127, i32 0, i32 2
store i32 0, i32* %132
%133 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %127, i32 0, i32 3
store i32 0, i32* %133
br label %134
134: ; preds = %182, %118
%135 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %21, i64 0, i64 0
%136 = call i64 @poll(%struct.pollfd* %135, i32 2, i32 -1)
%137 = icmp sgt i64 %136, 0
br i1 %137, label %138, label %183
138: ; preds = %134
%139 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %21, i64 0, i64 1
%140 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %139, i32 0, i32 2
%141 = load i32, i32* %140
%142 = load i32, i32* @POLLERR
%143 = load i32, i32* @POLLHUP
%144 = or i32 %142, %143
%145 = and i32 %141, %144
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %138
br label %183
148: ; preds = %138
%149 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %21, i64 0, i64 0
%150 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %149, i32 0, i32 2
%151 = load i32, i32* %150
%152 = load i32, i32* @POLLIN
%153 = and i32 %151, %152
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %182
155: ; preds = %148
%156 = load i32, i32* %6
%157 = sub i64 %27, 1
%158 = trunc i64 %157 to i32
%159 = call i32 @recv(i32 %156, i8* %28, i32 %158, i32 0)
store i32 %159, i32* %20
%160 = icmp sgt i32 %159, 0
br i1 %160, label %161, label %180
161: ; preds = %155
%162 = load i32, i32* %20
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8, i8* %28, i64 %163
store i8 0, i8* %164
%165 = getelementptr inbounds i8, i8* %28, i64 0
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%169 = sext i8 %168 to i32
%170 = icmp eq i32 %167, %169
br i1 %170, label %171, label %175
171: ; preds = %161
%172 = load i32, i32* @EXIT_FAILURE
store i32 %172, i32* %19
%173 = getelementptr inbounds i8, i8* %28, i64 1
%174 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %173)
br label %177
175: ; preds = %161
%176 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %177
177: ; preds = %175, %171
%178 = load i32, i32* @stdout
%179 = call i32 @fflush(i32 %178)
br label %181
180: ; preds = %155
br label %183
181: ; preds = %177
br label %182
182: ; preds = %181, %148
br label %134
183: ; preds = %180, %147, %134
%184 = load i32, i32* %6
%185 = call i32 @close(i32 %184)
%186 = load i32, i32* %19
store i32 %186, i32* %3
%187 = load i8*, i8** %8
%188 = load i32, i32* %3
ret i32 %188
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.pollfd = type { i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@.str = [21 x i8] c"No arguments given.\0A\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [30 x i8] c"Failed to create the socket.\0A\00"
@.str.2 = [13 x i8] c"BSPWM_SOCKET\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [26 x i8] c"/tmp/bspwm%s_%i_%i-socket\00"
@.str.5 = [34 x i8] c"Failed to connect to the socket.\0A\00"
@.str.6 = [5 x i8] c"%s%c\00"
@.str.7 = [26 x i8] c"Failed to send the data.\0A\00"
@EXIT_SUCCESS = global i32 0
@POLLIN = global i32 0
@STDOUT_FILENO = global i32 0
@POLLHUP = global i32 0
@POLLERR = global i32 0
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x %struct.pollfd]
%8 = bitcast %struct.sockaddr_un* %3 to i8*
%9 = load i32, i32* @BUFSIZ
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = load i32, i32* @BUFSIZ
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
%16 = icmp slt i32 %0, 2
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @err(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %2
%20 = load i32, i32* @AF_UNIX
%21 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %20, i32* %21
%22 = load i32, i32* @SOCK_STREAM
%23 = tail call i32 @socket(i32 %20, i32 %22, i32 0)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @err(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
%28 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* null, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %46
32: ; preds = %27
%33 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%34 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%35 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%36 = call i64 @xcb_parse_display(i32* null, i8** %4, i32* %5, i32* %6)
%37 = icmp eq i64 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %32
%39 = load i8*, i8** %4
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* null, i32 4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %39, i32 %40, i32 %41)
br label %43
43: ; preds = %38, %32
%44 = load i8*, i8** %4
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %43, %30
%47 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%48 = call i32 @connect(i32 %23, %struct.sockaddr* %47, i32 8)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @err(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
%53 = icmp sgt i32 %0, 1
%54 = icmp sgt i32 %9, 0
%55 = select i1 %53, i1 %54, i1 false
br i1 %55, label %60, label %56
56: ; preds = %60, %52
%57 = phi i32 [ 0, %52 ], [ %72, %60 ]
%58 = call i32 @send(i32 %23, i8* %12, i32 %57, i32 0)
%59 = icmp eq i32 %58, -1
br i1 %59, label %78, label %80
60: ; preds = %52, %60
%61 = phi i8** [ %66, %60 ], [ %1, %52 ]
%62 = phi i32 [ %74, %60 ], [ %9, %52 ]
%63 = phi i32 [ %73, %60 ], [ 0, %52 ]
%64 = phi i32 [ %72, %60 ], [ 0, %52 ]
%65 = phi i32 [ %67, %60 ], [ %0, %52 ]
%66 = getelementptr inbounds i8*, i8** %61, i64 1
%67 = add nsw i32 %65, -1
%68 = sext i32 %63 to i64
%69 = getelementptr inbounds i8, i8* %12, i64 %68
%70 = load i8*, i8** %66
%71 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %69, i32 %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %70, i32 0)
%72 = add nsw i32 %71, %64
%73 = add nsw i32 %71, %63
%74 = sub nsw i32 %62, %71
%75 = icmp ugt i32 %65, 2
%76 = icmp sgt i32 %74, 0
%77 = select i1 %75, i1 %76, i1 false
br i1 %77, label %60, label %56
78: ; preds = %56
%79 = call i32 @err(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
br label %80
80: ; preds = %78, %56
%81 = load i32, i32* @EXIT_SUCCESS
%82 = bitcast [2 x %struct.pollfd]* %7 to i8*
%83 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0
%84 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0, i32 0
store i32 %23, i32* %84
%85 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0, i32 1
%86 = load i32, i32* @POLLIN
store i32 %86, i32* %85
%87 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0, i32 2
store i32 0, i32* %87
%88 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 0, i32 3
store i32 0, i32* %88
%89 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 0
%90 = load i32, i32* @STDOUT_FILENO
store i32 %90, i32* %89
%91 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 1
%92 = load i32, i32* @POLLHUP
store i32 %92, i32* %91
%93 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 2
store i32 0, i32* %93
%94 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %7, i64 0, i64 1, i32 3
store i32 0, i32* %94
%95 = add i32 %13, -1
%96 = call i64 @poll(%struct.pollfd* %83, i32 2, i32 -1)
%97 = icmp sgt i64 %96, 0
br i1 %97, label %98, label %130
98: ; preds = %80, %126
%99 = phi i32 [ %127, %126 ], [ %81, %80 ]
%100 = load i32, i32* %93
%101 = load i32, i32* @POLLERR
%102 = load i32, i32* @POLLHUP
%103 = or i32 %102, %101
%104 = and i32 %103, %100
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %130
106: ; preds = %98
%107 = load i32, i32* %87
%108 = load i32, i32* @POLLIN
%109 = and i32 %108, %107
%110 = icmp eq i32 %109, 0
br i1 %110, label %126, label %111
111: ; preds = %106
%112 = call i32 @recv(i32 %23, i8* %15, i32 %95, i32 0)
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %130
114: ; preds = %111
%115 = zext i32 %112 to i64
%116 = getelementptr inbounds i8, i8* %15, i64 %115
store i8 0, i8* %116
%117 = load i8, i8* %15
%118 = icmp eq i8 %117, 7
%119 = load i32, i32* @EXIT_FAILURE
%120 = zext i1 %118 to i64
%121 = getelementptr i8, i8* %15, i64 %120
%122 = select i1 %118, i32 %119, i32 %99
%123 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %121)
%124 = load i32, i32* @stdout
%125 = call i32 @fflush(i32 %124)
br label %126
126: ; preds = %114, %106
%127 = phi i32 [ %122, %114 ], [ %99, %106 ]
%128 = call i64 @poll(%struct.pollfd* %83, i32 2, i32 -1)
%129 = icmp sgt i64 %128, 0
br i1 %129, label %98, label %130
130: ; preds = %126, %98, %111, %80
%131 = phi i32 [ %81, %80 ], [ %99, %111 ], [ %99, %98 ], [ %127, %126 ]
%132 = call i32 @close(i32 %23)
ret i32 %131
}