#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 {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
struct protoent {
  int dummy;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
scalar_t__ ENOENT;
int /*<<< orphan*/ PF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_ISUID;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int chmod(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ daemonize();
scalar_t__ errno;
int /*<<< orphan*/ exit(scalar_t__);
int handle_client(int, char *);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_un *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse_argv(int, char **, char **, int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_help_for_start_or_stop();
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
scalar_t__ unlink(char *);
int main(int argc, char **argv) {
  int socketfd;
  int connfd;
  struct protoent *tcp_protocol;
  struct sockaddr_un addr;
  socklen_t addrsize;
  int keepgoing;
  char *prefix;
  int shouldidaemonize = 1;
  if (!parse_argv(argc, argv, &prefix, &shouldidaemonize)) {
    print_help_for_start_or_stop();
  }
  if (shouldidaemonize) {
    daemonize();
  }
  if (unlink("/tmp/tsung_start_stop")) {
    if (errno != ENOENT) {
      perror("Couldn't unlink socket");
      exit(errno);
    }
  }
  socketfd = socket(PF_UNIX, SOCK_STREAM, 0);
  if (socketfd == -1) {
    perror("Socket creation failed");
    exit(errno);
  }
  memset(&addr, 0, sizeof(struct sockaddr_un));
  addr.sun_family = AF_UNIX;
  strcpy(addr.sun_path, "/tmp/tsung_start_stop");
  if (bind(socketfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) ==
      -1) {
    perror("bind failed");
    exit(errno);
  }
  if (chmod("/tmp/tsung_start_stop", S_ISUID | S_IRUSR | S_IWUSR | S_IXUSR |
                                         S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH |
                                         S_IWOTH | S_IXOTH) == -1) {
    perror("Chmod failed");
    exit(errno);
  }
  if (listen(socketfd, 255)) {
    perror("Listen failed");
    exit(errno);
  }
  keepgoing = 1;
  while (keepgoing) {
    addrsize = sizeof(struct sockaddr_un);
    connfd = accept(socketfd, (struct sockaddr *)&addr, &addrsize);
    if (connfd == -1) {
      perror("Accept failed");
      exit(errno);
    }
    keepgoing = handle_client(connfd, prefix);
    close(connfd);
  }
  close(socketfd);
  if (unlink("/tmp/tsung_start_stop")) {
    if (errno != ENOENT) {
      perror("Couldn't unlink socket");
      exit(errno);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
call   10d0 <parse_argv@plt>
cmp    $0x0,%eax
jne    1231 <main+0x41>
mov    $0x0,%al
call   10a0 <print_help_for_start_or_stop@plt>
cmpl   $0x0,-0x3c(%rbp)
je     1242 <main+0x52>
mov    $0x0,%al
call   1060 <daemonize@plt>
lea    0xdb7(%rip),%rdi
call   1040 <unlink@plt>
cmp    $0x0,%rax
je     1292 <main+0xa2>
mov    0x2d39(%rip),%rax
mov    (%rax),%rax
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%rax
je     128d <main+0x9d>
lea    0xd9d(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
jmp    1292 <main+0xa2>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12d3 <main+0xe3>
lea    0xd6e(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
lea    0xd07(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1333 <main+0x143>
lea    0xd25(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
mov    0x2c3d(%rip),%rax
or     (%rax),%esi
mov    0x2c6c(%rip),%rax
or     (%rax),%esi
mov    0x2c83(%rip),%rax
or     (%rax),%esi
mov    0x2c32(%rip),%rax
or     (%rax),%esi
mov    0x2c59(%rip),%rax
or     (%rax),%esi
mov    0x2c40(%rip),%rax
or     (%rax),%esi
mov    0x2c0f(%rip),%rax
or     (%rax),%esi
mov    0x2be6(%rip),%rax
or     (%rax),%esi
mov    0x2c55(%rip),%rax
or     (%rax),%esi
lea    0xc6c(%rip),%rdi
call   10b0 <chmod@plt>
cmp    $0xffffffff,%eax
jne    13bd <main+0x1cd>
lea    0xca7(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2be3(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0xff,%esi
call   1090 <listen@plt>
cmp    $0x0,%rax
je     13ef <main+0x1ff>
lea    0xc82(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bb1(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
movl   $0x1,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     145b <main+0x26b>
movl   $0x8,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    143f <main+0x24f>
lea    0xc40(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b61(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   1030 <handle_client@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
jmp    13f6 <main+0x206>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
lea    0xb96(%rip),%rdi
call   1040 <unlink@plt>
cmp    $0x0,%rax
je     14b3 <main+0x2c3>
mov    0x2b18(%rip),%rax
mov    (%rax),%rax
mov    0x2ae6(%rip),%rcx
cmp    (%rcx),%rax
je     14ae <main+0x2be>
lea    0xb7c(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2af2(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
jmp    14b3 <main+0x2c3>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0x1,0x4(%rsp)
lea    0x18(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   10d0 <parse_argv@plt>
test   %eax,%eax
jne    121e <main+0x2e>
xor    %eax,%eax
call   10a0 <print_help_for_start_or_stop@plt>
cmpl   $0x0,0x4(%rsp)
je     122c <main+0x3c>
xor    %eax,%eax
call   1060 <daemonize@plt>
lea    0xdcd(%rip),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
je     1257 <main+0x67>
mov    0x2d54(%rip),%rbx
mov    (%rbx),%rax
mov    0x2d22(%rip),%rcx
cmp    (%rcx),%rax
jne    13ef <main+0x1ff>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     1403 <main+0x213>
mov    %eax,%r14d
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x8(%rsp),%edi
lea    0xd58(%rip),%rsi
call   1050 <strcpy@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
je     140c <main+0x21c>
mov    0x2cfb(%rip),%rax
mov    0x2cac(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2cd9(%rip),%rax
or     (%rax),%esi
mov    0x2cf0(%rip),%rax
or     (%rax),%esi
mov    0x2c9f(%rip),%rax
or     (%rax),%esi
mov    0x2cc6(%rip),%rax
or     (%rax),%esi
mov    0x2cad(%rip),%rax
or     (%rax),%esi
mov    0x2c7c(%rip),%rax
or     (%rax),%esi
mov    0x2c53(%rip),%rax
or     (%rax),%esi
mov    0x2cc2(%rip),%rax
or     (%rax),%esi
lea    0xcd9(%rip),%rdi
call   10b0 <chmod@plt>
cmp    $0xffffffff,%eax
je     1415 <main+0x225>
mov    %r14d,%edi
mov    $0xff,%esi
call   1090 <listen@plt>
test   %rax,%rax
jne    141e <main+0x22e>
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movl   $0x8,0x14(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   10f0 <accept@plt>
cmp    $0xffffffff,%eax
je     13d4 <main+0x1e4>
mov    %eax,%ebx
mov    0x18(%rsp),%rsi
mov    %eax,%edi
call   1030 <handle_client@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1080 <close@plt>
test   %ebp,%ebp
jne    1360 <main+0x170>
mov    %r14d,%edi
call   1080 <close@plt>
lea    0xc5b(%rip),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
je     13c5 <main+0x1d5>
mov    0x2be2(%rip),%rbx
mov    (%rbx),%rax
mov    0x2bb0(%rip),%rcx
cmp    (%rcx),%rax
jne    13ef <main+0x1ff>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc90(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bb1(%rip),%rax
mov    (%rax),%rdi
call   1100 <exit@plt>
lea    0xc20(%rip),%rdi
call   10e0 <perror@plt>
mov    (%rbx),%rdi
call   1100 <exit@plt>
lea    0xc23(%rip),%rdi
jmp    13db <main+0x1eb>
lea    0xc31(%rip),%rdi
jmp    13db <main+0x1eb>
lea    0xc34(%rip),%rdi
jmp    13db <main+0x1eb>
lea    0xc38(%rip),%rdi
jmp    13db <main+0x1eb>

LLVM IR (-O0):
%struct.protoent = type { i32 }
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [22 x i8] c"/tmp/tsung_start_stop\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [23 x i8] c"Couldn't unlink socket\00"
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [23 x i8] c"Socket creation failed\00"
@AF_UNIX = global i32 0
@.str.3 = [12 x i8] c"bind failed\00"
@S_ISUID = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.4 = [13 x i8] c"Chmod failed\00"
@.str.5 = [14 x i8] c"Listen failed\00"
@.str.6 = [14 x i8] c"Accept failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.protoent*
%9 = alloca %struct.sockaddr_un
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %13
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @parse_argv(i32 %14, i8** %15, i8** %12, i32* %13)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %2
%19 = call i32 (...) @print_help_for_start_or_stop()
br label %20
20: ; preds = %18, %2
%21 = load i32, i32* %13
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (...) @daemonize()
br label %25
25: ; preds = %23, %20
%26 = call i64 @unlink(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i64, i64* @errno
%30 = load i64, i64* @ENOENT
%31 = icmp ne i64 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%34 = load i64, i64* @errno
%35 = call i32 @exit(i64 %34)
unreachable
36: ; preds = %28
br label %37
37: ; preds = %36, %25
%38 = load i32, i32* @PF_UNIX
%39 = load i32, i32* @SOCK_STREAM
%40 = call i32 @socket(i32 %38, i32 %39, i32 0)
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %47
43: ; preds = %37
%44 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%45 = load i64, i64* @errno
%46 = call i32 @exit(i64 %45)
unreachable
47: ; preds = %37
%48 = call i32 @memset(%struct.sockaddr_un* %9, i32 0, i32 8)
%49 = load i32, i32* @AF_UNIX
%50 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 1
store i32 %49, i32* %50
%51 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %9, i32 0, i32 0
%52 = load i32, i32* %51
%53 = call i32 @strcpy(i32 %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%54 = load i32, i32* %6
%55 = bitcast %struct.sockaddr_un* %9 to %struct.sockaddr*
%56 = call i32 @bind(i32 %54, %struct.sockaddr* %55, i32 8)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %62
58: ; preds = %47
%59 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%60 = load i64, i64* @errno
%61 = call i32 @exit(i64 %60)
unreachable
62: ; preds = %47
%63 = load i32, i32* @S_ISUID
%64 = load i32, i32* @S_IRUSR
%65 = or i32 %63, %64
%66 = load i32, i32* @S_IWUSR
%67 = or i32 %65, %66
%68 = load i32, i32* @S_IXUSR
%69 = or i32 %67, %68
%70 = load i32, i32* @S_IRGRP
%71 = or i32 %69, %70
%72 = load i32, i32* @S_IWGRP
%73 = or i32 %71, %72
%74 = load i32, i32* @S_IXGRP
%75 = or i32 %73, %74
%76 = load i32, i32* @S_IROTH
%77 = or i32 %75, %76
%78 = load i32, i32* @S_IWOTH
%79 = or i32 %77, %78
%80 = load i32, i32* @S_IXOTH
%81 = or i32 %79, %80
%82 = call i32 @chmod(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %81)
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %88
84: ; preds = %62
%85 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%86 = load i64, i64* @errno
%87 = call i32 @exit(i64 %86)
unreachable
88: ; preds = %62
%89 = load i32, i32* %6
%90 = call i64 @listen(i32 %89, i32 255)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %88
%93 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%94 = load i64, i64* @errno
%95 = call i32 @exit(i64 %94)
unreachable
96: ; preds = %88
store i32 1, i32* %11
br label %97
97: ; preds = %110, %96
%98 = load i32, i32* %11
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %116
100: ; preds = %97
store i32 8, i32* %10
%101 = load i32, i32* %6
%102 = bitcast %struct.sockaddr_un* %9 to %struct.sockaddr*
%103 = call i32 @accept(i32 %101, %struct.sockaddr* %102, i32* %10)
store i32 %103, i32* %7
%104 = load i32, i32* %7
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %110
106: ; preds = %100
%107 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%108 = load i64, i64* @errno
%109 = call i32 @exit(i64 %108)
unreachable
110: ; preds = %100
%111 = load i32, i32* %7
%112 = load i8*, i8** %12
%113 = call i32 @handle_client(i32 %111, i8* %112)
store i32 %113, i32* %11
%114 = load i32, i32* %7
%115 = call i32 @close(i32 %114)
br label %97
116: ; preds = %97
%117 = load i32, i32* %6
%118 = call i32 @close(i32 %117)
%119 = call i64 @unlink(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %130
121: ; preds = %116
%122 = load i64, i64* @errno
%123 = load i64, i64* @ENOENT
%124 = icmp ne i64 %122, %123
br i1 %124, label %125, label %129
125: ; preds = %121
%126 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%127 = load i64, i64* @errno
%128 = call i32 @exit(i64 %127)
unreachable
129: ; preds = %121
br label %130
130: ; preds = %129, %116
%131 = load i32, i32* %3
ret i32 %131
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.protoent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [22 x i8] c"/tmp/tsung_start_stop\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [23 x i8] c"Couldn't unlink socket\00"
@PF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [23 x i8] c"Socket creation failed\00"
@AF_UNIX = global i32 0
@.str.3 = [12 x i8] c"bind failed\00"
@S_ISUID = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.4 = [13 x i8] c"Chmod failed\00"
@.str.5 = [14 x i8] c"Listen failed\00"
@.str.6 = [14 x i8] c"Accept failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = bitcast %struct.sockaddr_un* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%11 = call i32 @parse_argv(i32 %0, i8** %1, i8** %5, i32* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @print_help_for_start_or_stop()
br label %15
15: ; preds = %13, %2
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 (...) @daemonize()
br label %20
20: ; preds = %18, %15
%21 = call i64 @unlink(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %20
%24 = load i64, i64* @errno
%25 = load i64, i64* @ENOENT
%26 = icmp eq i64 %24, %25
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%29 = load i64, i64* @errno
%30 = call i32 @exit(i64 %29)
unreachable
31: ; preds = %23, %20
%32 = load i32, i32* @PF_UNIX
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %40
36: ; preds = %31
%37 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%38 = load i64, i64* @errno
%39 = call i32 @exit(i64 %38)
unreachable
40: ; preds = %31
%41 = call i32 @memset(%struct.sockaddr_un* %3, i32 0, i32 8)
%42 = load i32, i32* @AF_UNIX
%43 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %42, i32* %43
%44 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 @strcpy(i32 %45, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%47 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%48 = call i32 @bind(i32 %34, %struct.sockaddr* %47, i32 8)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %54
50: ; preds = %40
%51 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%52 = load i64, i64* @errno
%53 = call i32 @exit(i64 %52)
unreachable
54: ; preds = %40
%55 = load i32, i32* @S_ISUID
%56 = load i32, i32* @S_IRUSR
%57 = or i32 %56, %55
%58 = load i32, i32* @S_IWUSR
%59 = or i32 %57, %58
%60 = load i32, i32* @S_IXUSR
%61 = or i32 %59, %60
%62 = load i32, i32* @S_IRGRP
%63 = or i32 %61, %62
%64 = load i32, i32* @S_IWGRP
%65 = or i32 %63, %64
%66 = load i32, i32* @S_IXGRP
%67 = or i32 %65, %66
%68 = load i32, i32* @S_IROTH
%69 = or i32 %67, %68
%70 = load i32, i32* @S_IWOTH
%71 = or i32 %69, %70
%72 = load i32, i32* @S_IXOTH
%73 = or i32 %71, %72
%74 = call i32 @chmod(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %73)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %80
76: ; preds = %54
%77 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%78 = load i64, i64* @errno
%79 = call i32 @exit(i64 %78)
unreachable
80: ; preds = %54
%81 = call i64 @listen(i32 %34, i32 255)
%82 = icmp eq i64 %81, 0
br i1 %82, label %87, label %83
83: ; preds = %80
%84 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%85 = load i64, i64* @errno
%86 = call i32 @exit(i64 %85)
unreachable
87: ; preds = %80, %94
store i32 8, i32* %4
%88 = call i32 @accept(i32 %34, %struct.sockaddr* %47, i32* %4)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%92 = load i64, i64* @errno
%93 = call i32 @exit(i64 %92)
unreachable
94: ; preds = %87
%95 = load i8*, i8** %5
%96 = call i32 @handle_client(i32 %88, i8* %95)
%97 = call i32 @close(i32 %88)
%98 = icmp eq i32 %96, 0
br i1 %98, label %99, label %87
99: ; preds = %94
%100 = call i32 @close(i32 %34)
%101 = call i64 @unlink(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%102 = icmp eq i64 %101, 0
br i1 %102, label %111, label %103
103: ; preds = %99
%104 = load i64, i64* @errno
%105 = load i64, i64* @ENOENT
%106 = icmp eq i64 %104, %105
br i1 %106, label %111, label %107
107: ; preds = %103
%108 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%109 = load i64, i64* @errno
%110 = call i32 @exit(i64 %109)
unreachable
111: ; preds = %103, %99
ret i32 0
}