#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 /*<<< orphan*/ sockaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr const *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, void *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
char *stpcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int sock, rv, buflen, i;
  struct sockaddr_un sockaddr;
  char *buffer = NULL, *p, *sockpath = "/var/run/libcare.sock";
  if (argc < 2 || (argv[1][0] == '/' && argc < 3)) {
    printf("%s: [/SOCKET] ARG0 [ARG1] [ARG2]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  argv++;
  argc--;
  sock = socket(AF_UNIX, SOCK_STREAM, 0);
  if (sock == -1)
    do {
      perror("socket(AF_UNIX)");
      exit(EXIT_FAILURE);
    } while (0);
  sockaddr.sun_family = AF_UNIX;
  if (argv[0][0] == '/') {
    sockpath = argv[0];
    argv++;
    argc--;
  }
  strncpy(sockaddr.sun_path, sockpath, sizeof(sockaddr.sun_path));
  rv = connect(sock, (const struct sockaddr *)&sockaddr, sizeof(sockaddr));
  if (rv == -1)
    do {
      perror("connect");
      exit(EXIT_FAILURE);
    } while (0);
  buflen = 0;
  for (i = 0; i < argc; i++) {
    buflen += strlen(argv[i]) + 1;
  }
  buflen++;
  p = buffer = malloc(buflen);
  if (buffer == NULL)
    do {
      perror("malloc");
      exit(EXIT_FAILURE);
    } while (0);
  for (i = 0; i < argc; i++) {
    p = stpcpy(p, argv[i]);
    p++;
  }
  *p++ = '\0';
  rv = send(sock, (void *)buffer, buflen, 0);
  if (rv == -1)
    do {
      perror("send");
      exit(EXIT_FAILURE);
    } while (0);
  if (buflen < 4096) {
    free(buffer);
    buflen = 4096;
    buffer = malloc(buflen);
  }
  while (1) {
    rv = recv(sock, buffer, buflen, 0);
    if (rv == 0)
      break;
    if (rv < 0)
      do {
        perror("recv");
        exit(EXIT_FAILURE);
      } while (0);
    write(1, buffer, rv);
  }
  close(sock);
  free(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xdfb(%rip),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1231 <main+0x51>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1252 <main+0x72>
cmpl   $0x3,-0x8(%rbp)
jge    1252 <main+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd7(%rip),%rdi
call   10a0 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12ac <main+0xcc>
jmp    1292 <main+0xb2>
lea    0xd9f(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12eb <main+0x10b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   1050 <strncpy@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   10f0 <connect@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1339 <main+0x159>
jmp    131f <main+0x13f>
lea    0xd22(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1383 <main+0x1a3>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1347 <main+0x167>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13c6 <main+0x1e6>
jmp    13ac <main+0x1cc>
lea    0xc9d(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    140c <main+0x22c>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <stpcpy@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13cd <main+0x1ed>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,(%rax)
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    145b <main+0x27b>
jmp    1441 <main+0x261>
lea    0xc0f(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x1000,-0x1c(%rbp)
jge    1484 <main+0x2a4>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1000,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
jmp    1489 <main+0x2a9>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    14ac <main+0x2cc>
jmp    14eb <main+0x30b>
cmpl   $0x0,-0x18(%rbp)
jge    14d5 <main+0x2f5>
jmp    14bb <main+0x2db>
lea    0xb9a(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1060 <write@plt>
jmp    1489 <main+0x2a9>
mov    -0x14(%rbp),%edi
call   10b0 <close@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
cmp    $0x2,%edi
jl     13e2 <main+0x202>
mov    %edi,%r15d
jne    120d <main+0x2d>
mov    0x8(%r12),%rax
cmpb   $0x2f,(%rax)
je     13e2 <main+0x202>
mov    0x2dd4(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     13f4 <main+0x214>
mov    %eax,%r14d
lea    0x8(%r12),%rax
mov    (%rbx),%ecx
mov    %ecx,0x14(%rsp)
mov    0x8(%r12),%rcx
add    $0x10,%r12
xor    %ebp,%ebp
cmpb   $0x2f,(%rcx)
cmovne %rax,%r12
sete   %bl
lea    0xda7(%rip),%rsi
cmove  %rcx,%rsi
mov    $0x4,%edx
call   1050 <strncpy@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x8,%edx
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
je     13fd <main+0x21d>
mov    %bl,%bpl
not    %ebp
add    %r15d,%ebp
je     1310 <main+0x130>
mov    %ebp,0xc(%rsp)
mov    %ebp,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rdi
call   1080 <strlen@plt>
add    %eax,%ebx
add    $0x1,%ebx
add    $0x1,%rbp
cmp    %rbp,%r13
jne    12a0 <main+0xc0>
lea    0x1(%rbx),%r15d
mov    %r15d,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1406 <main+0x226>
mov    %rax,%rbp
cmpl   $0x0,0xc(%rsp)
je     1330 <main+0x150>
mov    %r14d,0xc(%rsp)
xor    %r14d,%r14d
mov    %rbp,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r14,8),%rsi
mov    %rax,%rdi
call   1070 <stpcpy@plt>
add    $0x1,%rax
add    $0x1,%r14
cmp    %r14,%r13
jne    12f0 <main+0x110>
mov    0xc(%rsp),%r14d
jmp    1333 <main+0x153>
mov    $0x1,%r15d
mov    $0x1,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1406 <main+0x226>
mov    %rax,%rbp
xor    %ebx,%ebx
jmp    1333 <main+0x153>
mov    %rbp,%rax
movb   $0x0,(%rax)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
cmp    $0xffffffff,%eax
je     140f <main+0x22f>
cmp    $0xffe,%ebx
jg     1393 <main+0x1b3>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x1000,%r15d
mov    $0x1000,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
jmp    1393 <main+0x1b3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %eax,%eax
js     13c8 <main+0x1e8>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
test   %eax,%eax
jne    1380 <main+0x1a0>
mov    %r14d,%edi
call   10b0 <close@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc8d(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    (%r12),%rsi
lea    0xc29(%rip),%rdi
call   10a0 <printf@plt>
jmp    13d4 <main+0x1f4>
lea    0xc3d(%rip),%rdi
jmp    13cf <main+0x1ef>
lea    0xc44(%rip),%rdi
jmp    13cf <main+0x1ef>
lea    0xc43(%rip),%rdi
jmp    13cf <main+0x1ef>
lea    0xc41(%rip),%rdi
jmp    13cf <main+0x1ef>

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

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