#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_un {
  char *member_1;
  int /*<<< orphan*/ member_0;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ handle_client(int);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ unlink(char *);
int main(int argc, char **argv) {
  (void)argc;
  (void)argv;
  fprintf(stderr, "Hello world from syslogd!\n");
  unlink("/dev/log");
  int master = socket(AF_UNIX, SOCK_STREAM, 0);
  printf("Started syslogd with socket %d\n", master);
  struct sockaddr_un addr = {AF_UNIX, "/dev/log"};
  if (bind(master, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
    perror("bind");
    exit(1);
  }
  if (listen(master, 20) == -1) {
    perror("listen");
    exit(1);
  }
  fd_set active_fds, read_fds, err_fds;
  FD_ZERO(&active_fds);
  FD_SET(master, &active_fds);
  while (true) {
    read_fds = active_fds;
    err_fds = active_fds;
    select(FD_SETSIZE, &read_fds, NULL, &err_fds, NULL);
    for (int i = 0; i < FD_SETSIZE; i++) {
      if (FD_ISSET(i, &read_fds)) {
        if (i == master) {
          struct sockaddr_un cliaddr;
          socklen_t len;
          int client;
          client = accept(master, (struct sockaddr *)&cliaddr, &len);
          if (client > 0) {
            FD_SET(client, &active_fds);
          } else {
            perror("accept");
          }
          int flags;
          if ((flags = fcntl(client, F_GETFL)) < 0) {
            perror("fcntl");
            FD_CLR(client, &active_fds);
          } else {
            if (fcntl(client, F_SETFL, flags | O_NONBLOCK) < 0) {
              perror("fcntl");
              FD_CLR(client, &active_fds);
            }
          }
        } else {
          if (handle_client(i) < 0) {
            close(i);
            FD_CLR(i, &active_fds);
          }
        }
      } else if (FD_ISSET(i, &err_fds)) {
        if (i == master) {
          fprintf(stderr, "syslogd: found error condition on /dev/log\n");
        } else {
          fprintf(stderr, "closing client %d due to error\n", i);
          close(i);
          FD_CLR(i, &active_fds);
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xdd7(%rip),%rdi
call   1040 <unlink@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdb5(%rip),%rdi
call   1070 <printf@plt>
mov    0x2d65(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    0xd92(%rip),%rax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12bc <main+0xac>
lea    0xd97(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x14,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12e8 <main+0xd8>
lea    0xd70(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x2c(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x34(%rbp),%rcx
mov    %r8,%rdx
call   10b0 <select@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    0x2c80(%rip),%rcx
cmp    (%rcx),%eax
jge    14db <main+0x2cb>
mov    -0x38(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1452 <main+0x242>
mov    -0x38(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1422 <main+0x212>
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jle    1390 <main+0x180>
mov    -0x50(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1120 <FD_SET@plt>
jmp    139c <main+0x18c>
lea    0xcb9(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x50(%rbp),%edi
mov    0x2c0a(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1050 <fcntl@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
jge    13d8 <main+0x1c8>
lea    0xc95(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x50(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1100 <FD_CLR@plt>
jmp    141d <main+0x20d>
mov    -0x50(%rbp),%edi
mov    0x2be6(%rip),%rax
mov    (%rax),%esi
mov    -0x54(%rbp),%edx
mov    0x2bfa(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1050 <fcntl@plt>
cmp    $0x0,%eax
jge    1418 <main+0x208>
lea    0xc50(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x50(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1100 <FD_CLR@plt>
jmp    141d <main+0x20d>
jmp    144d <main+0x23d>
mov    -0x38(%rbp),%edi
call   1030 <handle_client@plt>
cmp    $0x0,%rax
jge    1448 <main+0x238>
mov    -0x38(%rbp),%edi
call   1080 <close@plt>
mov    -0x38(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1100 <FD_CLR@plt>
jmp    144d <main+0x23d>
jmp    14c8 <main+0x2b8>
mov    -0x38(%rbp),%edi
lea    -0x34(%rbp),%rsi
call   1060 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14c3 <main+0x2b3>
mov    -0x38(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1490 <main+0x280>
mov    0x2b55(%rip),%rax
mov    (%rax),%edi
lea    0xbd9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    14be <main+0x2ae>
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%edx
lea    0xbe6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x38(%rbp),%edi
call   1080 <close@plt>
mov    -0x38(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1100 <FD_CLR@plt>
jmp    14c3 <main+0x2b3>
jmp    14c8 <main+0x2b8>
jmp    14cd <main+0x2bd>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    132e <main+0x11e>
jmp    12fd <main+0xed>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xddf(%rip),%r14
mov    %r14,%rdi
call   1040 <unlink@plt>
mov    0x2d95(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%ebx
lea    0xdbd(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
movslq 0x0(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    %r14d,0x20(%rsp)
lea    0x18(%rsp),%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
je     143a <main+0x22a>
mov    %ebx,%edi
mov    $0x14,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
je     1443 <main+0x233>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   10a0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1120 <FD_SET@plt>
mov    0x2cef(%rip),%r12
mov    (%r12),%edi
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    %eax,0x8(%rsp)
mov    %r15,%rsi
xor    %edx,%edx
lea    0x8(%rsp),%rcx
xor    %r8d,%r8d
call   10b0 <select@plt>
mov    (%r12),%edi
test   %edi,%edi
jle    12e0 <main+0xd0>
xor    %r13d,%r13d
jmp    132d <main+0x11d>
lea    0xd4b(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
nopl   0x0(%rax)
add    $0x1,%r13d
mov    (%r12),%edi
cmp    %edi,%r13d
jge    12e0 <main+0xd0>
mov    %r13d,%edi
mov    %r15,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     13c0 <main+0x1b0>
cmp    %r13d,%ebx
jne    1400 <main+0x1f0>
mov    %ebx,%edi
lea    0x28(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   10f0 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1429 <main+0x219>
mov    %ebp,%edi
mov    %r14,%rsi
call   1120 <FD_SET@plt>
mov    0x2c3a(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <fcntl@plt>
test   %eax,%eax
js     13aa <main+0x19a>
mov    0x2c3c(%rip),%rcx
mov    (%rcx),%esi
mov    0x2c53(%rip),%rcx
or     (%rcx),%eax
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fcntl@plt>
test   %eax,%eax
jns    1320 <main+0x110>
lea    0xca6(%rip),%rdi
call   10e0 <perror@plt>
mov    %ebp,%edi
jmp    141c <main+0x20c>
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
lea    0x8(%rsp),%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1320 <main+0x110>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
cmp    %r13d,%ebx
je     130b <main+0xfb>
lea    0xc9a(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1411 <main+0x201>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1030 <handle_client@plt>
test   %rax,%rax
jns    1320 <main+0x110>
mov    %r13d,%edi
call   1080 <close@plt>
mov    %r13d,%edi
mov    %r14,%rsi
call   1100 <FD_CLR@plt>
jmp    1320 <main+0x110>
lea    0xc20(%rip),%rdi
call   10e0 <perror@plt>
jmp    136f <main+0x15f>
lea    0xc03(%rip),%rdi
jmp    144a <main+0x23a>
lea    0xbff(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [27 x i8] c"Hello world from syslogd!\0A\00"
@.str.1 = [9 x i8] c"/dev/log\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [32 x i8] c"Started syslogd with socket %d\0A\00"
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [7 x i8] c"listen\00"
@FD_SETSIZE = global i32 0
@.str.5 = [7 x i8] c"accept\00"
@F_GETFL = global i32 0
@.str.6 = [6 x i8] c"fcntl\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.7 = [44 x i8] c"syslogd: found error condition on /dev/log\0A\00"
@.str.8 = [32 x i8] c"closing client %d due to error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_un
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sockaddr_un
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @AF_UNIX
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%27 = load i32, i32* @AF_UNIX
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %26
%30 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 1
store i32 ptrtoint ([9 x i8]* @.str.1 to i32), i32* %30
%31 = load i32, i32* %6
%32 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%33 = call i32 @bind(i32 %31, %struct.sockaddr* %32, i32 16)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %38
35: ; preds = %2
%36 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %2
%39 = load i32, i32* %6
%40 = call i32 @listen(i32 %39, i32 20)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %38
%46 = call i32 @FD_ZERO(i32* %8)
%47 = load i32, i32* %6
%48 = call i32 @FD_SET(i32 %47, i32* %8)
br label %49
49: ; preds = %45, %136
%50 = load i32, i32* %8
store i32 %50, i32* %9
%51 = load i32, i32* %8
store i32 %51, i32* %10
%52 = load i32, i32* @FD_SETSIZE
%53 = call i32 @select(i32 %52, i32* %9, i32* null, i32* %10, i32* null)
store i32 0, i32* %11
br label %54
54: ; preds = %133, %49
%55 = load i32, i32* %11
%56 = load i32, i32* @FD_SETSIZE
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %136
58: ; preds = %54
%59 = load i32, i32* %11
%60 = call i64 @FD_ISSET(i32 %59, i32* %9)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %111
62: ; preds = %58
%63 = load i32, i32* %11
%64 = load i32, i32* %6
%65 = icmp eq i32 %63, %64
br i1 %65, label %66, label %100
66: ; preds = %62
%67 = load i32, i32* %6
%68 = bitcast %struct.sockaddr_un* %12 to %struct.sockaddr*
%69 = call i32 @accept(i32 %67, %struct.sockaddr* %68, i32* %13)
store i32 %69, i32* %14
%70 = load i32, i32* %14
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %66
%73 = load i32, i32* %14
%74 = call i32 @FD_SET(i32 %73, i32* %8)
br label %77
75: ; preds = %66
%76 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %77
77: ; preds = %75, %72
%78 = load i32, i32* %14
%79 = load i32, i32* @F_GETFL
%80 = call i32 (i32, i32, ...) @fcntl(i32 %78, i32 %79)
store i32 %80, i32* %15
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %77
%83 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%84 = load i32, i32* %14
%85 = call i32 @FD_CLR(i32 %84, i32* %8)
br label %99
86: ; preds = %77
%87 = load i32, i32* %14
%88 = load i32, i32* @F_SETFL
%89 = load i32, i32* %15
%90 = load i32, i32* @O_NONBLOCK
%91 = or i32 %89, %90
%92 = call i32 (i32, i32, ...) @fcntl(i32 %87, i32 %88, i32 %91)
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %98
94: ; preds = %86
%95 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%96 = load i32, i32* %14
%97 = call i32 @FD_CLR(i32 %96, i32* %8)
br label %98
98: ; preds = %94, %86
br label %99
99: ; preds = %98, %82
br label %110
100: ; preds = %62
%101 = load i32, i32* %11
%102 = call i64 @handle_client(i32 %101)
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %109
104: ; preds = %100
%105 = load i32, i32* %11
%106 = call i32 @close(i32 %105)
%107 = load i32, i32* %11
%108 = call i32 @FD_CLR(i32 %107, i32* %8)
br label %109
109: ; preds = %104, %100
br label %110
110: ; preds = %109, %99
br label %132
111: ; preds = %58
%112 = load i32, i32* %11
%113 = call i64 @FD_ISSET(i32 %112, i32* %10)
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %131
115: ; preds = %111
%116 = load i32, i32* %11
%117 = load i32, i32* %6
%118 = icmp eq i32 %116, %117
br i1 %118, label %119, label %122
119: ; preds = %115
%120 = load i32, i32* @stderr
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %130
122: ; preds = %115
%123 = load i32, i32* @stderr
%124 = load i32, i32* %11
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %11
%127 = call i32 @close(i32 %126)
%128 = load i32, i32* %11
%129 = call i32 @FD_CLR(i32 %128, i32* %8)
br label %130
130: ; preds = %122, %119
br label %131
131: ; preds = %130, %111
br label %132
132: ; preds = %131, %110
br label %133
133: ; preds = %132
%134 = load i32, i32* %11
%135 = add nsw i32 %134, 1
store i32 %135, i32* %11
br label %54
136: ; preds = %54
br label %49
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [27 x i8] c"Hello world from syslogd!\0A\00"
@.str.1 = [9 x i8] c"/dev/log\00"
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [32 x i8] c"Started syslogd with socket %d\0A\00"
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [7 x i8] c"listen\00"
@FD_SETSIZE = global i32 0
@.str.5 = [7 x i8] c"accept\00"
@F_GETFL = global i32 0
@.str.6 = [6 x i8] c"fcntl\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.7 = [44 x i8] c"syslogd: found error condition on /dev/log\0A\00"
@.str.8 = [32 x i8] c"closing client %d due to error\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr_un
%8 = alloca i32
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @AF_UNIX
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = bitcast %struct.sockaddr_un* %3 to i8*
%17 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 0
%18 = load i32, i32* @AF_UNIX
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %17
%21 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 ptrtoint ([9 x i8]* @.str.1 to i32), i32* %21
%22 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%23 = call i32 @bind(i32 %14, %struct.sockaddr* %22, i32 16)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = call i32 @listen(i32 %14, i32 20)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %28
%35 = bitcast i32* %4 to i8*
%36 = bitcast i32* %5 to i8*
%37 = bitcast i32* %6 to i8*
%38 = call i32 @FD_ZERO(i32* %4)
%39 = call i32 @FD_SET(i32 %14, i32* %4)
%40 = bitcast %struct.sockaddr_un* %7 to i8*
%41 = bitcast i32* %8 to i8*
%42 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%43 = load i32, i32* @FD_SETSIZE
br label %44
44: ; preds = %50, %34
%45 = phi i32 [ %43, %34 ], [ %51, %50 ]
%46 = load i32, i32* %4
store i32 %46, i32* %5
store i32 %46, i32* %6
%47 = call i32 @select(i32 %45, i32* %5, i32* null, i32* %6, i32* null)
%48 = load i32, i32* @FD_SETSIZE
%49 = icmp sgt i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %97, %44
%51 = phi i32 [ %48, %44 ], [ %99, %97 ]
br label %44
52: ; preds = %44, %97
%53 = phi i32 [ %98, %97 ], [ 0, %44 ]
%54 = call i64 @FD_ISSET(i32 %53, i32* %5)
%55 = icmp eq i64 %54, 0
br i1 %55, label %85, label %56
56: ; preds = %52
%57 = icmp eq i32 %53, %14
br i1 %57, label %58, label %79
58: ; preds = %56
%59 = call i32 @accept(i32 %14, %struct.sockaddr* %42, i32* %8)
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @FD_SET(i32 %59, i32* %4)
br label %65
63: ; preds = %58
%64 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
%66 = load i32, i32* @F_GETFL
%67 = call i32 (i32, i32, ...) @fcntl(i32 %59, i32 %66)
%68 = icmp slt i32 %67, 0
br i1 %68, label %75, label %69
69: ; preds = %65
%70 = load i32, i32* @F_SETFL
%71 = load i32, i32* @O_NONBLOCK
%72 = or i32 %71, %67
%73 = call i32 (i32, i32, ...) @fcntl(i32 %59, i32 %70, i32 %72)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %69, %65
%76 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%77 = call i32 @FD_CLR(i32 %59, i32* %4)
br label %78
78: ; preds = %75, %69
br label %97
79: ; preds = %56
%80 = call i64 @handle_client(i32 %53)
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %97
82: ; preds = %79
%83 = call i32 @close(i32 %53)
%84 = call i32 @FD_CLR(i32 %53, i32* %4)
br label %97
85: ; preds = %52
%86 = call i64 @FD_ISSET(i32 %53, i32* %6)
%87 = icmp eq i64 %86, 0
br i1 %87, label %97, label %88
88: ; preds = %85
%89 = icmp eq i32 %53, %14
%90 = load i32, i32* @stderr
br i1 %89, label %91, label %93
91: ; preds = %88
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
br label %97
93: ; preds = %88
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %53)
%95 = call i32 @close(i32 %53)
%96 = call i32 @FD_CLR(i32 %53, i32* %4)
br label %97
97: ; preds = %79, %82, %78, %91, %93, %85
%98 = add nuw nsw i32 %53, 1
%99 = load i32, i32* @FD_SETSIZE
%100 = icmp slt i32 %98, %99
br i1 %100, label %52, label %50
}