#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*/, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(struct sockaddr_un *, int /*<<< orphan*/, int);
int read(int, int **, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strncmp(int *, int *, int);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int);
int write(int, int **, int);
void testCatAndClose() {
  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, "catAndClose 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, "catAndClose connect");
  uint8_t data[] = {0, 4, 0, 1, 0xCA, 0xFE, 0xBA, 0xBE, 0, 0, 0, 0xFF};
  written = write(sock, &data, sizeof(data));
  if (written < sizeof(data))
    error(EXIT_FAILURE, errno, "catAndClose write");
  uint8_t resp[256];
  errno = 0;
  ret = read(sock, &resp, 2 + 2 + 4);
  if (ret != 2 + 2 + 4)
    error(EXIT_FAILURE, errno, "cat read response");
  len = (resp[0] << 8) | resp[1];
  if (len != 4)
    error(EXIT_FAILURE, 0, "unexpected cat length %d", len);
  type = (resp[2] << 8) | resp[3];
  if (type != 1)
    error(EXIT_FAILURE, 0, "unexpected cat type %d", type);
  if (strncmp(&data[4], &resp[4], 4))
    error(EXIT_FAILURE, 0, "unexpected cat response");
  errno = 0;
  ret = read(sock, &resp, 2 + 2 + 0);
  if (ret != 2 + 2 + 0)
    error(EXIT_FAILURE, errno, "close read response");
  len = (resp[0] << 8) | resp[1];
  if (len != 0)
    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);
  close(sock);
}


x86 assembly (clang, -O0):
<testCatAndClose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%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    11f4 <testCatAndClose+0x54>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    0xe13(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
lea    0xdf9(%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    1265 <testCatAndClose+0xc5>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
mov    0x2d7e(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    0xdc3(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    -0x50(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x30,%edx
call   1090 <memcpy@plt>
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x30,%edx
call   1050 <write@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x30,%rax
jae    12bf <testCatAndClose+0x11f>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
mov    0x2d24(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    0xd7d(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    0x2d0a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0x8,%edx
call   1080 <read@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
je     1311 <testCatAndClose+0x171>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
mov    0x2cd2(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    0xd3d(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x450(%rbp),%eax
shl    $0x8,%eax
or     -0x44c(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
je     1349 <testCatAndClose+0x1a9>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
xor    %esi,%esi
lea    0xd17(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x448(%rbp),%eax
shl    $0x8,%eax
or     -0x444(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     1381 <testCatAndClose+0x1e1>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%ecx
xor    %esi,%esi
lea    0xcf8(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
lea    -0x50(%rbp),%rdi
add    $0x10,%rdi
lea    -0x450(%rbp),%rsi
add    $0x10,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13c1 <testCatAndClose+0x221>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    0xccf(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    0x2c08(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
je     1413 <testCatAndClose+0x273>
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
mov    0x2bd0(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
lea    0xc95(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x450(%rbp),%eax
shl    $0x8,%eax
or     -0x44c(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     144b <testCatAndClose+0x2ab>
mov    0x2b92(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
xor    %esi,%esi
lea    0xc71(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x448(%rbp),%eax
shl    $0x8,%eax
or     -0x444(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xff,-0x10(%rbp)
je     1486 <testCatAndClose+0x2e6>
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%ecx
xor    %esi,%esi
lea    0xc51(%rip),%rdx
mov    $0x0,%al
call   10a0 <error@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testCatAndClose>:
push   %rbp
push   %r14
push   %rbx
sub    $0x440,%rsp
mov    0x2e46(%rip),%r14
mov    (%r14),%edi
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11db <testCatAndClose+0x4b>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
lea    0xe2c(%rip),%rdx
xor    %eax,%eax
call   1090 <error@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    (%r14),%eax
mov    %eax,0xc(%rsp)
mov    0x8(%rsp),%edi
lea    0xe12(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   10a0 <connect@plt>
test   %eax,%eax
jns    123e <testCatAndClose+0xae>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
lea    0xdea(%rip),%rdx
xor    %eax,%eax
call   1090 <error@plt>
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x30,%edx
call   1050 <write@plt>
cmp    $0x2f,%eax
ja     1298 <testCatAndClose+0x108>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
lea    0xda4(%rip),%rdx
xor    %eax,%eax
call   1090 <error@plt>
mov    0x2d31(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x40(%rsp),%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1080 <read@plt>
cmp    $0x8,%eax
je     12d5 <testCatAndClose+0x145>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
lea    0xd79(%rip),%rdx
xor    %eax,%eax
call   1090 <error@plt>
mov    0x40(%rsp),%ecx
shl    $0x8,%ecx
or     0x44(%rsp),%ecx
cmp    $0x4,%ecx
je     12fe <testCatAndClose+0x16e>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd64(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <error@plt>
mov    0x48(%rsp),%ecx
shl    $0x8,%ecx
or     0x4c(%rsp),%ecx
cmp    $0x1,%ecx
je     1327 <testCatAndClose+0x197>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <error@plt>
lea    0x20(%rsp),%rdi
lea    0x50(%rsp),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1359 <testCatAndClose+0x1c9>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <error@plt>
movq   $0x0,(%rbx)
lea    0x40(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1080 <read@plt>
cmp    $0x4,%eax
je     138f <testCatAndClose+0x1ff>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
lea    0xd19(%rip),%rdx
xor    %eax,%eax
call   1090 <error@plt>
mov    0x40(%rsp),%ecx
shl    $0x8,%ecx
or     0x44(%rsp),%ecx
je     13b5 <testCatAndClose+0x225>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
lea    0xd09(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <error@plt>
mov    0x48(%rsp),%ecx
shl    $0x8,%ecx
or     0x4c(%rsp),%ecx
cmp    $0xff,%ecx
je     13e1 <testCatAndClose+0x251>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
lea    0xcf8(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <error@plt>
mov    %ebp,%edi
call   1070 <close@plt>
add    $0x440,%rsp
pop    %rbx
pop    %r14
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 = [19 x i8] c"catAndClose socket\00"
@.str.1 = [14 x i8] c"/tmp/mysocket\00"
@.str.2 = [20 x i8] c"catAndClose connect\00"
@__const.testCatAndClose.data = [12 x i32] [i32 0, i32 4, i32 0, i32 1, i32 202, i32 254, i32 186, i32 190, i32 0, i32 0, i32 0, i32 255]
@.str.3 = [18 x i8] c"catAndClose write\00"
@.str.4 = [18 x i8] c"cat read response\00"
@.str.5 = [25 x i8] c"unexpected cat length %d\00"
@.str.6 = [23 x i8] c"unexpected cat type %d\00"
@.str.7 = [24 x i8] c"unexpected cat response\00"
@.str.8 = [20 x i8] c"close read response\00"
@.str.9 = [27 x i8] c"unexpected close length %d\00"
@.str.10 = [25 x i8] c"unexpected close type %d\00"
define void @testCatAndClose() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_un
%7 = alloca [12 x i32]
%8 = alloca [256 x i32]
%9 = load i32, i32* @AF_UNIX
%10 = load i32, i32* @SOCK_STREAM
%11 = call i32 @socket(i32 %9, i32 %10, i32 0)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = load i32, i32* @EXIT_FAILURE
%16 = load i64, i64* @errno
%17 = trunc i64 %16 to i32
%18 = call i32 (i32, i32, i8*, ...) @error(i32 %15, i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %14, %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 %36
31: ; preds = %19
%32 = load i32, i32* @EXIT_FAILURE
%33 = load i64, i64* @errno
%34 = trunc i64 %33 to i32
%35 = call i32 (i32, i32, i8*, ...) @error(i32 %32, i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %31, %19
%37 = bitcast [12 x i32]* %7 to i8*
%38 = load i32, i32* %2
%39 = bitcast [12 x i32]* %7 to i32**
%40 = call i32 @write(i32 %38, i32** %39, i32 48)
store i32 %40, i32* %5
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = icmp ult i64 %42, 48
br i1 %43, label %44, label %49
44: ; preds = %36
%45 = load i32, i32* @EXIT_FAILURE
%46 = load i64, i64* @errno
%47 = trunc i64 %46 to i32
%48 = call i32 (i32, i32, i8*, ...) @error(i32 %45, i32 %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %44, %36
store i64 0, i64* @errno
%50 = load i32, i32* %2
%51 = bitcast [256 x i32]* %8 to i32**
%52 = call i32 @read(i32 %50, i32** %51, i32 8)
store i32 %52, i32* %1
%53 = load i32, i32* %1
%54 = icmp ne i32 %53, 8
br i1 %54, label %55, label %60
55: ; preds = %49
%56 = load i32, i32* @EXIT_FAILURE
%57 = load i64, i64* @errno
%58 = trunc i64 %57 to i32
%59 = call i32 (i32, i32, i8*, ...) @error(i32 %56, i32 %58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %55, %49
%61 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%62 = load i32, i32* %61
%63 = shl i32 %62, 8
%64 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 1
%65 = load i32, i32* %64
%66 = or i32 %63, %65
store i32 %66, i32* %3
%67 = load i32, i32* %3
%68 = icmp ne i32 %67, 4
br i1 %68, label %69, label %73
69: ; preds = %60
%70 = load i32, i32* @EXIT_FAILURE
%71 = load i32, i32* %3
%72 = call i32 (i32, i32, i8*, ...) @error(i32 %70, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %69, %60
%74 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 2
%75 = load i32, i32* %74
%76 = shl i32 %75, 8
%77 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 3
%78 = load i32, i32* %77
%79 = or i32 %76, %78
store i32 %79, i32* %4
%80 = load i32, i32* %4
%81 = icmp ne i32 %80, 1
br i1 %81, label %82, label %86
82: ; preds = %73
%83 = load i32, i32* @EXIT_FAILURE
%84 = load i32, i32* %4
%85 = call i32 (i32, i32, i8*, ...) @error(i32 %83, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %82, %73
%87 = getelementptr inbounds [12 x i32], [12 x i32]* %7, i64 0, i64 4
%88 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 4
%89 = call i64 @strncmp(i32* %87, i32* %88, i32 4)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 (i32, i32, i8*, ...) @error(i32 %92, i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %94
94: ; preds = %91, %86
store i64 0, i64* @errno
%95 = load i32, i32* %2
%96 = bitcast [256 x i32]* %8 to i32**
%97 = call i32 @read(i32 %95, i32** %96, i32 4)
store i32 %97, i32* %1
%98 = load i32, i32* %1
%99 = icmp ne i32 %98, 4
br i1 %99, label %100, label %105
100: ; preds = %94
%101 = load i32, i32* @EXIT_FAILURE
%102 = load i64, i64* @errno
%103 = trunc i64 %102 to i32
%104 = call i32 (i32, i32, i8*, ...) @error(i32 %101, i32 %103, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %105
105: ; preds = %100, %94
%106 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%107 = load i32, i32* %106
%108 = shl i32 %107, 8
%109 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 1
%110 = load i32, i32* %109
%111 = or i32 %108, %110
store i32 %111, i32* %3
%112 = load i32, i32* %3
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %105
%115 = load i32, i32* @EXIT_FAILURE
%116 = load i32, i32* %3
%117 = call i32 (i32, i32, i8*, ...) @error(i32 %115, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 %116)
br label %118
118: ; preds = %114, %105
%119 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 2
%120 = load i32, i32* %119
%121 = shl i32 %120, 8
%122 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 3
%123 = load i32, i32* %122
%124 = or i32 %121, %123
store i32 %124, i32* %4
%125 = load i32, i32* %4
%126 = icmp ne i32 %125, 255
br i1 %126, label %127, label %131
127: ; preds = %118
%128 = load i32, i32* @EXIT_FAILURE
%129 = load i32, i32* %4
%130 = call i32 (i32, i32, i8*, ...) @error(i32 %128, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %129)
br label %131
131: ; preds = %127, %118
%132 = load i32, i32* %2
%133 = call i32 @close(i32 %132)
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 = [19 x i8] c"catAndClose socket\00"
@.str.1 = [14 x i8] c"/tmp/mysocket\00"
@.str.2 = [20 x i8] c"catAndClose connect\00"
@__const.testCatAndClose.data = [12 x i32] [i32 0, i32 4, i32 0, i32 1, i32 202, i32 254, i32 186, i32 190, i32 0, i32 0, i32 0, i32 255]
@.str.3 = [18 x i8] c"catAndClose write\00"
@.str.4 = [18 x i8] c"cat read response\00"
@.str.5 = [25 x i8] c"unexpected cat length %d\00"
@.str.6 = [23 x i8] c"unexpected cat type %d\00"
@.str.7 = [24 x i8] c"unexpected cat response\00"
@.str.8 = [20 x i8] c"close read response\00"
@.str.9 = [27 x i8] c"unexpected close length %d\00"
@.str.10 = [25 x i8] c"unexpected close type %d\00"
define void @testCatAndClose() {
%1 = alloca %struct.sockaddr_un
%2 = alloca [12 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 %14
9: ; preds = %0
%10 = load i32, i32* @EXIT_FAILURE
%11 = load i64, i64* @errno
%12 = trunc i64 %11 to i32
%13 = tail call i32 (i32, i32, i8*, ...) @error(i32 %10, i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %9, %0
%15 = call i32 @memset(%struct.sockaddr_un* %1, i32 0, i32 8)
%16 = load i32, i32* @AF_UNIX
%17 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
store i32 %16, i32* %17
%18 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @strncpy(i32 %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 3)
%21 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%22 = call i32 @connect(i32 %7, %struct.sockaddr* %21, i32 8)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %14
%25 = load i32, i32* @EXIT_FAILURE
%26 = load i64, i64* @errno
%27 = trunc i64 %26 to i32
%28 = call i32 (i32, i32, i8*, ...) @error(i32 %25, i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %24, %14
%30 = bitcast [12 x i32]* %2 to i8*
%31 = bitcast [12 x i32]* %2 to i32**
%32 = call i32 @write(i32 %7, i32** %31, i32 48)
%33 = icmp ult i32 %32, 48
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load i32, i32* @EXIT_FAILURE
%36 = load i64, i64* @errno
%37 = trunc i64 %36 to i32
%38 = call i32 (i32, i32, i8*, ...) @error(i32 %35, i32 %37, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %34, %29
%40 = bitcast [256 x i32]* %3 to i8*
store i64 0, i64* @errno
%41 = bitcast [256 x i32]* %3 to i32**
%42 = call i32 @read(i32 %7, i32** %41, i32 8)
%43 = icmp eq i32 %42, 8
br i1 %43, label %49, label %44
44: ; preds = %39
%45 = load i32, i32* @EXIT_FAILURE
%46 = load i64, i64* @errno
%47 = trunc i64 %46 to i32
%48 = call i32 (i32, i32, i8*, ...) @error(i32 %45, i32 %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %44, %39
%50 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%51 = load i32, i32* %50
%52 = shl i32 %51, 8
%53 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 1
%54 = load i32, i32* %53
%55 = or i32 %52, %54
%56 = icmp eq i32 %55, 4
br i1 %56, label %60, label %57
57: ; preds = %49
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 (i32, i32, i8*, ...) @error(i32 %58, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %60
60: ; preds = %57, %49
%61 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 2
%62 = load i32, i32* %61
%63 = shl i32 %62, 8
%64 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 3
%65 = load i32, i32* %64
%66 = or i32 %63, %65
%67 = icmp eq i32 %66, 1
br i1 %67, label %71, label %68
68: ; preds = %60
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 (i32, i32, i8*, ...) @error(i32 %69, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %66)
br label %71
71: ; preds = %68, %60
%72 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 4
%73 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 4
%74 = call i64 @strncmp(i32* %72, i32* %73, i32 4)
%75 = icmp eq i64 %74, 0
br i1 %75, label %79, label %76
76: ; preds = %71
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 (i32, i32, i8*, ...) @error(i32 %77, i32 0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %79
79: ; preds = %76, %71
store i64 0, i64* @errno
%80 = call i32 @read(i32 %7, i32** %41, i32 4)
%81 = icmp eq i32 %80, 4
br i1 %81, label %87, label %82
82: ; preds = %79
%83 = load i32, i32* @EXIT_FAILURE
%84 = load i64, i64* @errno
%85 = trunc i64 %84 to i32
%86 = call i32 (i32, i32, i8*, ...) @error(i32 %83, i32 %85, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %87
87: ; preds = %82, %79
%88 = load i32, i32* %50
%89 = shl i32 %88, 8
%90 = load i32, i32* %53
%91 = or i32 %89, %90
%92 = icmp eq i32 %91, 0
br i1 %92, label %96, label %93
93: ; preds = %87
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 (i32, i32, i8*, ...) @error(i32 %94, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 %91)
br label %96
96: ; preds = %93, %87
%97 = load i32, i32* %61
%98 = shl i32 %97, 8
%99 = load i32, i32* %64
%100 = or i32 %98, %99
%101 = icmp eq i32 %100, 255
br i1 %101, label %105, label %102
102: ; preds = %96
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 (i32, i32, i8*, ...) @error(i32 %103, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %100)
br label %105
105: ; preds = %102, %96
%106 = call i32 @close(i32 %7)
ret void
}