#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;
  int /*<<< orphan*/ member_0;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ env;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int PATH_MAX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
scalar_t__ find_socket_path(int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getcwd(char *, int);
scalar_t__ handle_play(char *);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
char *read_response(int);
scalar_t__ send_args(int, int, char **);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int fd = socket(AF_UNIX, SOCK_STREAM, 0);
  if (fd < 0) {
    fprintf(stderr,
            "line %d: "
            "failed to create socket"
            "\n",
            232);
    return -1;
  }
  struct sockaddr_un addr = {0};
  addr.sun_family = AF_UNIX;
  if (find_socket_path(addr.sun_path, sizeof(addr.sun_path))) {
    close(fd);
    return -1;
  }
  if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) {
    fprintf(stderr,
            "line %d: "
            "failed to connect: %s"
            "\n",
            244, strerror(errno));
    close(fd);
    return -1;
  }
  bool is_play = argc >= 2 && strcmp(argv[1], "play") == 0;
  char cwd[PATH_MAX];
  if (!getcwd(cwd, PATH_MAX)) {
    fprintf(stderr,
            "line %d: "
            "failed to get cwd: %s"
            "\n",
            255, strerror(errno));
    return -1;
  }
  char *env[2] = {"CWD", cwd};
  if (send_args(fd, sizeof(env) / sizeof(char *), env)) {
    close(fd);
    return -1;
  }
  if (send_args(fd, argc - 1, &argv[1])) {
    close(fd);
    return -1;
  }
  char result;
  if (read(fd, &result, 1) != 1) {
    fprintf(stderr,
            "line %d: "
            "failed to read process result"
            "\n",
            272);
    close(fd);
    return -1;
  }
  char *out = read_response(fd);
  if (!out) {
    fprintf(stderr,
            "line %d: "
            "failed to read stdout"
            "\n",
            279);
    close(fd);
    return -1;
  }
  if (!is_play || result) {
    printf(out);
    free(out);
  }
  char *err = read_response(fd);
  if (!err) {
    fprintf(stderr,
            "line %d: "
            "failed to read stderr"
            "\n",
            290);
    close(fd);
    return -1;
  }
  fprintf(stderr, err);
  free(err);
  close(fd);
  if (is_play && !result) {
    if (handle_play(out)) {
      free(out);
      return -1;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1257 <main+0x67>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    $0xe8,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15de <main+0x3ee>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x4,%esi
call   10b0 <find_socket_path@plt>
cmp    $0x0,%rax
je     129e <main+0xae>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15de <main+0x3ee>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <connect@plt>
cmp    $0x0,%rax
je     1300 <main+0x110>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rcx
lea    0xd42(%rip),%rsi
mov    $0xf4,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15de <main+0x3ee>
xor    %eax,%eax
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x6d(%rbp)
jl     132d <main+0x13d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd24(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x6d(%rbp)
mov    -0x6d(%rbp),%al
movzbl %al,%eax
and    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    0x2cb0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x78(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
call   1080 <getcwd@plt>
cmp    $0x0,%eax
jne    13c2 <main+0x1d2>
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%rcx
lea    0xca4(%rip),%rsi
mov    $0xff,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
mov    -0x78(%rbp),%rax
lea    0xc9a(%rip),%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x50(%rbp),%rdx
mov    $0x2,%esi
call   1050 <send_args@plt>
cmp    $0x0,%rax
je     140b <main+0x21b>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1050 <send_args@plt>
cmp    $0x0,%rax
je     1446 <main+0x256>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
mov    -0x14(%rbp),%edi
lea    -0x51(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x1,%eax
je     1497 <main+0x2a7>
mov    0x2b69(%rip),%rax
mov    (%rax),%edi
lea    0xbfb(%rip),%rsi
mov    $0x110,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
mov    -0x14(%rbp),%edi
call   1100 <read_response@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    14e5 <main+0x2f5>
mov    0x2b1b(%rip),%rax
mov    (%rax),%edi
lea    0xbd5(%rip),%rsi
mov    $0x117,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
cmpl   $0x0,-0x24(%rbp)
je     14fc <main+0x30c>
movsbl -0x51(%rbp),%eax
cmp    $0x0,%eax
je     150e <main+0x31e>
mov    -0x60(%rbp),%rdi
call   1060 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1100 <read_response@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    155c <main+0x36c>
mov    0x2aa4(%rip),%rax
mov    (%rax),%edi
lea    0xb7e(%rip),%rsi
mov    $0x122,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
mov    0x2a6d(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0x24(%rbp)
je     15c9 <main+0x3d9>
cmpb   $0x0,-0x51(%rbp)
jne    15c9 <main+0x3d9>
mov    -0x60(%rbp),%rdi
call   1040 <handle_play@plt>
cmp    $0x0,%rax
je     15c4 <main+0x3d4>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    15d7 <main+0x3e7>
jmp    15c9 <main+0x3d9>
movsbl -0x51(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x30(%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    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x2de2(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
js     128b <main+0xab>
mov    %eax,%r12d
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x40(%rbp)
mov    (%rbx),%eax
mov    %eax,-0x44(%rbp)
xor    %edi,%edi
mov    $0x4,%esi
call   10a0 <find_socket_path@plt>
test   %rax,%rax
jne    1281 <main+0xa1>
lea    -0x48(%rbp),%rsi
mov    %r12d,%edi
mov    $0xc,%edx
call   10d0 <connect@plt>
test   %rax,%rax
je     12bd <main+0xdd>
mov    0x2d77(%rip),%rax
mov    (%rax),%ebx
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xdb2(%rip),%rsi
mov    %ebx,%edi
mov    $0xf4,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r12d,%edi
call   1080 <close@plt>
jmp    12a7 <main+0xc7>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
mov    $0xe8,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
cmp    $0x2,%r15d
jl     12e0 <main+0x100>
mov    0x8(%r14),%rdi
lea    0xd71(%rip),%rsi
call   10b0 <strcmp@plt>
xor    %r13d,%r13d
test   %rax,%rax
sete   %r13b
mov    %rsp,-0x38(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <getcwd@plt>
test   %eax,%eax
je     140a <main+0x22a>
lea    0xd50(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    %rbx,-0x58(%rbp)
lea    -0x60(%rbp),%rdx
mov    %r12d,%edi
mov    $0x2,%esi
call   1050 <send_args@plt>
test   %rax,%rax
jne    147c <main+0x29c>
add    $0xffffffff,%r15d
add    $0x8,%r14
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r14,%rdx
call   1050 <send_args@plt>
test   %rax,%rax
jne    147c <main+0x29c>
lea    -0x29(%rbp),%rsi
mov    %r12d,%edi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
jne    143b <main+0x25b>
mov    %r12d,%edi
call   10f0 <read_response@plt>
test   %rax,%rax
je     1452 <main+0x272>
mov    %rax,%r14
test   %r13d,%r13d
sete   %al
movsbl -0x29(%rbp),%ebx
test   %ebx,%ebx
setne  %r13b
or     %al,%r13b
cmp    $0x1,%r13b
jne    13af <main+0x1cf>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r12d,%edi
call   10f0 <read_response@plt>
mov    %rax,%r15
mov    0x2c0f(%rip),%rax
mov    (%rax),%edi
test   %r15,%r15
je     1469 <main+0x289>
mov    %r15,%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12d,%edi
call   1080 <close@plt>
test   %r13b,%r13b
jne    1489 <main+0x2a9>
mov    %r14,%rdi
call   1040 <handle_play@plt>
test   %rax,%rax
je     1489 <main+0x2a9>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1484 <main+0x2a4>
mov    0x2bbf(%rip),%rax
mov    (%rax),%ebx
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc1f(%rip),%rsi
mov    %ebx,%edi
mov    $0xff,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1484 <main+0x2a4>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
lea    0xc20(%rip),%rsi
mov    $0x110,%edx
jmp    1475 <main+0x295>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
lea    0xc31(%rip),%rsi
mov    $0x117,%edx
jmp    1475 <main+0x295>
lea    0xc43(%rip),%rsi
mov    $0x122,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r12d,%edi
call   1080 <close@plt>
mov    $0xffffffff,%ebx
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
jmp    12ac <main+0xcc>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"line %d: failed to create socket\0A\00"
@.str.1 = [32 x i8] c"line %d: failed to connect: %s\0A\00"
@errno = global i32 0
@.str.2 = [5 x i8] c"play\00"
@PATH_MAX = global i32 0
@.str.3 = [32 x i8] c"line %d: failed to get cwd: %s\0A\00"
@.str.4 = [4 x i8] c"CWD\00"
@.str.5 = [40 x i8] c"line %d: failed to read process result\0A\00"
@.str.6 = [32 x i8] c"line %d: failed to read stdout\0A\00"
@.str.7 = [32 x i8] c"line %d: failed to read stderr\0A\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 i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca [2 x i8*]
%13 = alloca i8
%14 = alloca i8*
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @AF_UNIX
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 232)
store i32 -1, i32* %3
br label %159
24: ; preds = %2
%25 = bitcast %struct.sockaddr_un* %7 to i8*
%26 = load i32, i32* @AF_UNIX
%27 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 1
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i64 @find_socket_path(i32 %29, i32 4)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = load i32, i32* %6
%34 = call i32 @close(i32 %33)
store i32 -1, i32* %3
br label %159
35: ; preds = %24
%36 = load i32, i32* %6
%37 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%38 = call i64 @connect(i32 %36, %struct.sockaddr* %37, i32 12)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = load i32, i32* @errno
%43 = call i8* @strerror(i32 %42)
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 244, i8* %43)
%45 = load i32, i32* %6
%46 = call i32 @close(i32 %45)
store i32 -1, i32* %3
br label %159
47: ; preds = %35
%48 = load i32, i32* %4
%49 = icmp sge i32 %48, 2
br i1 %49, label %50, label %56
50: ; preds = %47
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br label %56
56: ; preds = %50, %47
%57 = phi i1 [ false, %47 ], [ %55, %50 ]
%58 = zext i1 %57 to i32
store i32 %58, i32* %8
%59 = load i32, i32* @PATH_MAX
%60 = zext i32 %59 to i64
%61 = call i8* @llvm.stacksave()
store i8* %61, i8** %9
%62 = alloca i8, i64 %60
store i64 %60, i64* %10
%63 = load i32, i32* @PATH_MAX
%64 = call i32 @getcwd(i8* %62, i32 %63)
%65 = icmp ne i32 %64, 0
br i1 %65, label %71, label %66
66: ; preds = %56
%67 = load i32, i32* @stderr
%68 = load i32, i32* @errno
%69 = call i8* @strerror(i32 %68)
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 255, i8* %69)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
71: ; preds = %56
%72 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %72
%73 = getelementptr inbounds i8*, i8** %72, i64 1
store i8* %62, i8** %73
%74 = load i32, i32* %6
%75 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%76 = call i64 @send_args(i32 %74, i32 2, i8** %75)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %71
%79 = load i32, i32* %6
%80 = call i32 @close(i32 %79)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
81: ; preds = %71
%82 = load i32, i32* %6
%83 = load i32, i32* %4
%84 = sub nsw i32 %83, 1
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = call i64 @send_args(i32 %82, i32 %84, i8** %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %81
%90 = load i32, i32* %6
%91 = call i32 @close(i32 %90)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
92: ; preds = %81
%93 = load i32, i32* %6
%94 = call i32 @read(i32 %93, i8* %13, i32 1)
%95 = icmp ne i32 %94, 1
br i1 %95, label %96, label %101
96: ; preds = %92
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 272)
%99 = load i32, i32* %6
%100 = call i32 @close(i32 %99)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
101: ; preds = %92
%102 = load i32, i32* %6
%103 = call i8* @read_response(i32 %102)
store i8* %103, i8** %14
%104 = load i8*, i8** %14
%105 = icmp ne i8* %104, null
br i1 %105, label %111, label %106
106: ; preds = %101
%107 = load i32, i32* @stderr
%108 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 279)
%109 = load i32, i32* %6
%110 = call i32 @close(i32 %109)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
111: ; preds = %101
%112 = load i32, i32* %8
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %111
%115 = load i8, i8* %13
%116 = sext i8 %115 to i32
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %123
118: ; preds = %114, %111
%119 = load i8*, i8** %14
%120 = call i32 @printf(i8* %119)
%121 = load i8*, i8** %14
%122 = call i32 @free(i8* %121)
br label %123
123: ; preds = %118, %114
%124 = load i32, i32* %6
%125 = call i8* @read_response(i32 %124)
store i8* %125, i8** %15
%126 = load i8*, i8** %15
%127 = icmp ne i8* %126, null
br i1 %127, label %133, label %128
128: ; preds = %123
%129 = load i32, i32* @stderr
%130 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 290)
%131 = load i32, i32* %6
%132 = call i32 @close(i32 %131)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
133: ; preds = %123
%134 = load i32, i32* @stderr
%135 = load i8*, i8** %15
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* %135)
%137 = load i8*, i8** %15
%138 = call i32 @free(i8* %137)
%139 = load i32, i32* %6
%140 = call i32 @close(i32 %139)
%141 = load i32, i32* %8
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %154
143: ; preds = %133
%144 = load i8, i8* %13
%145 = icmp ne i8 %144, 0
br i1 %145, label %154, label %146
146: ; preds = %143
%147 = load i8*, i8** %14
%148 = call i64 @handle_play(i8* %147)
%149 = icmp ne i64 %148, 0
br i1 %149, label %150, label %153
150: ; preds = %146
%151 = load i8*, i8** %14
%152 = call i32 @free(i8* %151)
store i32 -1, i32* %3
store i32 1, i32* %11
br label %157
153: ; preds = %146
br label %154
154: ; preds = %153, %143, %133
%155 = load i8, i8* %13
%156 = sext i8 %155 to i32
store i32 %156, i32* %3
store i32 1, i32* %11
br label %157
157: ; preds = %154, %150, %128, %106, %96, %89, %78, %66
%158 = load i8*, i8** %9
br label %159
159: ; preds = %157, %40, %32, %21
%160 = load i32, i32* %3
ret i32 %160
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"line %d: failed to create socket\0A\00"
@.str.1 = [32 x i8] c"line %d: failed to connect: %s\0A\00"
@errno = global i32 0
@.str.2 = [5 x i8] c"play\00"
@PATH_MAX = global i32 0
@.str.3 = [32 x i8] c"line %d: failed to get cwd: %s\0A\00"
@.str.4 = [4 x i8] c"CWD\00"
@.str.5 = [40 x i8] c"line %d: failed to read process result\0A\00"
@.str.6 = [32 x i8] c"line %d: failed to read stdout\0A\00"
@.str.7 = [32 x i8] c"line %d: failed to read stderr\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca [2 x i8*]
%5 = alloca i8
%6 = load i32, i32* @AF_UNIX
%7 = load i32, i32* @SOCK_STREAM
%8 = tail call i32 @socket(i32 %6, i32 %7, i32 0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 232)
br label %116
13: ; preds = %2
%14 = bitcast %struct.sockaddr_un* %3 to i8*
%15 = load i32, i32* @AF_UNIX
%16 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %15, i32* %16
%17 = tail call i64 @find_socket_path(i32 0, i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = tail call i32 @close(i32 %8)
br label %114
21: ; preds = %13
%22 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%23 = call i64 @connect(i32 %8, %struct.sockaddr* %22, i32 12)
%24 = icmp eq i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 244, i8* %28)
%30 = call i32 @close(i32 %8)
br label %114
31: ; preds = %21
%32 = icmp sgt i32 %0, 1
br i1 %32, label %33, label %39
33: ; preds = %31
%34 = getelementptr inbounds i8*, i8** %1, i64 1
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
%38 = zext i1 %37 to i32
br label %39
39: ; preds = %33, %31
%40 = phi i32 [ 0, %31 ], [ %38, %33 ]
%41 = load i32, i32* @PATH_MAX
%42 = zext i32 %41 to i64
%43 = call i8* @llvm.stacksave()
%44 = alloca i8, i64 %42
%45 = load i32, i32* @PATH_MAX
%46 = call i32 @getcwd(i8* %44, i32 %45)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %39
%49 = load i32, i32* @stderr
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 255, i8* %51)
br label %112
53: ; preds = %39
%54 = bitcast [2 x i8*]* %4 to i8*
%55 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %55
%56 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
store i8* %44, i8** %56
%57 = call i64 @send_args(i32 %8, i32 2, i8** %55)
%58 = icmp eq i64 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %53
%60 = call i32 @close(i32 %8)
br label %110
61: ; preds = %53
%62 = add nsw i32 %0, -1
%63 = getelementptr inbounds i8*, i8** %1, i64 1
%64 = call i64 @send_args(i32 %8, i32 %62, i8** %63)
%65 = icmp eq i64 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %61
%67 = call i32 @close(i32 %8)
br label %110
68: ; preds = %61
%69 = call i32 @read(i32 %8, i8* %5, i32 1)
%70 = icmp eq i32 %69, 1
br i1 %70, label %75, label %71
71: ; preds = %68
%72 = load i32, i32* @stderr
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 272)
%74 = call i32 @close(i32 %8)
br label %108
75: ; preds = %68
%76 = call i8* @read_response(i32 %8)
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %82
78: ; preds = %75
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 279)
%81 = call i32 @close(i32 %8)
br label %108
82: ; preds = %75
%83 = icmp eq i32 %40, 0
%84 = load i8, i8* %5
%85 = icmp ne i8 %84, 0
%86 = select i1 %83, i1 true, i1 %85
br i1 %86, label %87, label %90
87: ; preds = %82
%88 = call i32 @printf(i8* %76)
%89 = call i32 @free(i8* %76)
br label %90
90: ; preds = %82, %87
%91 = call i8* @read_response(i32 %8)
%92 = icmp eq i8* %91, null
%93 = load i32, i32* @stderr
br i1 %92, label %94, label %97
94: ; preds = %90
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 290)
%96 = call i32 @close(i32 %8)
br label %108
97: ; preds = %90
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* %91)
%99 = call i32 @free(i8* %91)
%100 = call i32 @close(i32 %8)
br i1 %86, label %106, label %101
101: ; preds = %97
%102 = call i64 @handle_play(i8* %76)
%103 = icmp eq i64 %102, 0
br i1 %103, label %106, label %104
104: ; preds = %101
%105 = call i32 @free(i8* %76)
br label %108
106: ; preds = %101, %97
%107 = sext i8 %84 to i32
br label %108
108: ; preds = %78, %106, %104, %94, %71
%109 = phi i32 [ -1, %71 ], [ -1, %78 ], [ %107, %106 ], [ -1, %104 ], [ -1, %94 ]
br label %110
110: ; preds = %108, %66, %59
%111 = phi i32 [ -1, %59 ], [ -1, %66 ], [ %109, %108 ]
br label %112
112: ; preds = %110, %48
%113 = phi i32 [ %111, %110 ], [ -1, %48 ]
br label %114
114: ; preds = %112, %25, %19
%115 = phi i32 [ -1, %19 ], [ -1, %25 ], [ %113, %112 ]
br label %116
116: ; preds = %114, %10
%117 = phi i32 [ -1, %10 ], [ %115, %114 ]
ret i32 %117
}