#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 /*<<< orphan*/ val1;
struct sockaddr_un {
  char *sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_SNDTIMEO;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr const *, int /*<<< orphan*/);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int listen(int, int);
int mkstemp(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int);
int strlen(char *);
int /*<<< orphan*/ unlink(char *);
int main() {
  int sock = 0, ret = 0, val = 0, len = 0, tfd = 0;
  int csk[5];
  struct sockaddr_in sin5;
  struct sockaddr_un sinu;
  pid_t pid;
  char stnbf[100];
  strcpy(stnbf, "/tmp/unix.XXXXXX");
  tfd = mkstemp(stnbf);
  if (tfd < 0) {
    perror("mkstemp error");
    exit(-1);
  }
  close(tfd);
  sinu.sun_family = AF_UNIX;
  strcpy(sinu.sun_path, stnbf);
  len = sizeof(struct sockaddr_un) - sizeof(sinu.sun_path) +
        strlen(sinu.sun_path);
  unlink(stnbf);
  unlink(stnbf);
  if ((pid = fork()) == 0) {
    sock = socket(AF_UNIX, SOCK_STREAM, 0);
    if (sock == -1) {
      perror("socket failed");
      unlink(stnbf);
      exit(-1);
    }
    ret = bind(sock, (struct sockaddr *)&sinu, len);
    if (ret == -1) {
      perror("bind failed");
      printf("errno = %d(%s)\n", errno, strerror(errno));
      unlink(stnbf);
      exit(-1);
    }
    ret = listen(sock, 3);
    if (ret == -1) {
      perror("listen failed");
      unlink(stnbf);
      printf("errno = %d(%s)\n", errno, strerror(errno));
      exit(-1);
    }
    sleep(200);
    printf("chld weak up\n");
    exit(1);
  }
  sleep(2);
  for (val = 0; val < 5; val++) {
    csk[val] = socket(AF_UNIX, SOCK_STREAM, 0);
    if (csk[val] == -1) {
      perror("csk socket failed");
      unlink(stnbf);
      exit(-1);
    }
    int val1 = 2;
    int vasize = 10;
    ret = setsockopt(csk[val], SOL_SOCKET, SO_SNDTIMEO, &val1, sizeof(val1));
    if (ret == -1) {
      perror("set failed");
      printf("errno = %d(%s)\n", errno, strerror(errno));
      exit(-1);
    }
    ret = connect(csk[val], (const struct sockaddr *)&sinu, (socklen_t)len);
    if (ret != 0) {
      printf("csk [%d] connect errno = %d(%s)\n", val, errno, strerror(errno));
    } else
      printf("cn ok\n");
  }
  unlink(stnbf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xb0(%rbp),%rdi
call   10a0 <mkstemp@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1277 <main+0x77>
lea    0xda9(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rdi
call   1060 <strlen@plt>
cltq
add    $0x8,%rax
mov    %eax,-0x14(%rbp)
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jne    1424 <main+0x224>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
mov    0x2ce0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1320 <main+0x120>
lea    0xd46(%rip),%rdi
call   10c0 <perror@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10b0 <bind@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1392 <main+0x192>
lea    0xcdc(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xbc(%rbp),%esi
mov    %rax,%rdx
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1090 <listen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1402 <main+0x202>
lea    0xc78(%rip),%rdi
call   10c0 <perror@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc0(%rbp)
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xc0(%rbp),%esi
mov    %rax,%rdx
lea    0xc84(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    $0xc8,%edi
call   1100 <sleep@plt>
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    $0x2,%edi
call   1100 <sleep@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    15b4 <main+0x3b4>
mov    0x2b92(%rip),%rax
mov    (%rax),%edi
mov    0x2b79(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
movslq -0x10(%rbp),%rax
cmpl   $0xffffffff,-0x30(%rbp,%rax,4)
jne    1493 <main+0x293>
lea    0xbcf(%rip),%rdi
call   10c0 <perror@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
movl   $0x2,-0xb4(%rbp)
movl   $0xa,-0xb8(%rbp)
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
mov    0x2b2a(%rip),%rax
mov    (%rax),%esi
mov    0x2b31(%rip),%rax
mov    (%rax),%edx
lea    -0xb4(%rbp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    152a <main+0x32a>
lea    0xb72(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2acd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xc4(%rbp),%esi
mov    %rax,%rdx
lea    0xb5c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
lea    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10e0 <connect@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1593 <main+0x393>
mov    -0x10(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    0x2a65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc8(%rbp)
mov    0x2a56(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xcc(%rbp),%esi
mov    -0xc8(%rbp),%edx
mov    %rax,%rcx
lea    0xadd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15a1 <main+0x3a1>
lea    0xaeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15a6 <main+0x3a6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1435 <main+0x235>
lea    -0xb0(%rbp),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xdd8(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   10b0 <mkstemp@plt>
test   %eax,%eax
js     13d0 <main+0x1c0>
mov    %eax,%edi
call   1090 <close@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
lea    0x20(%rsp),%rbp
mov    %rbp,%rsi
call   1040 <strcpy@plt>
call   1070 <strlen@plt>
mov    %eax,%r13d
add    $0x8,%r13d
mov    %rbp,%rdi
call   1030 <unlink@plt>
mov    %rbp,%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     13e6 <main+0x1d6>
mov    $0x2,%edi
call   1110 <sleep@plt>
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%r15
xor    %ebp,%ebp
jmp    12c8 <main+0xb8>
nopl   0x0(%rax)
lea    0xdc0(%rip),%rdi
call   1050 <puts@plt>
add    $0x1,%ebp
cmp    $0x5,%ebp
je     1359 <main+0x149>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     1377 <main+0x167>
mov    %eax,%r12d
movl   $0x2,0xc(%rsp)
mov    0x2ce4(%rip),%rax
mov    (%rax),%esi
mov    0x2ceb(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
mov    %r14,%rcx
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1397 <main+0x187>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r13d,%edx
call   10f0 <connect@plt>
test   %eax,%eax
je     12b0 <main+0xa0>
mov    0x2c8a(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xd10(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    12bc <main+0xac>
lea    0x20(%rsp),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcbb(%rip),%rdi
call   10d0 <perror@plt>
lea    0x20(%rsp),%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
lea    0xcad(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xcad(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
lea    0xc3a(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
mov    0x2bd2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
jne    1410 <main+0x200>
lea    0xc32(%rip),%rdi
jmp    137e <main+0x16e>
mov    %eax,%ebp
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    %r13d,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    145a <main+0x24a>
lea    0xbf2(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2b87(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xc1e(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1383 <main+0x173>
mov    %ebp,%edi
mov    $0x3,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1486 <main+0x276>
lea    0xbb9(%rip),%rdi
call   10d0 <perror@plt>
lea    0x20(%rsp),%rdi
call   1030 <unlink@plt>
jmp    13a3 <main+0x193>
mov    $0xc8,%edi
call   1110 <sleep@plt>
lea    0xbe6(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"/tmp/unix.XXXXXX\00"
@.str.1 = [14 x i8] c"mkstemp error\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [14 x i8] c"socket failed\00"
@.str.3 = [12 x i8] c"bind failed\00"
@.str.4 = [16 x i8] c"errno = %d(%s)\0A\00"
@errno = global i32 0
@.str.5 = [14 x i8] c"listen failed\00"
@.str.6 = [14 x i8] c"chld weak up\0A\00"
@.str.7 = [18 x i8] c"csk socket failed\00"
@SOL_SOCKET = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.8 = [11 x i8] c"set failed\00"
@.str.9 = [33 x i8] c"csk [%d] connect errno = %d(%s)\0A\00"
@.str.10 = [7 x i8] c"cn ok\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [5 x i32]
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_un
%10 = alloca i32
%11 = alloca [100 x i8]
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%17 = call i32 @mkstemp(i8* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %0
%24 = load i32, i32* %6
%25 = call i32 @close(i32 %24)
%26 = load i32, i32* @AF_UNIX
%27 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 1
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 0
%29 = load i8*, i8** %28
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 0
%33 = load i8*, i8** %32
%34 = call i32 @strlen(i8* %33)
%35 = sext i32 %34 to i64
%36 = add i64 8, %35
%37 = trunc i64 %36 to i32
store i32 %37, i32* %5
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%39 = call i32 @unlink(i8* %38)
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%41 = call i32 @unlink(i8* %40)
%42 = call i32 (...) @fork()
store i32 %42, i32* %10
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %89
44: ; preds = %23
%45 = load i32, i32* @AF_UNIX
%46 = load i32, i32* @SOCK_STREAM
%47 = call i32 @socket(i32 %45, i32 %46, i32 0)
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %55
50: ; preds = %44
%51 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%53 = call i32 @unlink(i8* %52)
%54 = call i32 @exit(i32 -1)
unreachable
55: ; preds = %44
%56 = load i32, i32* %2
%57 = bitcast %struct.sockaddr_un* %9 to %struct.sockaddr*
%58 = load i32, i32* %5
%59 = call i32 @bind(i32 %56, %struct.sockaddr* %57, i32 %58)
store i32 %59, i32* %3
%60 = load i32, i32* %3
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %71
62: ; preds = %55
%63 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%64 = load i32, i32* @errno
%65 = load i32, i32* @errno
%66 = call i8* @strerror(i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %64, i8* %66)
%68 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%69 = call i32 @unlink(i8* %68)
%70 = call i32 @exit(i32 -1)
unreachable
71: ; preds = %55
%72 = load i32, i32* %2
%73 = call i32 @listen(i32 %72, i32 3)
store i32 %73, i32* %3
%74 = load i32, i32* %3
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %85
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%79 = call i32 @unlink(i8* %78)
%80 = load i32, i32* @errno
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %80, i8* %82)
%84 = call i32 @exit(i32 -1)
unreachable
85: ; preds = %71
%86 = call i32 @sleep(i32 200)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %23
%90 = call i32 @sleep(i32 2)
store i32 0, i32* %4
br label %91
91: ; preds = %147, %89
%92 = load i32, i32* %4
%93 = icmp slt i32 %92, 5
br i1 %93, label %94, label %150
94: ; preds = %91
%95 = load i32, i32* @AF_UNIX
%96 = load i32, i32* @SOCK_STREAM
%97 = call i32 @socket(i32 %95, i32 %96, i32 0)
%98 = load i32, i32* %4
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %99
store i32 %97, i32* %100
%101 = load i32, i32* %4
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %111
106: ; preds = %94
%107 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%109 = call i32 @unlink(i8* %108)
%110 = call i32 @exit(i32 -1)
unreachable
111: ; preds = %94
store i32 2, i32* %12
store i32 10, i32* %13
%112 = load i32, i32* %4
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %113
%115 = load i32, i32* %114
%116 = load i32, i32* @SOL_SOCKET
%117 = load i32, i32* @SO_SNDTIMEO
%118 = call i32 @setsockopt(i32 %115, i32 %116, i32 %117, i32* %12, i32 4)
store i32 %118, i32* %3
%119 = load i32, i32* %3
%120 = icmp eq i32 %119, -1
br i1 %120, label %121, label %128
121: ; preds = %111
%122 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%123 = load i32, i32* @errno
%124 = load i32, i32* @errno
%125 = call i8* @strerror(i32 %124)
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %123, i8* %125)
%127 = call i32 @exit(i32 -1)
unreachable
128: ; preds = %111
%129 = load i32, i32* %4
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %130
%132 = load i32, i32* %131
%133 = bitcast %struct.sockaddr_un* %9 to %struct.sockaddr*
%134 = load i32, i32* %5
%135 = call i32 @connect(i32 %132, %struct.sockaddr* %133, i32 %134)
store i32 %135, i32* %3
%136 = load i32, i32* %3
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %144
138: ; preds = %128
%139 = load i32, i32* %4
%140 = load i32, i32* @errno
%141 = load i32, i32* @errno
%142 = call i8* @strerror(i32 %141)
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %139, i32 %140, i8* %142)
br label %146
144: ; preds = %128
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %146
146: ; preds = %144, %138
br label %147
147: ; preds = %146
%148 = load i32, i32* %4
%149 = add nsw i32 %148, 1
store i32 %149, i32* %4
br label %91
150: ; preds = %91
%151 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%152 = call i32 @unlink(i8* %151)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"/tmp/unix.XXXXXX\00"
@.str.1 = [14 x i8] c"mkstemp error\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [14 x i8] c"socket failed\00"
@.str.3 = [12 x i8] c"bind failed\00"
@.str.4 = [16 x i8] c"errno = %d(%s)\0A\00"
@errno = global i32 0
@.str.5 = [14 x i8] c"listen failed\00"
@.str.7 = [18 x i8] c"csk socket failed\00"
@SOL_SOCKET = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.8 = [11 x i8] c"set failed\00"
@.str.9 = [33 x i8] c"csk [%d] connect errno = %d(%s)\0A\00"
@str = [6 x i8] c"cn ok\00"
@str.11 = [13 x i8] c"chld weak up\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_un
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = bitcast %struct.sockaddr_un* %1 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @mkstemp(i8* %5)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %0
%13 = call i32 @close(i32 %7)
%14 = load i32, i32* @AF_UNIX
%15 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
store i32 %14, i32* %15
%16 = call i32 @strcpy(i8* undef, i8* %5)
%17 = call i32 @strlen(i8* undef)
%18 = add i32 %17, 8
%19 = call i32 @unlink(i8* %5)
%20 = call i32 @unlink(i8* %5)
%21 = call i32 (...) @fork()
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %57
23: ; preds = %12
%24 = load i32, i32* @AF_UNIX
%25 = load i32, i32* @SOCK_STREAM
%26 = call i32 @socket(i32 %24, i32 %25, i32 0)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @unlink(i8* %5)
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %23
%33 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%34 = call i32 @bind(i32 %26, %struct.sockaddr* %33, i32 %18)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %38, i8* %39)
%41 = call i32 @unlink(i8* %5)
%42 = call i32 @exit(i32 -1)
unreachable
43: ; preds = %32
%44 = call i32 @listen(i32 %26, i32 3)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %53
46: ; preds = %43
%47 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%48 = call i32 @unlink(i8* %5)
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %49, i8* %50)
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %43
%54 = call i32 @sleep(i32 200)
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %12
%58 = call i32 @sleep(i32 2)
%59 = bitcast i32* %3 to i8*
%60 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
br label %61
61: ; preds = %57, %91
%62 = phi i32 [ 0, %57 ], [ %92, %91 ]
%63 = load i32, i32* @AF_UNIX
%64 = load i32, i32* @SOCK_STREAM
%65 = call i32 @socket(i32 %63, i32 %64, i32 0)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %71
67: ; preds = %61
%68 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%69 = call i32 @unlink(i8* %5)
%70 = call i32 @exit(i32 -1)
unreachable
71: ; preds = %61
store i32 2, i32* %3
%72 = load i32, i32* @SOL_SOCKET
%73 = load i32, i32* @SO_SNDTIMEO
%74 = call i32 @setsockopt(i32 %65, i32 %72, i32 %73, i32* %3, i32 4)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %82
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %78, i8* %79)
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %71
%83 = call i32 @connect(i32 %65, %struct.sockaddr* %60, i32 %18)
%84 = icmp eq i32 %83, 0
br i1 %84, label %89, label %85
85: ; preds = %82
%86 = load i32, i32* @errno
%87 = call i8* @strerror(i32 %86)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %62, i32 %86, i8* %87)
br label %91
89: ; preds = %82
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %91
91: ; preds = %89, %85
%92 = add nuw nsw i32 %62, 1
%93 = icmp eq i32 %92, 5
br i1 %93, label %94, label %61
94: ; preds = %91
%95 = call i32 @unlink(i8* %5)
ret i32 0
}