#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ sun1;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_un {
  char *sun_path;
  int /*<<< orphan*/ sun_family;
};
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  int sin_family;
  TYPE_1__ sin_addr;
  void *sin_port;
};
struct sockaddr {
  int dummy;
};
struct msghdr {
  int msg_namelen;
  int msg_iovlen;
  scalar_t__ msg_flags;
  scalar_t__ msg_controllen;
  int /*<<< orphan*/ *msg_control;
  struct iovec *msg_iov;
  struct sockaddr_in *msg_name;
};
struct iovec {
  char *iov_base;
  int iov_len;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sin1;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ from;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
void *INADDR_ANY;
int MSG_DONTWAIT;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int getpid();
void *htonl(int);
void *htons(int);
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int mkstemp(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ recvmsg(int, struct msghdr *, int);
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/, struct timeval *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ start_server(struct sockaddr_in *, struct sockaddr_un *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int s, fd_null;
  struct sockaddr_in sin1, sin2, sin4, from;
  pid_t pid = 0;
  char buf[1024];
  fd_set rdfds;
  struct timeval timeout;
  socklen_t fromlen;
  struct msghdr msgdat;
  struct iovec iov;
  struct sockaddr_un sun1;
  char tmpsunpath[1024];
  sin1.sin_family = AF_INET;
  sin1.sin_port = htons((getpid() % 32768) + 11000);
  sin1.sin_addr.s_addr = INADDR_ANY;
  (void)strcpy(tmpsunpath, "udsockXXXXXX");
  s = mkstemp(tmpsunpath);
  close(s);
  unlink(tmpsunpath);
  sun1.sun_family = AF_UNIX;
  strcpy(sun1.sun_path, tmpsunpath);
  pid = start_server(&sin1, &sun1);
  sin2.sin_family = AF_INET;
  sin2.sin_port = htons((getpid() % 32768) + 10000);
  sin2.sin_addr.s_addr = INADDR_ANY;
  sin4.sin_family = 47;
  sin4.sin_port = 0;
  sin4.sin_addr.s_addr = htonl(0x0AFFFEFD);
  fromlen = sizeof(from);
  iov.iov_base = buf;
  iov.iov_len = sizeof(buf);
  msgdat.msg_name = &from;
  msgdat.msg_namelen = fromlen;
  msgdat.msg_iov = &iov;
  msgdat.msg_iovlen = 1;
  msgdat.msg_control = NULL;
  msgdat.msg_controllen = 0;
  msgdat.msg_flags = 0;
  fd_null = open("/dev/null", O_WRONLY);
  recvmsg(-1, &msgdat, 0);
  recvmsg(fd_null, &msgdat, MSG_DONTWAIT);
  s = socket(PF_INET, SOCK_STREAM, 0);
  connect(s, (struct sockaddr *)&sin1, sizeof(sin1));
  FD_ZERO(&rdfds);
  FD_SET(s, &rdfds);
  timeout.tv_sec = 2;
  timeout.tv_usec = 0;
  select(s + 1, &rdfds, 0, 0, &timeout);
  recvmsg(s, (struct msghdr *)-1, 0);
  close(s);
  s = socket(PF_INET, SOCK_STREAM, 0);
  connect(s, (struct sockaddr *)&sin1, sizeof(sin1));
  FD_ZERO(&rdfds);
  FD_SET(s, &rdfds);
  timeout.tv_sec = 2;
  timeout.tv_usec = 0;
  select(s + 1, &rdfds, 0, 0, &timeout);
  recvmsg(s, &msgdat, -1);
  close(s);
  s = socket(PF_UNIX, SOCK_STREAM, 0);
  connect(s, (struct sockaddr *)&sun1, sizeof(sun1));
  write(s, "R", 1);
  FD_ZERO(&rdfds);
  FD_SET(s, &rdfds);
  timeout.tv_sec = 2;
  timeout.tv_usec = 0;
  select(s + 1, &rdfds, 0, 0, &timeout);
  recvmsg(s, &msgdat, MSG_DONTWAIT);
  close(s);
  close(fd_null);
  if (pid > 0)
    (void)kill(pid, SIGKILL);
  (void)unlink(tmpsunpath);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8f0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x78(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    $0x8000,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x2af8,%edi
call   1070 <htons@plt>
mov    %rax,-0x18(%rbp)
mov    0x2d72(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    -0x8f0(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x8f0(%rbp),%rdi
call   10d0 <mkstemp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
lea    -0x8f0(%rbp),%rdi
call   1030 <unlink@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4e8(%rbp)
mov    -0x4f0(%rbp),%rdi
lea    -0x8f0(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x28(%rbp),%rdi
lea    -0x4f0(%rbp),%rsi
call   1120 <start_server@plt>
mov    %rax,-0x78(%rbp)
mov    0x2d08(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    $0x8000,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x2710,%edi
call   1070 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    0x2ccb(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movl   $0x2f,-0x58(%rbp)
movq   $0x0,-0x48(%rbp)
mov    $0xafffefd,%edi
call   1080 <htonl@plt>
mov    %rax,-0x50(%rbp)
movl   $0x18,-0x49c(%rbp)
lea    -0x480(%rbp),%rax
mov    %rax,-0x4e0(%rbp)
movl   $0x400,-0x4d8(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x4a8(%rbp)
mov    -0x49c(%rbp),%eax
mov    %eax,-0x4d0(%rbp)
lea    -0x4e0(%rbp),%rax
mov    %rax,-0x4b0(%rbp)
movl   $0x1,-0x4cc(%rbp)
movq   $0x0,-0x4b8(%rbp)
movq   $0x0,-0x4c0(%rbp)
movq   $0x0,-0x4c8(%rbp)
mov    0x2bf6(%rip),%rax
mov    (%rax),%esi
lea    0xc62(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0xc(%rbp)
mov    $0xffffffff,%edi
lea    -0x4d0(%rbp),%rsi
xor    %edx,%edx
call   10e0 <recvmsg@plt>
mov    -0xc(%rbp),%edi
mov    0x2be0(%rip),%rax
mov    (%rax),%edx
lea    -0x4d0(%rbp),%rsi
call   10e0 <recvmsg@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edi
mov    0x2bd2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x18,%edx
call   1100 <connect@plt>
lea    -0x484(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x484(%rbp),%rsi
call   1110 <FD_SET@plt>
movl   $0x2,-0x498(%rbp)
movq   $0x0,-0x490(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
lea    -0x484(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x498(%rbp),%r8
mov    %ecx,%edx
call   10c0 <select@plt>
mov    -0x8(%rbp),%edi
mov    $0xffffffffffffffff,%rsi
xor    %edx,%edx
call   10e0 <recvmsg@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    0x2b40(%rip),%rax
mov    (%rax),%edi
mov    0x2b3f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x18,%edx
call   1100 <connect@plt>
lea    -0x484(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x484(%rbp),%rsi
call   1110 <FD_SET@plt>
movl   $0x2,-0x498(%rbp)
movq   $0x0,-0x490(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
lea    -0x484(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x498(%rbp),%r8
mov    %ecx,%edx
call   10c0 <select@plt>
mov    -0x8(%rbp),%edi
lea    -0x4d0(%rbp),%rsi
mov    $0xffffffff,%edx
call   10e0 <recvmsg@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
mov    0x2aa9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x4f0(%rbp),%rsi
mov    $0x10,%edx
call   1100 <connect@plt>
mov    -0x8(%rbp),%edi
lea    0xad6(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
lea    -0x484(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x8(%rbp),%edi
lea    -0x484(%rbp),%rsi
call   1110 <FD_SET@plt>
movl   $0x2,-0x498(%rbp)
movq   $0x0,-0x490(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
lea    -0x484(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x498(%rbp),%r8
mov    %ecx,%edx
call   10c0 <select@plt>
mov    -0x8(%rbp),%edi
mov    0x2a0e(%rip),%rax
mov    (%rax),%edx
lea    -0x4d0(%rbp),%rsi
call   10e0 <recvmsg@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    -0xc(%rbp),%edi
call   1090 <close@plt>
cmpq   $0x0,-0x78(%rbp)
jle    15dd <main+0x3cd>
mov    -0x78(%rbp),%rdi
mov    0x29d2(%rip),%rax
mov    (%rax),%esi
call   10a0 <kill@plt>
lea    -0x8f0(%rbp),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x8f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8a8,%rsp
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0x7fff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff8000,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x2af8,%edi
call   1070 <htons@plt>
mov    %rax,0x30(%rsp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x28(%rsp)
lea    0xd8f(%rip),%rsi
lea    0xa0(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   10d0 <mkstemp@plt>
mov    %eax,%edi
call   1090 <close@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0x20(%rsp),%r14
lea    0x38(%rsp),%rsi
mov    %r14,%rdi
call   1120 <start_server@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0x7fff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff8000,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x2710,%edi
call   1070 <htons@plt>
mov    $0xafffefd,%edi
call   1080 <htonl@plt>
lea    0x4a0(%rsp),%rax
mov    %rax,0x48(%rsp)
movl   $0x400,0x50(%rsp)
lea    0x88(%rsp),%rax
mov    %rax,0x80(%rsp)
movabs $0x100000018,%rax
mov    %rax,0x58(%rsp)
lea    0x48(%rsp),%rax
mov    %rax,0x78(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x60(%rsp)
movq   $0x0,0x70(%rsp)
mov    0x2c4c(%rip),%rax
mov    (%rax),%esi
lea    0xcb8(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,%r15d
lea    0x58(%rsp),%rbx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   10e0 <recvmsg@plt>
mov    0x2c38(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
call   10e0 <recvmsg@plt>
mov    0x2c2c(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2c29(%rip),%r12
mov    (%r12),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   1100 <connect@plt>
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1110 <FD_SET@plt>
movl   $0x2,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x1(%rbp),%edi
mov    %rsp,%r14
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10c0 <select@plt>
mov    %ebp,%edi
mov    $0xffffffffffffffff,%rsi
xor    %edx,%edx
call   10e0 <recvmsg@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x0(%r13),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
lea    0x20(%rsp),%rsi
mov    $0x18,%edx
call   1100 <connect@plt>
mov    %rbx,%rdi
call   10b0 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1110 <FD_SET@plt>
movl   $0x2,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x1(%rbp),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10c0 <select@plt>
mov    %ebp,%edi
lea    0x58(%rsp),%rsi
mov    $0xffffffff,%edx
call   10e0 <recvmsg@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
lea    0x38(%rsp),%rsi
mov    $0x10,%edx
call   1100 <connect@plt>
lea    0xb75(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %rbx,%rdi
call   10b0 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1110 <FD_SET@plt>
movl   $0x2,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x1(%rbp),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10c0 <select@plt>
mov    0x2ac7(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
lea    0x58(%rsp),%rsi
call   10e0 <recvmsg@plt>
mov    %ebp,%edi
call   1090 <close@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
jle    151e <main+0x30e>
mov    0x2a91(%rip),%rax
mov    (%rax),%esi
call   10a0 <kill@plt>
lea    0xa0(%rsp),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x8a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.timeval = type { i32, i64 }
%struct.msghdr = type { i32, i32, i64, i64, i32*, %struct.iovec*, %struct.sockaddr_in* }
%struct.iovec = type { i8*, i32 }
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@INADDR_ANY = global i8* null
@.str = [13 x i8] c"udsockXXXXXX\00"
@AF_UNIX = global i32 0
@.str.1 = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
@MSG_DONTWAIT = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@PF_UNIX = global i32 0
@.str.2 = [2 x i8] c"R\00"
@SIGKILL = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca i64
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca %struct.timeval
%12 = alloca i32
%13 = alloca %struct.msghdr
%14 = alloca %struct.iovec
%15 = alloca %struct.sockaddr_un
%16 = alloca [1024 x i8]
store i32 0, i32* %1
store i64 0, i64* %8
%17 = load i8*, i8** @AF_INET
%18 = ptrtoint i8* %17 to i32
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %18, i32* %19
%20 = call i32 (...) @getpid()
%21 = srem i32 %20, 32768
%22 = add nsw i32 %21, 11000
%23 = call i8* @htons(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i8* %23, i8** %24
%25 = load i8*, i8** @INADDR_ANY
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i32 0, i32 0
store i8* %25, i8** %27
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%31 = call i32 @mkstemp(i8* %30)
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = call i32 @close(i32 %32)
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%35 = call i32 @unlink(i8* %34)
%36 = load i32, i32* @AF_UNIX
%37 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %15, i32 0, i32 1
store i32 %36, i32* %37
%38 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %15, i32 0, i32 0
%39 = load i8*, i8** %38
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = call i64 @start_server(%struct.sockaddr_in* %4, %struct.sockaddr_un* %15)
store i64 %42, i64* %8
%43 = load i8*, i8** @AF_INET
%44 = ptrtoint i8* %43 to i32
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i32 %44, i32* %45
%46 = call i32 (...) @getpid()
%47 = srem i32 %46, 32768
%48 = add nsw i32 %47, 10000
%49 = call i8* @htons(i32 %48)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i8* %49, i8** %50
%51 = load i8*, i8** @INADDR_ANY
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%53 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %52, i32 0, i32 0
store i8* %51, i8** %53
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i32 47, i32* %54
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* null, i8** %55
%56 = call i8* @htonl(i32 184549117)
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %57, i32 0, i32 0
store i8* %56, i8** %58
store i32 24, i32* %12
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%60 = getelementptr inbounds %struct.iovec, %struct.iovec* %14, i32 0, i32 0
store i8* %59, i8** %60
%61 = getelementptr inbounds %struct.iovec, %struct.iovec* %14, i32 0, i32 1
store i32 1024, i32* %61
%62 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 6
store %struct.sockaddr_in* %7, %struct.sockaddr_in** %62
%63 = load i32, i32* %12
%64 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 0
store i32 %63, i32* %64
%65 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 5
store %struct.iovec* %14, %struct.iovec** %65
%66 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 1
store i32 1, i32* %66
%67 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 4
store i32* null, i32** %67
%68 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 3
store i64 0, i64* %68
%69 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %13, i32 0, i32 2
store i64 0, i64* %69
%70 = load i32, i32* @O_WRONLY
%71 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %70)
store i32 %71, i32* %3
%72 = call i32 @recvmsg(i32 -1, %struct.msghdr* %13, i32 0)
%73 = load i32, i32* %3
%74 = load i32, i32* @MSG_DONTWAIT
%75 = call i32 @recvmsg(i32 %73, %struct.msghdr* %13, i32 %74)
%76 = load i32, i32* @PF_INET
%77 = load i32, i32* @SOCK_STREAM
%78 = call i32 @socket(i32 %76, i32 %77, i32 0)
store i32 %78, i32* %2
%79 = load i32, i32* %2
%80 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%81 = call i32 @connect(i32 %79, %struct.sockaddr* %80, i32 24)
%82 = call i32 @FD_ZERO(i32* %10)
%83 = load i32, i32* %2
%84 = call i32 @FD_SET(i32 %83, i32* %10)
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
store i32 2, i32* %85
%86 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
store i64 0, i64* %86
%87 = load i32, i32* %2
%88 = add nsw i32 %87, 1
%89 = call i32 @select(i32 %88, i32* %10, i32 0, i32 0, %struct.timeval* %11)
%90 = load i32, i32* %2
%91 = call i32 @recvmsg(i32 %90, %struct.msghdr* inttoptr (i64 -1 to %struct.msghdr*), i32 0)
%92 = load i32, i32* %2
%93 = call i32 @close(i32 %92)
%94 = load i32, i32* @PF_INET
%95 = load i32, i32* @SOCK_STREAM
%96 = call i32 @socket(i32 %94, i32 %95, i32 0)
store i32 %96, i32* %2
%97 = load i32, i32* %2
%98 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%99 = call i32 @connect(i32 %97, %struct.sockaddr* %98, i32 24)
%100 = call i32 @FD_ZERO(i32* %10)
%101 = load i32, i32* %2
%102 = call i32 @FD_SET(i32 %101, i32* %10)
%103 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
store i32 2, i32* %103
%104 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
store i64 0, i64* %104
%105 = load i32, i32* %2
%106 = add nsw i32 %105, 1
%107 = call i32 @select(i32 %106, i32* %10, i32 0, i32 0, %struct.timeval* %11)
%108 = load i32, i32* %2
%109 = call i32 @recvmsg(i32 %108, %struct.msghdr* %13, i32 -1)
%110 = load i32, i32* %2
%111 = call i32 @close(i32 %110)
%112 = load i32, i32* @PF_UNIX
%113 = load i32, i32* @SOCK_STREAM
%114 = call i32 @socket(i32 %112, i32 %113, i32 0)
store i32 %114, i32* %2
%115 = load i32, i32* %2
%116 = bitcast %struct.sockaddr_un* %15 to %struct.sockaddr*
%117 = call i32 @connect(i32 %115, %struct.sockaddr* %116, i32 16)
%118 = load i32, i32* %2
%119 = call i32 @write(i32 %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%120 = call i32 @FD_ZERO(i32* %10)
%121 = load i32, i32* %2
%122 = call i32 @FD_SET(i32 %121, i32* %10)
%123 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
store i32 2, i32* %123
%124 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
store i64 0, i64* %124
%125 = load i32, i32* %2
%126 = add nsw i32 %125, 1
%127 = call i32 @select(i32 %126, i32* %10, i32 0, i32 0, %struct.timeval* %11)
%128 = load i32, i32* %2
%129 = load i32, i32* @MSG_DONTWAIT
%130 = call i32 @recvmsg(i32 %128, %struct.msghdr* %13, i32 %129)
%131 = load i32, i32* %2
%132 = call i32 @close(i32 %131)
%133 = load i32, i32* %3
%134 = call i32 @close(i32 %133)
%135 = load i64, i64* %8
%136 = icmp sgt i64 %135, 0
br i1 %136, label %137, label %141
137: ; preds = %0
%138 = load i64, i64* %8
%139 = load i32, i32* @SIGKILL
%140 = call i32 @kill(i64 %138, i32 %139)
br label %141
141: ; preds = %137, %0
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%143 = call i32 @unlink(i8* %142)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.timeval = type { i32, i64 }
%struct.msghdr = type { i32, i32, i64, i64, i32*, %struct.iovec*, %struct.sockaddr_in* }
%struct.iovec = type { i8*, i32 }
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@INADDR_ANY = global i8* null
@.str = [13 x i8] c"udsockXXXXXX\00"
@AF_UNIX = global i32 0
@.str.1 = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
@MSG_DONTWAIT = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@PF_UNIX = global i32 0
@.str.2 = [2 x i8] c"R\00"
@SIGKILL = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca %struct.msghdr
%7 = alloca %struct.iovec
%8 = alloca %struct.sockaddr_un
%9 = alloca [1024 x i8]
%10 = bitcast %struct.sockaddr_in* %1 to i8*
%11 = bitcast %struct.sockaddr_in* %2 to i8*
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = bitcast i32* %4 to i8*
%14 = bitcast %struct.timeval* %5 to i8*
%15 = bitcast %struct.msghdr* %6 to i8*
%16 = bitcast %struct.iovec* %7 to i8*
%17 = bitcast %struct.sockaddr_un* %8 to i8*
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%19 = load i8*, i8** @AF_INET
%20 = ptrtoint i8* %19 to i64
%21 = trunc i64 %20 to i32
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %21, i32* %22
%23 = tail call i32 (...) @getpid()
%24 = srem i32 %23, 32768
%25 = add nsw i32 %24, 11000
%26 = tail call i8* @htons(i32 %25)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i8* %26, i8** %27
%28 = load i8*, i8** @INADDR_ANY
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i8* %28, i8** %29
%30 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @mkstemp(i8* %18)
%32 = call i32 @close(i32 %31)
%33 = call i32 @unlink(i8* %18)
%34 = load i32, i32* @AF_UNIX
%35 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %8, i64 0, i32 1
store i32 %34, i32* %35
%36 = call i32 @strcpy(i8* undef, i8* %18)
%37 = call i64 @start_server(%struct.sockaddr_in* %1, %struct.sockaddr_un* %8)
%38 = call i32 (...) @getpid()
%39 = srem i32 %38, 32768
%40 = add nsw i32 %39, 10000
%41 = call i8* @htons(i32 %40)
%42 = call i8* @htonl(i32 184549117)
%43 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i64 0, i32 0
store i8* %12, i8** %43
%44 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i64 0, i32 1
store i32 1024, i32* %44
%45 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 6
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %45
%46 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 0
store i32 24, i32* %46
%47 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 5
store %struct.iovec* %7, %struct.iovec** %47
%48 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 1
store i32 1, i32* %48
%49 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 2
%50 = bitcast i64* %49 to i8*
%51 = load i32, i32* @O_WRONLY
%52 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = call i32 @recvmsg(i32 -1, %struct.msghdr* %6, i32 0)
%54 = load i32, i32* @MSG_DONTWAIT
%55 = call i32 @recvmsg(i32 %52, %struct.msghdr* %6, i32 %54)
%56 = load i32, i32* @PF_INET
%57 = load i32, i32* @SOCK_STREAM
%58 = call i32 @socket(i32 %56, i32 %57, i32 0)
%59 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%60 = call i32 @connect(i32 %58, %struct.sockaddr* %59, i32 24)
%61 = call i32 @FD_ZERO(i32* %4)
%62 = call i32 @FD_SET(i32 %58, i32* %4)
%63 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 2, i32* %63
%64 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 0, i64* %64
%65 = add nsw i32 %58, 1
%66 = call i32 @select(i32 %65, i32* %4, i32 0, i32 0, %struct.timeval* %5)
%67 = call i32 @recvmsg(i32 %58, %struct.msghdr* inttoptr (i64 -1 to %struct.msghdr*), i32 0)
%68 = call i32 @close(i32 %58)
%69 = load i32, i32* @PF_INET
%70 = load i32, i32* @SOCK_STREAM
%71 = call i32 @socket(i32 %69, i32 %70, i32 0)
%72 = call i32 @connect(i32 %71, %struct.sockaddr* %59, i32 24)
%73 = call i32 @FD_ZERO(i32* %4)
%74 = call i32 @FD_SET(i32 %71, i32* %4)
store i32 2, i32* %63
store i64 0, i64* %64
%75 = add nsw i32 %71, 1
%76 = call i32 @select(i32 %75, i32* %4, i32 0, i32 0, %struct.timeval* %5)
%77 = call i32 @recvmsg(i32 %71, %struct.msghdr* %6, i32 -1)
%78 = call i32 @close(i32 %71)
%79 = load i32, i32* @PF_UNIX
%80 = load i32, i32* @SOCK_STREAM
%81 = call i32 @socket(i32 %79, i32 %80, i32 0)
%82 = bitcast %struct.sockaddr_un* %8 to %struct.sockaddr*
%83 = call i32 @connect(i32 %81, %struct.sockaddr* %82, i32 16)
%84 = call i32 @write(i32 %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%85 = call i32 @FD_ZERO(i32* %4)
%86 = call i32 @FD_SET(i32 %81, i32* %4)
store i32 2, i32* %63
store i64 0, i64* %64
%87 = add nsw i32 %81, 1
%88 = call i32 @select(i32 %87, i32* %4, i32 0, i32 0, %struct.timeval* %5)
%89 = load i32, i32* @MSG_DONTWAIT
%90 = call i32 @recvmsg(i32 %81, %struct.msghdr* %6, i32 %89)
%91 = call i32 @close(i32 %81)
%92 = call i32 @close(i32 %52)
%93 = icmp sgt i64 %37, 0
br i1 %93, label %94, label %97
94: ; preds = %0
%95 = load i32, i32* @SIGKILL
%96 = call i32 @kill(i64 %37, i32 %95)
br label %97
97: ; preds = %94, %0
%98 = call i32 @unlink(i8* %18)
ret i32 0
}