#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 */
typedef int uint8_t;
struct sockaddr_un {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ data;

/* 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);
scalar_t__ errno;
int /*<<< orphan*/ error(int /*<<< orphan*/, scalar_t__, char *, ...);
int /*<<< orphan*/ memset(struct sockaddr_un *, int /*<<< orphan*/, int);
int read(int, int **, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int strlen(char *);
scalar_t__ strncmp(char *, int *, int);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int);
int write(int, int **, int);
void testGreeting() {
  int ret, sock, len, type;
  ssize_t written;
  struct sockaddr_un addr;
  sock = socket(AF_UNIX, SOCK_STREAM, 0);
  if (sock < 0)
    error(EXIT_FAILURE, errno, "greeting socket");
  memset(&addr, 0, sizeof(struct sockaddr_un));
  addr.sun_family = AF_UNIX;
  strncpy(addr.sun_path, "/tmp/mysocket", sizeof(addr.sun_path) - 1);
  ret =
      connect(sock, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un));
  if (ret < 0)
    error(EXIT_FAILURE, errno, "greeting connect");
  uint8_t data[] = {0, 5, 0, 0, 'L', 'u', 'c', 'a', 's'};
  written = write(sock, &data, sizeof(data));
  if (written < sizeof(data))
    error(EXIT_FAILURE, errno, "greeting write");
  char *expRespCont = "Greetings, Lucas!\n";
  uint8_t resp[256];
  errno = 0;
  ret = read(sock, &resp, 2 + 2 + strlen(expRespCont));
  if (ret != 2 + 2 + strlen(expRespCont))
    error(EXIT_FAILURE, errno, "unexpected greeting read response 1 length %d",
          ret);
  len = (resp[0] << 8) | resp[1];
  if (len != strlen(expRespCont))
    error(EXIT_FAILURE, 0, "unexpected greeting length %d", len);
  type = (resp[2] << 8) | resp[3];
  if (type != 0)
    error(EXIT_FAILURE, 0, "unexpected greeting response type %d", type);
  if (strncmp(expRespCont, &resp[4], len))
    error(EXIT_FAILURE, 0, "unexpected greeting response");
  expRespCont = "Goodbye.\n";
  errno = 0;
  ret = read(sock, &resp, 2 + 2 + strlen(expRespCont));
  if (ret != 2 + 2 + strlen(expRespCont))
    error(EXIT_FAILURE, errno, "unexpected greeting read response 2 length %d",
          ret);
  len = (resp[0] << 8) | resp[1];
  if (len != strlen(expRespCont))
    error(EXIT_FAILURE, 0, "unexpected close length %d", len);
  type = (resp[2] << 8) | resp[3];
  if (type != 0xFF)
    error(EXIT_FAILURE, 0, "unexpected close type %d", type);
  if (strncmp(expRespCont, &resp[4], len))
    error(EXIT_FAILURE, 0, "unexpected close response");
  close(sock);
}


x86 assembly (clang, -O0):
<testGreeting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11f2 <testGreeting+0x52>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%rsi
lea    0xe15(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
lea    0xdf8(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   10b0 <connect@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1261 <testGreeting+0xc1>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    0x2d80(%rip),%rax
mov    (%rax),%rsi
lea    0xdc4(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1070 <memset@plt>
movl   $0x5,-0x4c(%rbp)
movl   $0x4c,-0x40(%rbp)
movl   $0x75,-0x3c(%rbp)
movl   $0x63,-0x38(%rbp)
movl   $0x61,-0x34(%rbp)
movl   $0x73,-0x30(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x24,%edx
call   1050 <write@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x24,%rax
jae    12de <testGreeting+0x13e>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
mov    0x2d03(%rip),%rax
mov    (%rax),%rsi
lea    0xd58(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    0xd59(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2ce0(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%eax
mov    %eax,-0x474(%rbp)
lea    -0x460(%rbp),%rax
mov    %rax,-0x470(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x474(%rbp),%edi
mov    -0x470(%rbp),%rsi
mov    %eax,%edx
add    $0x4,%edx
call   1090 <read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x464(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x464(%rbp),%eax
add    $0x4,%ecx
cmp    %ecx,%eax
je     137a <testGreeting+0x1da>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
mov    0x2c6a(%rip),%rax
mov    (%rax),%rsi
mov    -0x4(%rbp),%ecx
lea    0xcde(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x460(%rbp),%eax
shl    $0x8,%eax
or     -0x45c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x478(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x478(%rbp),%eax
cmp    %ecx,%eax
je     13cc <testGreeting+0x22c>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
lea    0xcba(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x458(%rbp),%eax
shl    $0x8,%eax
or     -0x454(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1406 <testGreeting+0x266>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
lea    0xc9e(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x58(%rbp),%rdi
lea    -0x460(%rbp),%rsi
add    $0x10,%rsi
mov    -0xc(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1442 <testGreeting+0x2a2>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xc87(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    0xc96(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2b7c(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%eax
mov    %eax,-0x48c(%rbp)
lea    -0x460(%rbp),%rax
mov    %rax,-0x488(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x48c(%rbp),%edi
mov    -0x488(%rbp),%rsi
mov    %eax,%edx
add    $0x4,%edx
call   1090 <read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x47c(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x47c(%rbp),%eax
add    $0x4,%ecx
cmp    %ecx,%eax
je     14de <testGreeting+0x33e>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
mov    0x2b06(%rip),%rax
mov    (%rax),%rsi
mov    -0x4(%rbp),%ecx
lea    0xc12(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x460(%rbp),%eax
shl    $0x8,%eax
or     -0x45c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x490(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x490(%rbp),%eax
cmp    %ecx,%eax
je     1530 <testGreeting+0x390>
mov    0x2aaf(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
lea    0xbee(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x458(%rbp),%eax
shl    $0x8,%eax
or     -0x454(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xff,-0x10(%rbp)
je     156d <testGreeting+0x3cd>
mov    0x2a72(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
lea    0xbcc(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x58(%rbp),%rdi
lea    -0x460(%rbp),%rsi
add    $0x10,%rsi
mov    -0xc(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     15a9 <testGreeting+0x409>
mov    0x2a33(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xba9(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testGreeting>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x440,%rsp
mov    0x2e32(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    11f0 <testGreeting+0x50>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%rsi
lea    0xe27(%rip),%rdx
xor    %eax,%eax
call   10a0 <error@plt>
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0xc(%rsp)
mov    0x8(%rsp),%edi
lea    0xe0b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
call   10b0 <connect@plt>
test   %eax,%eax
jns    1254 <testGreeting+0xb4>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%rsi
lea    0xde1(%rip),%rdx
xor    %eax,%eax
call   10a0 <error@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x5,0x14(%rsp)
movaps 0xd95(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x73,0x30(%rsp)
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x24,%edx
call   1050 <write@plt>
cmp    $0x23,%eax
ja     12b0 <testGreeting+0x110>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%rsi
lea    0xd96(%rip),%rdx
xor    %eax,%eax
call   10a0 <error@plt>
mov    0x2d19(%rip),%r12
movq   $0x0,(%r12)
lea    0xd88(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x4(%rax),%edx
lea    0x40(%rsp),%rsi
mov    %r15d,%edi
call   1090 <read@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
add    $0x4,%eax
cmp    %eax,%ebp
je     130c <testGreeting+0x16c>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rsi
lea    0xd5e(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <error@plt>
mov    0x40(%rsp),%ebp
shl    $0x8,%ebp
or     0x44(%rsp),%ebp
lea    0xd30(%rip),%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
je     1342 <testGreeting+0x1a2>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%rip),%rdx
xor    %esi,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <error@plt>
mov    0x48(%rsp),%ecx
shl    $0x8,%ecx
or     0x4c(%rsp),%ecx
je     1368 <testGreeting+0x1c8>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <error@plt>
lea    0x50(%rsp),%r14
lea    0xcda(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     139c <testGreeting+0x1fc>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <error@plt>
movq   $0x0,(%r12)
lea    0xd44(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x4(%rax),%edx
lea    0x40(%rsp),%rsi
mov    %r15d,%edi
call   1090 <read@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
add    $0x4,%eax
cmp    %eax,%ebp
je     13f1 <testGreeting+0x251>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rsi
lea    0xd11(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <error@plt>
mov    0x40(%rsp),%ebp
shl    $0x8,%ebp
or     0x44(%rsp),%ebp
lea    0xcec(%rip),%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
je     1427 <testGreeting+0x287>
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
lea    0xd0b(%rip),%rdx
xor    %esi,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <error@plt>
mov    0x48(%rsp),%ecx
shl    $0x8,%ecx
or     0x4c(%rsp),%ecx
cmp    $0xff,%ecx
je     1453 <testGreeting+0x2b3>
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
lea    0xcf8(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <error@plt>
lea    0xc95(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1482 <testGreeting+0x2e2>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
lea    0xce2(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <error@plt>
mov    %r15d,%edi
call   1080 <close@plt>
add    $0x440,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str = [16 x i8] c"greeting socket\00"
@.str.1 = [14 x i8] c"/tmp/mysocket\00"
@.str.2 = [17 x i8] c"greeting connect\00"
@.str.3 = [15 x i8] c"greeting write\00"
@.str.4 = [19 x i8] c"Greetings, Lucas!\0A\00"
@.str.5 = [46 x i8] c"unexpected greeting read response 1 length %d\00"
@.str.6 = [30 x i8] c"unexpected greeting length %d\00"
@.str.7 = [37 x i8] c"unexpected greeting response type %d\00"
@.str.8 = [29 x i8] c"unexpected greeting response\00"
@.str.9 = [10 x i8] c"Goodbye.\0A\00"
@.str.10 = [46 x i8] c"unexpected greeting read response 2 length %d\00"
@.str.11 = [27 x i8] c"unexpected close length %d\00"
@.str.12 = [25 x i8] c"unexpected close type %d\00"
@.str.13 = [26 x i8] c"unexpected close response\00"
define void @testGreeting() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_un
%7 = alloca [9 x i32]
%8 = alloca i8*
%9 = alloca [256 x i32]
%10 = load i32, i32* @AF_UNIX
%11 = load i32, i32* @SOCK_STREAM
%12 = call i32 @socket(i32 %10, i32 %11, i32 0)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i32, i32* @EXIT_FAILURE
%17 = load i64, i64* @errno
%18 = call i32 (i32, i64, i8*, ...) @error(i32 %16, i64 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %15, %0
%20 = call i32 @memset(%struct.sockaddr_un* %6, i32 0, i32 8)
%21 = load i32, i32* @AF_UNIX
%22 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 1
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @strncpy(i32 %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 3)
%26 = load i32, i32* %2
%27 = bitcast %struct.sockaddr_un* %6 to %struct.sockaddr*
%28 = call i32 @connect(i32 %26, %struct.sockaddr* %27, i32 8)
store i32 %28, i32* %1
%29 = load i32, i32* %1
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %19
%32 = load i32, i32* @EXIT_FAILURE
%33 = load i64, i64* @errno
%34 = call i32 (i32, i64, i8*, ...) @error(i32 %32, i64 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %31, %19
%36 = bitcast [9 x i32]* %7 to i8*
%37 = bitcast i8* %36 to [9 x i32]*
%38 = getelementptr inbounds [9 x i32], [9 x i32]* %37, i32 0, i32 1
store i32 5, i32* %38
%39 = getelementptr inbounds [9 x i32], [9 x i32]* %37, i32 0, i32 4
store i32 76, i32* %39
%40 = getelementptr inbounds [9 x i32], [9 x i32]* %37, i32 0, i32 5
store i32 117, i32* %40
%41 = getelementptr inbounds [9 x i32], [9 x i32]* %37, i32 0, i32 6
store i32 99, i32* %41
%42 = getelementptr inbounds [9 x i32], [9 x i32]* %37, i32 0, i32 7
store i32 97, i32* %42
%43 = getelementptr inbounds [9 x i32], [9 x i32]* %37, i32 0, i32 8
store i32 115, i32* %43
%44 = load i32, i32* %2
%45 = bitcast [9 x i32]* %7 to i32**
%46 = call i32 @write(i32 %44, i32** %45, i32 36)
store i32 %46, i32* %5
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = icmp ult i64 %48, 36
br i1 %49, label %50, label %54
50: ; preds = %35
%51 = load i32, i32* @EXIT_FAILURE
%52 = load i64, i64* @errno
%53 = call i32 (i32, i64, i8*, ...) @error(i32 %51, i64 %52, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %50, %35
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %8
store i64 0, i64* @errno
%55 = load i32, i32* %2
%56 = bitcast [256 x i32]* %9 to i32**
%57 = load i8*, i8** %8
%58 = call i32 @strlen(i8* %57)
%59 = add nsw i32 4, %58
%60 = call i32 @read(i32 %55, i32** %56, i32 %59)
store i32 %60, i32* %1
%61 = load i32, i32* %1
%62 = load i8*, i8** %8
%63 = call i32 @strlen(i8* %62)
%64 = add nsw i32 4, %63
%65 = icmp ne i32 %61, %64
br i1 %65, label %66, label %71
66: ; preds = %54
%67 = load i32, i32* @EXIT_FAILURE
%68 = load i64, i64* @errno
%69 = load i32, i32* %1
%70 = call i32 (i32, i64, i8*, ...) @error(i32 %67, i64 %68, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %66, %54
%72 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 0
%73 = load i32, i32* %72
%74 = shl i32 %73, 8
%75 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 1
%76 = load i32, i32* %75
%77 = or i32 %74, %76
store i32 %77, i32* %3
%78 = load i32, i32* %3
%79 = load i8*, i8** %8
%80 = call i32 @strlen(i8* %79)
%81 = icmp ne i32 %78, %80
br i1 %81, label %82, label %86
82: ; preds = %71
%83 = load i32, i32* @EXIT_FAILURE
%84 = load i32, i32* %3
%85 = call i32 (i32, i64, i8*, ...) @error(i32 %83, i64 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %82, %71
%87 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 2
%88 = load i32, i32* %87
%89 = shl i32 %88, 8
%90 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 3
%91 = load i32, i32* %90
%92 = or i32 %89, %91
store i32 %92, i32* %4
%93 = load i32, i32* %4
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %86
%96 = load i32, i32* @EXIT_FAILURE
%97 = load i32, i32* %4
%98 = call i32 (i32, i64, i8*, ...) @error(i32 %96, i64 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %97)
br label %99
99: ; preds = %95, %86
%100 = load i8*, i8** %8
%101 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 4
%102 = load i32, i32* %3
%103 = call i64 @strncmp(i8* %100, i32* %101, i32 %102)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %99
%106 = load i32, i32* @EXIT_FAILURE
%107 = call i32 (i32, i64, i8*, ...) @error(i32 %106, i64 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %108
108: ; preds = %105, %99
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8** %8
store i64 0, i64* @errno
%109 = load i32, i32* %2
%110 = bitcast [256 x i32]* %9 to i32**
%111 = load i8*, i8** %8
%112 = call i32 @strlen(i8* %111)
%113 = add nsw i32 4, %112
%114 = call i32 @read(i32 %109, i32** %110, i32 %113)
store i32 %114, i32* %1
%115 = load i32, i32* %1
%116 = load i8*, i8** %8
%117 = call i32 @strlen(i8* %116)
%118 = add nsw i32 4, %117
%119 = icmp ne i32 %115, %118
br i1 %119, label %120, label %125
120: ; preds = %108
%121 = load i32, i32* @EXIT_FAILURE
%122 = load i64, i64* @errno
%123 = load i32, i32* %1
%124 = call i32 (i32, i64, i8*, ...) @error(i32 %121, i64 %122, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0), i32 %123)
br label %125
125: ; preds = %120, %108
%126 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 0
%127 = load i32, i32* %126
%128 = shl i32 %127, 8
%129 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 1
%130 = load i32, i32* %129
%131 = or i32 %128, %130
store i32 %131, i32* %3
%132 = load i32, i32* %3
%133 = load i8*, i8** %8
%134 = call i32 @strlen(i8* %133)
%135 = icmp ne i32 %132, %134
br i1 %135, label %136, label %140
136: ; preds = %125
%137 = load i32, i32* @EXIT_FAILURE
%138 = load i32, i32* %3
%139 = call i32 (i32, i64, i8*, ...) @error(i32 %137, i64 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i32 %138)
br label %140
140: ; preds = %136, %125
%141 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 2
%142 = load i32, i32* %141
%143 = shl i32 %142, 8
%144 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 3
%145 = load i32, i32* %144
%146 = or i32 %143, %145
store i32 %146, i32* %4
%147 = load i32, i32* %4
%148 = icmp ne i32 %147, 255
br i1 %148, label %149, label %153
149: ; preds = %140
%150 = load i32, i32* @EXIT_FAILURE
%151 = load i32, i32* %4
%152 = call i32 (i32, i64, i8*, ...) @error(i32 %150, i64 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 %151)
br label %153
153: ; preds = %149, %140
%154 = load i8*, i8** %8
%155 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 4
%156 = load i32, i32* %3
%157 = call i64 @strncmp(i8* %154, i32* %155, i32 %156)
%158 = icmp ne i64 %157, 0
br i1 %158, label %159, label %162
159: ; preds = %153
%160 = load i32, i32* @EXIT_FAILURE
%161 = call i32 (i32, i64, i8*, ...) @error(i32 %160, i64 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %162
162: ; preds = %159, %153
%163 = load i32, i32* %2
%164 = call i32 @close(i32 %163)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str = [16 x i8] c"greeting socket\00"
@.str.1 = [14 x i8] c"/tmp/mysocket\00"
@.str.2 = [17 x i8] c"greeting connect\00"
@.str.3 = [15 x i8] c"greeting write\00"
@.str.4 = [19 x i8] c"Greetings, Lucas!\0A\00"
@.str.5 = [46 x i8] c"unexpected greeting read response 1 length %d\00"
@.str.6 = [30 x i8] c"unexpected greeting length %d\00"
@.str.7 = [37 x i8] c"unexpected greeting response type %d\00"
@.str.8 = [29 x i8] c"unexpected greeting response\00"
@.str.9 = [10 x i8] c"Goodbye.\0A\00"
@.str.10 = [46 x i8] c"unexpected greeting read response 2 length %d\00"
@.str.11 = [27 x i8] c"unexpected close length %d\00"
@.str.12 = [25 x i8] c"unexpected close type %d\00"
@.str.13 = [26 x i8] c"unexpected close response\00"
define void @testGreeting() {
%1 = alloca %struct.sockaddr_un
%2 = alloca [9 x i32]
%3 = alloca [256 x i32]
%4 = bitcast %struct.sockaddr_un* %1 to i8*
%5 = load i32, i32* @AF_UNIX
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @EXIT_FAILURE
%11 = load i64, i64* @errno
%12 = tail call i32 (i32, i64, i8*, ...) @error(i32 %10, i64 %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %9, %0
%14 = call i32 @memset(%struct.sockaddr_un* %1, i32 0, i32 8)
%15 = load i32, i32* @AF_UNIX
%16 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @strncpy(i32 %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 3)
%20 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%21 = call i32 @connect(i32 %7, %struct.sockaddr* %20, i32 8)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %13
%24 = load i32, i32* @EXIT_FAILURE
%25 = load i64, i64* @errno
%26 = call i32 (i32, i64, i8*, ...) @error(i32 %24, i64 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %23, %13
%28 = bitcast [9 x i32]* %2 to i8*
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 1
store i32 5, i32* %29
%30 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 76, i32 117, i32 99, i32 97>, <4 x i32>* %31
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 8
store i32 115, i32* %32
%33 = bitcast [9 x i32]* %2 to i32**
%34 = call i32 @write(i32 %7, i32** %33, i32 36)
%35 = icmp ult i32 %34, 36
br i1 %35, label %36, label %40
36: ; preds = %27
%37 = load i32, i32* @EXIT_FAILURE
%38 = load i64, i64* @errno
%39 = call i32 (i32, i64, i8*, ...) @error(i32 %37, i64 %38, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %36, %27
%41 = bitcast [256 x i32]* %3 to i8*
store i64 0, i64* @errno
%42 = bitcast [256 x i32]* %3 to i32**
%43 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%44 = add nsw i32 %43, 4
%45 = call i32 @read(i32 %7, i32** %42, i32 %44)
%46 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%47 = add nsw i32 %46, 4
%48 = icmp eq i32 %45, %47
br i1 %48, label %53, label %49
49: ; preds = %40
%50 = load i32, i32* @EXIT_FAILURE
%51 = load i64, i64* @errno
%52 = call i32 (i32, i64, i8*, ...) @error(i32 %50, i64 %51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %45)
br label %53
53: ; preds = %49, %40
%54 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%55 = load i32, i32* %54
%56 = shl i32 %55, 8
%57 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 1
%58 = load i32, i32* %57
%59 = or i32 %56, %58
%60 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp eq i32 %59, %60
br i1 %61, label %65, label %62
62: ; preds = %53
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 (i32, i64, i8*, ...) @error(i32 %63, i64 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %59)
br label %65
65: ; preds = %62, %53
%66 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 2
%67 = load i32, i32* %66
%68 = shl i32 %67, 8
%69 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 3
%70 = load i32, i32* %69
%71 = or i32 %68, %70
%72 = icmp eq i32 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %65
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 (i32, i64, i8*, ...) @error(i32 %74, i64 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %71)
br label %76
76: ; preds = %73, %65
%77 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 4
%78 = call i64 @strncmp(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32* %77, i32 %59)
%79 = icmp eq i64 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %76
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 (i32, i64, i8*, ...) @error(i32 %81, i64 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %83
83: ; preds = %80, %76
store i64 0, i64* @errno
%84 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%85 = add nsw i32 %84, 4
%86 = call i32 @read(i32 %7, i32** %42, i32 %85)
%87 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%88 = add nsw i32 %87, 4
%89 = icmp eq i32 %86, %88
br i1 %89, label %94, label %90
90: ; preds = %83
%91 = load i32, i32* @EXIT_FAILURE
%92 = load i64, i64* @errno
%93 = call i32 (i32, i64, i8*, ...) @error(i32 %91, i64 %92, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0), i32 %86)
br label %94
94: ; preds = %90, %83
%95 = load i32, i32* %54
%96 = shl i32 %95, 8
%97 = load i32, i32* %57
%98 = or i32 %96, %97
%99 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%100 = icmp eq i32 %98, %99
br i1 %100, label %104, label %101
101: ; preds = %94
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 (i32, i64, i8*, ...) @error(i32 %102, i64 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i32 %98)
br label %104
104: ; preds = %101, %94
%105 = load i32, i32* %66
%106 = shl i32 %105, 8
%107 = load i32, i32* %69
%108 = or i32 %106, %107
%109 = icmp eq i32 %108, 255
br i1 %109, label %113, label %110
110: ; preds = %104
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 (i32, i64, i8*, ...) @error(i32 %111, i64 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 %108)
br label %113
113: ; preds = %110, %104
%114 = call i64 @strncmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32* %77, i32 %98)
%115 = icmp eq i64 %114, 0
br i1 %115, label %119, label %116
116: ; preds = %113
%117 = load i32, i32* @EXIT_FAILURE
%118 = call i32 (i32, i64, i8*, ...) @error(i32 %117, i64 0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %119
119: ; preds = %116, %113
%120 = call i32 @close(i32 %7)
ret void
}