#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;
};
typedef int /*<<< orphan*/ serverAddr;
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int write(int, char *, int);
int main(void) {
  int serverSocket = -1, socketToClient = -1;
  struct sockaddr_un serverAddr;
  pid_t c1 = -1, c2 = -1;
  int r;
  char request[10];
  char chr;
  int delay = 0;
  int i = 0;
  if ((serverSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
    perror("Server: Error in creating a socket ");
    exit(EXIT_FAILURE);
  }
  unlink("server.sock");
  serverAddr.sun_family = AF_UNIX;
  strcpy(serverAddr.sun_path, "server.sock");
  if (bind(serverSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) ==
      -1) {
    perror("Server: Error in binding the socket");
    exit(EXIT_FAILURE);
  }
  if (listen(serverSocket, 5) == -1) {
    perror("Server: Error in listening a socket");
    exit(EXIT_FAILURE);
  }
  while (1) {
    if ((socketToClient = accept(serverSocket, NULL, 0)) == -1) {
      perror("Server: Error in accepting a connection");
      exit(EXIT_FAILURE);
    }
    c1 = fork();
    if (c1 < 0) {
      perror("Server: fork");
      exit(EXIT_FAILURE);
    }
    if (c1 == 0) {
      c2 = fork();
      if (c2 < 0) {
        perror("Server: fork");
        exit(EXIT_FAILURE);
      } else if (c2 > 0) {
        exit(EXIT_SUCCESS);
      } else {
        r = read(socketToClient, request, 5);
        if (r > 0) {
          request[r] = '\0';
          printf("Server: %s\n", request);
          printf("socket to client fd: %d\n", socketToClient);
          chr = request[0];
          delay = atoi(&request[2]);
          for (i = 0; i < 10; i++) {
            if (write(socketToClient, &chr, 1) == -1)
              perror("Server: Error in write");
            sleep(delay);
          }
          printf("Closing socket to client fd: %d\n", socketToClient);
          close(socketToClient);
        } else if (r < 0)
          perror("Server: Error in read");
        else
          printf("Server: Number of bytes read was zero %d\n", r);
        exit(EXIT_SUCCESS);
      }
    }
    close(socketToClient);
    wait(NULL);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movq   $0xffffffffffffffff,-0x20(%rbp)
ff
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    127a <main+0x7a>
lea    0xd99(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xda3(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
lea    0xd88(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12d5 <main+0xd5>
lea    0xd6e(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   1090 <listen@plt>
cmp    $0xffffffff,%eax
jne    1305 <main+0x105>
lea    0xd62(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    130a <main+0x10a>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10c0 <accept@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    133e <main+0x13e>
lea    0xd4d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    136e <main+0x16e>
lea    0xd45(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    14cc <main+0x2cc>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    13a9 <main+0x1a9>
lea    0xd0a(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x28(%rbp)
jle    13c2 <main+0x1c2>
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x36(%rbp),%rsi
mov    $0x5,%edx
call   1080 <read@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    148d <main+0x28d>
movslq -0x2c(%rbp),%rax
movb   $0x0,-0x36(%rbp,%rax,1)
lea    -0x36(%rbp),%rsi
lea    0xcb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x36(%rbp),%al
mov    %al,-0x37(%rbp)
lea    -0x36(%rbp),%rdi
add    $0x2,%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0xa,-0x40(%rbp)
jge    146f <main+0x26f>
mov    -0xc(%rbp),%edi
lea    -0x37(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1459 <main+0x259>
lea    0xc65(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x3c(%rbp),%edi
call   10f0 <sleep@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1429 <main+0x229>
mov    -0xc(%rbp),%esi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
jmp    14be <main+0x2be>
cmpl   $0x0,-0x2c(%rbp)
jge    14a8 <main+0x2a8>
lea    0xc53(%rip),%rdi
call   10b0 <perror@plt>
jmp    14b9 <main+0x2b9>
mov    -0x2c(%rbp),%esi
lea    0xc55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14be <main+0x2be>
mov    0x2b03(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1100 <wait@plt>
jmp    130a <main+0x10a>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2dd9(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
cmp    $0xffffffff,%eax
jne    1232 <main+0x32>
lea    0xdd3(%rip),%rdi
jmp    12ea <main+0xea>
mov    %eax,%ebp
lea    0xde9(%rip),%r14
mov    %r14,%rdi
call   1030 <unlink@plt>
mov    (%rbx),%eax
mov    %eax,0x1c(%rsp)
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0x18(%rsp),%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1270 <main+0x70>
lea    0xdc2(%rip),%rdi
jmp    12ea <main+0xea>
mov    %ebp,%edi
mov    $0x5,%esi
call   1090 <listen@plt>
cmp    $0xffffffff,%eax
jne    128a <main+0x8a>
lea    0xdcc(%rip),%rdi
jmp    12ea <main+0xea>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <accept@plt>
cmp    $0xffffffff,%eax
je     12ce <main+0xce>
mov    %eax,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1110 <fork@plt>
test   %rax,%rax
js     12e3 <main+0xe3>
je     12d7 <main+0xd7>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %edi,%edi
call   1100 <wait@plt>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    12a0 <main+0xa0>
lea    0xda3(%rip),%rdi
jmp    12ea <main+0xea>
xor    %eax,%eax
call   1110 <fork@plt>
test   %rax,%rax
jns    12fd <main+0xfd>
lea    0xdb6(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jne    1326 <main+0x126>
lea    0xe(%rsp),%rsi
mov    %ebx,%edi
mov    $0x5,%edx
call   1080 <read@plt>
test   %eax,%eax
jg     1334 <main+0x134>
jns    1528 <main+0x328>
lea    0xdd0(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    %eax,%eax
movb   $0x0,0xe(%rsp,%rax,1)
lea    0xd6b(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd83(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xe(%rsp),%al
mov    %al,0xd(%rsp)
lea    0x10(%rsp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1394 <main+0x194>
lea    0xd2a(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    13bd <main+0x1bd>
lea    0xd01(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    13e6 <main+0x1e6>
lea    0xcd8(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    140f <main+0x20f>
lea    0xcaf(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1438 <main+0x238>
lea    0xc86(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1461 <main+0x261>
lea    0xc5d(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    148a <main+0x28a>
lea    0xc34(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    14b3 <main+0x2b3>
lea    0xc0b(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    14dc <main+0x2dc>
lea    0xbe2(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1505 <main+0x305>
lea    0xbb9(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   10f0 <sleep@plt>
lea    0xbbd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    1326 <main+0x126>
lea    0xbd8(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1326 <main+0x126>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [36 x i8] c"Server: Error in creating a socket \00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"server.sock\00"
@.str.2 = [36 x i8] c"Server: Error in binding the socket\00"
@.str.3 = [36 x i8] c"Server: Error in listening a socket\00"
@.str.4 = [40 x i8] c"Server: Error in accepting a connection\00"
@.str.5 = [13 x i8] c"Server: fork\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [12 x i8] c"Server: %s\0A\00"
@.str.7 = [25 x i8] c"socket to client fd: %d\0A\00"
@.str.8 = [23 x i8] c"Server: Error in write\00"
@.str.9 = [33 x i8] c"Closing socket to client fd: %d\0A\00"
@.str.10 = [22 x i8] c"Server: Error in read\00"
@.str.11 = [42 x i8] c"Server: Number of bytes read was zero %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_un
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 -1, i32* %3
store i64 -1, i64* %5
store i64 -1, i64* %6
store i32 0, i32* %10
store i32 0, i32* %11
%12 = load i32, i32* @AF_UNIX
%13 = load i32, i32* @SOCK_STREAM
%14 = call i32 @socket(i32 %12, i32 %13, i32 0)
store i32 %14, i32* %2
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %0
%21 = call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @AF_UNIX
%23 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %4, i32 0, i32 1
store i32 %22, i32* %23
%24 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %4, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @strcpy(i32 %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %2
%28 = bitcast %struct.sockaddr_un* %4 to %struct.sockaddr*
%29 = call i32 @bind(i32 %27, %struct.sockaddr* %28, i32 8)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %35
31: ; preds = %20
%32 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %20
%36 = load i32, i32* %2
%37 = call i32 @listen(i32 %36, i32 5)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %35
br label %44
44: ; preds = %43, %127
%45 = load i32, i32* %2
%46 = call i32 @accept(i32 %45, i32* null, i32 0)
store i32 %46, i32* %3
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %44
%53 = call i64 (...) @fork()
store i64 %53, i64* %5
%54 = load i64, i64* %5
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %52
%61 = load i64, i64* %5
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %127
63: ; preds = %60
%64 = call i64 (...) @fork()
store i64 %64, i64* %6
%65 = load i64, i64* %6
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %63
%72 = load i64, i64* %6
%73 = icmp sgt i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %71
%75 = load i32, i32* @EXIT_SUCCESS
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %71
%78 = load i32, i32* %3
%79 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%80 = call i32 @read(i32 %78, i8* %79, i32 5)
store i32 %80, i32* %7
%81 = load i32, i32* %7
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %115
83: ; preds = %77
%84 = load i32, i32* %7
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %85
store i8 0, i8* %86
%87 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %87)
%89 = load i32, i32* %3
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %89)
%91 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%92 = load i8, i8* %91
store i8 %92, i8* %9
%93 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 2
%94 = call i32 @atoi(i8* %93)
store i32 %94, i32* %10
store i32 0, i32* %11
br label %95
95: ; preds = %107, %83
%96 = load i32, i32* %11
%97 = icmp slt i32 %96, 10
br i1 %97, label %98, label %110
98: ; preds = %95
%99 = load i32, i32* %3
%100 = call i32 @write(i32 %99, i8* %9, i32 1)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %104
102: ; preds = %98
%103 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %104
104: ; preds = %102, %98
%105 = load i32, i32* %10
%106 = call i32 @sleep(i32 %105)
br label %107
107: ; preds = %104
%108 = load i32, i32* %11
%109 = add nsw i32 %108, 1
store i32 %109, i32* %11
br label %95
110: ; preds = %95
%111 = load i32, i32* %3
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %111)
%113 = load i32, i32* %3
%114 = call i32 @close(i32 %113)
br label %124
115: ; preds = %77
%116 = load i32, i32* %7
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %123
120: ; preds = %115
%121 = load i32, i32* %7
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), i32 %121)
br label %123
123: ; preds = %120, %118
br label %124
124: ; preds = %123, %110
%125 = load i32, i32* @EXIT_SUCCESS
%126 = call i32 @exit(i32 %125)
unreachable
127: ; preds = %60
%128 = load i32, i32* %3
%129 = call i32 @close(i32 %128)
%130 = call i32 @wait(i32* null)
br label %44
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [36 x i8] c"Server: Error in creating a socket \00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"server.sock\00"
@.str.2 = [36 x i8] c"Server: Error in binding the socket\00"
@.str.3 = [36 x i8] c"Server: Error in listening a socket\00"
@.str.4 = [40 x i8] c"Server: Error in accepting a connection\00"
@.str.5 = [13 x i8] c"Server: fork\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [12 x i8] c"Server: %s\0A\00"
@.str.7 = [25 x i8] c"socket to client fd: %d\0A\00"
@.str.8 = [23 x i8] c"Server: Error in write\00"
@.str.9 = [33 x i8] c"Closing socket to client fd: %d\0A\00"
@.str.10 = [22 x i8] c"Server: Error in read\00"
@.str.11 = [42 x i8] c"Server: Number of bytes read was zero %d\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_un
%2 = alloca [10 x i8]
%3 = alloca i8
%4 = bitcast %struct.sockaddr_un* %1 to i8*
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @AF_UNIX
%7 = load i32, i32* @SOCK_STREAM
%8 = tail call i32 @socket(i32 %6, i32 %7, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @AF_UNIX
%17 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %1, i64 0, i32 1
store i32 %16, i32* %17
%18 = tail call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%19 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%20 = call i32 @bind(i32 %8, %struct.sockaddr* %19, i32 8)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %14
%27 = call i32 @listen(i32 %8, i32 5)
%28 = icmp eq i32 %27, -1
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = call i32 @accept(i32 %8, i32* null, i32 0)
%31 = icmp eq i32 %30, -1
br i1 %31, label %36, label %40
32: ; preds = %26
%33 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %144, %29
%37 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %29, %144
%41 = phi i32 [ %147, %144 ], [ %30, %29 ]
%42 = call i64 (...) @fork()
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %40
%49 = icmp eq i64 %42, 0
br i1 %49, label %50, label %144
50: ; preds = %48
%51 = call i64 (...) @fork()
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %50
%58 = icmp eq i64 %51, 0
br i1 %58, label %62, label %59
59: ; preds = %57
%60 = load i32, i32* @EXIT_SUCCESS
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %57
%63 = call i32 @read(i32 %41, i8* %5, i32 5)
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %135
65: ; preds = %62
%66 = zext i32 %63 to i64
%67 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %66
store i8 0, i8* %67
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %41)
%70 = load i8, i8* %5
store i8 %70, i8* %3
%71 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
%72 = call i32 @atoi(i8* %71)
%73 = call i32 @write(i32 %41, i8* %3, i32 1)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %77
75: ; preds = %65
%76 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %77
77: ; preds = %75, %65
%78 = call i32 @sleep(i32 %72)
%79 = call i32 @write(i32 %41, i8* %3, i32 1)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %83
83: ; preds = %81, %77
%84 = call i32 @sleep(i32 %72)
%85 = call i32 @write(i32 %41, i8* %3, i32 1)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %89
89: ; preds = %87, %83
%90 = call i32 @sleep(i32 %72)
%91 = call i32 @write(i32 %41, i8* %3, i32 1)
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %95
95: ; preds = %93, %89
%96 = call i32 @sleep(i32 %72)
%97 = call i32 @write(i32 %41, i8* %3, i32 1)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %101
99: ; preds = %95
%100 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %101
101: ; preds = %99, %95
%102 = call i32 @sleep(i32 %72)
%103 = call i32 @write(i32 %41, i8* %3, i32 1)
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %107
105: ; preds = %101
%106 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %107
107: ; preds = %105, %101
%108 = call i32 @sleep(i32 %72)
%109 = call i32 @write(i32 %41, i8* %3, i32 1)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %113
111: ; preds = %107
%112 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %113
113: ; preds = %111, %107
%114 = call i32 @sleep(i32 %72)
%115 = call i32 @write(i32 %41, i8* %3, i32 1)
%116 = icmp eq i32 %115, -1
br i1 %116, label %117, label %119
117: ; preds = %113
%118 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %119
119: ; preds = %117, %113
%120 = call i32 @sleep(i32 %72)
%121 = call i32 @write(i32 %41, i8* %3, i32 1)
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %125
123: ; preds = %119
%124 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %125
125: ; preds = %123, %119
%126 = call i32 @sleep(i32 %72)
%127 = call i32 @write(i32 %41, i8* %3, i32 1)
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %131
131: ; preds = %129, %125
%132 = call i32 @sleep(i32 %72)
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%134 = call i32 @close(i32 %41)
br label %141
135: ; preds = %62
%136 = icmp slt i32 %63, 0
br i1 %136, label %137, label %139
137: ; preds = %135
%138 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %141
139: ; preds = %135
%140 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), i32 0)
br label %141
141: ; preds = %137, %139, %131
%142 = load i32, i32* @EXIT_SUCCESS
%143 = call i32 @exit(i32 %142)
unreachable
144: ; preds = %48
%145 = call i32 @close(i32 %41)
%146 = call i32 @wait(i32* null)
%147 = call i32 @accept(i32 %8, i32* null, i32 0)
%148 = icmp eq i32 %147, -1
br i1 %148, label %36, label %40
}