#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;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int BUFSIZ;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ SOCK_STREAM;
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct sockaddr_un *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int read(int /*<<< orphan*/, char *, int);
int recv(int, char *, int, int /*<<< orphan*/);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int strlen(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int write(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    usage();
    return 1;
  } else if (strcmp(argv[1], "--help") == 0) {
    usage();
    return 0;
  }
  int sockfd;
  struct sockaddr_un serverAddress;
  do {
  } while (0);
  ;
  if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
    do {
      perror("qtwine-terminal-helper: "
             "socket() failed");
      sleep(3);
      exit(EXIT_FAILURE);
    } while (0);
  memset(&serverAddress, 0, sizeof(struct sockaddr_un));
  serverAddress.sun_family = AF_UNIX;
  strcpy(serverAddress.sun_path, argv[1]);
  int len = strlen(serverAddress.sun_path) + sizeof(serverAddress.sun_family);
  if (connect(sockfd, (struct sockaddr *)&serverAddress, len) == -1)
    do {
      perror("qtwine-terminal-helper: "
             "connect() failed");
      sleep(3);
      exit(EXIT_FAILURE);
    } while (0);
  do {
  } while (0);
  ;
  fd_set rfds;
  int retval;
  ssize_t bytesRead;
  char buffer[BUFSIZ];
  do {
  } while (0);
  ;
  while (1) {
    FD_ZERO(&rfds);
    FD_SET(sockfd, &rfds);
    FD_SET(0, &rfds);
    retval = select(sockfd + 1, &rfds, NULL, NULL, NULL);
    if (retval == -1)
      do {
        perror("qtwine-terminal-helper: "
               "select() failed");
        sleep(3);
        exit(EXIT_FAILURE);
      } while (0);
    else if (retval > 0) {
      if (FD_ISSET(sockfd, &rfds)) {
        do {
        } while (0);
        ;
        bytesRead = recv(sockfd, buffer, BUFSIZ, 0);
        if (bytesRead > 0 && write(1, buffer, bytesRead) == -1)
          do {
            perror("qtwine-terminal-helper: "
                   "write()");
            sleep(3);
            exit(EXIT_FAILURE);
          } while (0);
        else if (bytesRead == -1)
          do {
            perror("qtwine-terminal-helper: "
                   "recv()");
            sleep(3);
            exit(EXIT_FAILURE);
          } while (0);
      }
      if (FD_ISSET(0, &rfds)) {
        do {
        } while (0);
        ;
        bytesRead = read(0, buffer, BUFSIZ);
        if (bytesRead > 0 && send(sockfd, buffer, bytesRead, 0) == -1)
          do {
            perror("qtwine-terminal-helper: "
                   "send()");
            sleep(3);
            exit(EXIT_FAILURE);
          } while (0);
        else if (bytesRead == -1)
          do {
            perror("qtwine-terminal-helper: "
                   "read()");
            sleep(3);
            exit(EXIT_FAILURE);
          } while (0);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1253 <main+0x33>
mov    $0x0,%al
call   10e0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    15c0 <main+0x3a0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9e(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1284 <main+0x64>
mov    $0x0,%al
call   10e0 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    15c0 <main+0x3a0>
jmp    1289 <main+0x69>
jmp    128e <main+0x6e>
jmp    1293 <main+0x73>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
mov    0x2d35(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12e1 <main+0xc1>
jmp    12bd <main+0x9d>
lea    0xd43(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1090 <memset@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%edi
call   1070 <strlen@plt>
cltq
add    $0x4,%rax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    135f <main+0x13f>
jmp    133b <main+0x11b>
lea    0xced(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1364 <main+0x144>
jmp    1369 <main+0x149>
mov    0x2c60(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
jmp    139a <main+0x17a>
jmp    139f <main+0x17f>
jmp    13a4 <main+0x184>
jmp    13a9 <main+0x189>
lea    -0x28(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1120 <FD_SET@plt>
xor    %edi,%edi
lea    -0x28(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <select@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1419 <main+0x1f9>
jmp    13f5 <main+0x1d5>
lea    0xc5c(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    15b6 <main+0x396>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14ec <main+0x2cc>
jmp    143e <main+0x21e>
jmp    1443 <main+0x223>
jmp    1448 <main+0x228>
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    0x2b7a(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    14af <main+0x28f>
mov    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    $0x1,%edi
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    14af <main+0x28f>
jmp    148b <main+0x26b>
lea    0xbee(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
cmpl   $0xffffffff,-0x30(%rbp)
jne    14e2 <main+0x2c2>
jmp    14be <main+0x29e>
lea    0xbdb(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2aed(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    14e7 <main+0x2c7>
jmp    14ec <main+0x2cc>
xor    %edi,%edi
lea    -0x28(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15b1 <main+0x391>
jmp    1506 <main+0x2e6>
jmp    150b <main+0x2eb>
jmp    1510 <main+0x2f0>
mov    -0x48(%rbp),%rsi
mov    0x2ab5(%rip),%rax
mov    (%rax),%edx
xor    %edi,%edi
call   10a0 <read@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    1574 <main+0x354>
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    1574 <main+0x354>
jmp    1550 <main+0x330>
lea    0xb68(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2a5b(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
cmpl   $0xffffffff,-0x30(%rbp)
jne    15a7 <main+0x387>
jmp    1583 <main+0x363>
lea    0xb54(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2a28(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    15ac <main+0x38c>
jmp    15b1 <main+0x391>
jmp    15b6 <main+0x396>
jmp    15bb <main+0x39b>
jmp    13a4 <main+0x184>
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    $0x18,%rsp
mov    $0x1,%ebx
cmp    $0x2,%edi
jl     1255 <main+0x35>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xdb7(%rip),%rsi
call   10b0 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    126d <main+0x4d>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d74(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
cmp    $0xffffffff,%eax
jne    1297 <main+0x77>
lea    0xd75(%rip),%rdi
jmp    1344 <main+0x124>
mov    %eax,%r12d
lea    -0x30(%rbp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1090 <memset@plt>
mov    (%rbx),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    0x8(%r14),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%edi
call   1070 <strlen@plt>
lea    0x4(%rax),%edx
mov    %r12d,%edi
mov    %r15,%rsi
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    12e2 <main+0xc2>
lea    0xd4f(%rip),%rdi
jmp    1344 <main+0x124>
mov    0x2ce7(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r12d,%r15d
add    $0x1,%r15d
lea    -0x34(%rbp),%rbx
mov    %rbx,%rdi
call   10c0 <FD_ZERO@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1120 <FD_SET@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1120 <FD_SET@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
jne    1361 <main+0x141>
lea    0xd14(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    -0x34(%rbp),%rbx
jmp    13a4 <main+0x184>
cmp    $0xffffffff,%eax
je     144d <main+0x22d>
mov    %rbx,%rdi
call   10c0 <FD_ZERO@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1120 <FD_SET@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1120 <FD_SET@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
je     133d <main+0x11d>
test   %eax,%eax
jle    1370 <main+0x150>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     13e8 <main+0x1c8>
mov    0x0(%r13),%edx
mov    %r12d,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    13e3 <main+0x1c3>
mov    $0x1,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    13e8 <main+0x1c8>
jmp    1435 <main+0x215>
cmp    $0xffffffff,%eax
je     1441 <main+0x221>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1370 <main+0x150>
mov    0x0(%r13),%edx
xor    %edi,%edi
mov    %r14,%rsi
call   10a0 <read@plt>
test   %eax,%eax
jle    1367 <main+0x147>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    1370 <main+0x150>
lea    0xc8f(%rip),%rdi
jmp    1344 <main+0x124>
lea    0xc44(%rip),%rdi
jmp    1344 <main+0x124>
lea    0xc58(%rip),%rdi
jmp    1344 <main+0x124>
lea    0xc8a(%rip),%rdi
jmp    1344 <main+0x124>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"--help\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [40 x i8] c"qtwine-terminal-helper: socket() failed\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [41 x i8] c"qtwine-terminal-helper: connect() failed\00"
@BUFSIZ = global i32 0
@.str.3 = [40 x i8] c"qtwine-terminal-helper: select() failed\00"
@.str.4 = [32 x i8] c"qtwine-terminal-helper: write()\00"
@.str.5 = [31 x i8] c"qtwine-terminal-helper: recv()\00"
@.str.6 = [31 x i8] c"qtwine-terminal-helper: send()\00"
@.str.7 = [31 x i8] c"qtwine-terminal-helper: read()\00"
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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (...) @usage()
store i32 1, i32* %3
br label %179
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 (...) @usage()
store i32 0, i32* %3
br label %179
26: ; preds = %18
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
%30 = load i32, i32* @AF_UNIX
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i32 %30, i32 %31, i32 0)
store i32 %32, i32* %6
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %41
34: ; preds = %29
br label %35
35: ; preds = %34
%36 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @sleep(i32 3)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; No predecessors!
br label %41
41: ; preds = %40, %29
%42 = call i32 @memset(%struct.sockaddr_un* %7, i32 0, i32 8)
%43 = load i32, i32* @AF_UNIX
%44 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 1
store i32 %43, i32* %44
%45 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%46 = load i32, i32* %45
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @strcpy(i32 %46, i8* %49)
%51 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%52 = load i32, i32* %51
%53 = call i32 @strlen(i32 %52)
%54 = sext i32 %53 to i64
%55 = add i64 %54, 4
%56 = trunc i64 %55 to i32
store i32 %56, i32* %8
%57 = load i32, i32* %6
%58 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%59 = load i32, i32* %8
%60 = call i32 @connect(i32 %57, %struct.sockaddr* %58, i32 %59)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %69
62: ; preds = %41
br label %63
63: ; preds = %62
%64 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%65 = call i32 @sleep(i32 3)
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; No predecessors!
br label %69
69: ; preds = %68, %41
br label %70
70: ; preds = %69
br label %71
71: ; preds = %70
%72 = load i32, i32* @BUFSIZ
%73 = zext i32 %72 to i64
%74 = call i8* @llvm.stacksave()
store i8* %74, i8** %12
%75 = alloca i8, i64 %73
store i64 %73, i64* %13
br label %76
76: ; preds = %71
br label %77
77: ; preds = %76
br label %78
78: ; preds = %77
br label %79
79: ; preds = %178, %78
br label %80
80: ; preds = %79
%81 = call i32 @FD_ZERO(i32* %9)
%82 = load i32, i32* %6
%83 = call i32 @FD_SET(i32 %82, i32* %9)
%84 = call i32 @FD_SET(i32 0, i32* %9)
%85 = load i32, i32* %6
%86 = add nsw i32 %85, 1
%87 = call i32 @select(i32 %86, i32* %9, i32* null, i32* null, i32* null)
store i32 %87, i32* %10
%88 = load i32, i32* %10
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %98
90: ; preds = %80
br label %91
91: ; preds = %90
%92 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%93 = call i32 @sleep(i32 3)
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 @exit(i32 %94)
unreachable
96: ; No predecessors!
br label %97
97: ; preds = %96
br label %178
98: ; preds = %80
%99 = load i32, i32* %10
%100 = icmp sgt i32 %99, 0
br i1 %100, label %101, label %177
101: ; preds = %98
%102 = load i32, i32* %6
%103 = call i64 @FD_ISSET(i32 %102, i32* %9)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %139
105: ; preds = %101
br label %106
106: ; preds = %105
br label %107
107: ; preds = %106
br label %108
108: ; preds = %107
%109 = load i32, i32* %6
%110 = load i32, i32* @BUFSIZ
%111 = call i32 @recv(i32 %109, i8* %75, i32 %110, i32 0)
store i32 %111, i32* %11
%112 = load i32, i32* %11
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %126
114: ; preds = %108
%115 = load i32, i32* %11
%116 = call i32 @write(i32 1, i8* %75, i32 %115)
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %126
118: ; preds = %114
br label %119
119: ; preds = %118
%120 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%121 = call i32 @sleep(i32 3)
%122 = load i32, i32* @EXIT_FAILURE
%123 = call i32 @exit(i32 %122)
unreachable
124: ; No predecessors!
br label %125
125: ; preds = %124
br label %138
126: ; preds = %114, %108
%127 = load i32, i32* %11
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %137
129: ; preds = %126
br label %130
130: ; preds = %129
%131 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%132 = call i32 @sleep(i32 3)
%133 = load i32, i32* @EXIT_FAILURE
%134 = call i32 @exit(i32 %133)
unreachable
135: ; No predecessors!
br label %136
136: ; preds = %135
br label %137
137: ; preds = %136, %126
br label %138
138: ; preds = %137, %125
br label %139
139: ; preds = %138, %101
%140 = call i64 @FD_ISSET(i32 0, i32* %9)
%141 = icmp ne i64 %140, 0
br i1 %141, label %142, label %176
142: ; preds = %139
br label %143
143: ; preds = %142
br label %144
144: ; preds = %143
br label %145
145: ; preds = %144
%146 = load i32, i32* @BUFSIZ
%147 = call i32 @read(i32 0, i8* %75, i32 %146)
store i32 %147, i32* %11
%148 = load i32, i32* %11
%149 = icmp sgt i32 %148, 0
br i1 %149, label %150, label %163
150: ; preds = %145
%151 = load i32, i32* %6
%152 = load i32, i32* %11
%153 = call i32 @send(i32 %151, i8* %75, i32 %152, i32 0)
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %163
155: ; preds = %150
br label %156
156: ; preds = %155
%157 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%158 = call i32 @sleep(i32 3)
%159 = load i32, i32* @EXIT_FAILURE
%160 = call i32 @exit(i32 %159)
unreachable
161: ; No predecessors!
br label %162
162: ; preds = %161
br label %175
163: ; preds = %150, %145
%164 = load i32, i32* %11
%165 = icmp eq i32 %164, -1
br i1 %165, label %166, label %174
166: ; preds = %163
br label %167
167: ; preds = %166
%168 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%169 = call i32 @sleep(i32 3)
%170 = load i32, i32* @EXIT_FAILURE
%171 = call i32 @exit(i32 %170)
unreachable
172: ; No predecessors!
br label %173
173: ; preds = %172
br label %174
174: ; preds = %173, %163
br label %175
175: ; preds = %174, %162
br label %176
176: ; preds = %175, %139
br label %177
177: ; preds = %176, %98
br label %178
178: ; preds = %177, %97
br label %79
179: ; preds = %24, %16
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"--help\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [40 x i8] c"qtwine-terminal-helper: socket() failed\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [41 x i8] c"qtwine-terminal-helper: connect() failed\00"
@BUFSIZ = global i32 0
@.str.3 = [40 x i8] c"qtwine-terminal-helper: select() failed\00"
@.str.4 = [32 x i8] c"qtwine-terminal-helper: write()\00"
@.str.5 = [31 x i8] c"qtwine-terminal-helper: recv()\00"
@.str.6 = [31 x i8] c"qtwine-terminal-helper: send()\00"
@.str.7 = [31 x i8] c"qtwine-terminal-helper: read()\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = icmp slt i32 %0, 2
br i1 %5, label %110, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %110, label %11
11: ; preds = %6
%12 = bitcast %struct.sockaddr_un* %3 to i8*
%13 = load i32, i32* @AF_UNIX
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = tail call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @sleep(i32 3)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %11
%23 = call i32 @memset(%struct.sockaddr_un* %3, i32 0, i32 8)
%24 = load i32, i32* @AF_UNIX
%25 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %24, i32* %25
%26 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 0
%27 = load i32, i32* %26
%28 = load i8*, i8** %7
%29 = call i32 @strcpy(i32 %27, i8* %28)
%30 = load i32, i32* %26
%31 = call i32 @strlen(i32 %30)
%32 = add i32 %31, 4
%33 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%34 = call i32 @connect(i32 %15, %struct.sockaddr* %33, i32 %32)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %41
36: ; preds = %22
%37 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @sleep(i32 3)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %22
%42 = bitcast i32* %4 to i8*
%43 = load i32, i32* @BUFSIZ
%44 = zext i32 %43 to i64
%45 = alloca i8, i64 %44
%46 = add nuw nsw i32 %15, 1
%47 = call i32 @FD_ZERO(i32* %4)
%48 = call i32 @FD_SET(i32 %15, i32* %4)
%49 = call i32 @FD_SET(i32 0, i32* %4)
%50 = call i32 @select(i32 %46, i32* %4, i32* null, i32* null, i32* null)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %57
52: ; preds = %104, %41
%53 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @sleep(i32 3)
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %41, %104
%58 = phi i32 [ %108, %104 ], [ %50, %41 ]
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %104
60: ; preds = %57
%61 = call i64 @FD_ISSET(i32 %15, i32* %4)
%62 = icmp eq i64 %61, 0
br i1 %62, label %82, label %63
63: ; preds = %60
%64 = load i32, i32* @BUFSIZ
%65 = call i32 @recv(i32 %15, i8* %45, i32 %64, i32 0)
%66 = icmp sgt i32 %65, 0
br i1 %66, label %67, label %75
67: ; preds = %63
%68 = call i32 @write(i32 1, i8* %45, i32 %65)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %82
70: ; preds = %67
%71 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%72 = call i32 @sleep(i32 3)
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %63
%76 = icmp eq i32 %65, -1
br i1 %76, label %77, label %82
77: ; preds = %75
%78 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%79 = call i32 @sleep(i32 3)
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %67, %75, %60
%83 = call i64 @FD_ISSET(i32 0, i32* %4)
%84 = icmp eq i64 %83, 0
br i1 %84, label %104, label %85
85: ; preds = %82
%86 = load i32, i32* @BUFSIZ
%87 = call i32 @read(i32 0, i8* %45, i32 %86)
%88 = icmp sgt i32 %87, 0
br i1 %88, label %89, label %97
89: ; preds = %85
%90 = call i32 @send(i32 %15, i8* %45, i32 %87, i32 0)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %104
92: ; preds = %89
%93 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%94 = call i32 @sleep(i32 3)
%95 = load i32, i32* @EXIT_FAILURE
%96 = call i32 @exit(i32 %95)
unreachable
97: ; preds = %85
%98 = icmp eq i32 %87, -1
br i1 %98, label %99, label %104
99: ; preds = %97
%100 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @sleep(i32 3)
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %89, %57, %97, %82
%105 = call i32 @FD_ZERO(i32* %4)
%106 = call i32 @FD_SET(i32 %15, i32* %4)
%107 = call i32 @FD_SET(i32 0, i32* %4)
%108 = call i32 @select(i32 %46, i32* %4, i32* null, i32* null, i32* null)
%109 = icmp eq i32 %108, -1
br i1 %109, label %52, label %57
110: ; preds = %6, %2
%111 = phi i32 [ 1, %2 ], [ 0, %6 ]
%112 = tail call i32 (...) @usage()
ret i32 %111
}