#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 */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ cli_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ CountTheVowels(int);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("\nPort number is missing...\n");
    exit(0);
  }
  printf("Server has started\n");
  int sockfd, newsockfd, portno, clilen;
  struct sockaddr_in serv_addr, cli_addr;
  char buffer[256];
  int n, pid;
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0) {
    printf("ERROR opening socket\n");
    exit(1);
  }
  bzero((char *)&serv_addr, sizeof(serv_addr));
  portno = atoi(argv[1]);
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = INADDR_ANY;
  serv_addr.sin_port = htons(portno);
  if (bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
    printf("ERROR on binding\n");
    exit(1);
  }
  listen(sockfd, 5);
  clilen = sizeof(cli_addr);
  while (1) {
    newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
    if (newsockfd < 0) {
      printf("ERROR on accept\n");
      exit(1);
    }
    pid = fork();
    if (pid < 0) {
      perror("ERROR on fork\n");
      exit(1);
    }
    if (pid == 0) {
      close(sockfd);
      printf("Client Connected\n");
      CountTheVowels(newsockfd);
      exit(0);
    } else {
      close(newsockfd);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1206 <main+0x36>
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    124e <main+0x7e>
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   10a0 <bzero@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   1080 <bind@plt>
cmp    $0x0,%rax
jge    12c0 <main+0xf0>
lea    0xd95(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1060 <listen@plt>
movl   $0xc,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   10b0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1307 <main+0x137>
lea    0xd60(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x148(%rbp)
cmpl   $0x0,-0x148(%rbp)
jge    1337 <main+0x167>
lea    0xd41(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0x148(%rbp)
jne    1367 <main+0x197>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
lea    0xd25(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1070 <CountTheVowels@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
jmp    12d4 <main+0x104>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jg     11f2 <main+0x22>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    %rsi,%rbp
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de0(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
test   %eax,%eax
jns    122a <main+0x5a>
lea    0xe2f(%rip),%rdi
jmp    12ef <main+0x11f>
mov    %eax,%r14d
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   10a0 <bzero@plt>
mov    0x8(%rbp),%rdi
call   10c0 <atoi@plt>
mov    (%rbx),%ecx
mov    %ecx,0x10(%rsp)
mov    0x2d8b(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0xc(%rsp)
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1080 <bind@plt>
test   %rax,%rax
jns    1284 <main+0xb4>
lea    0xdc1(%rip),%rdi
jmp    12ef <main+0x11f>
mov    %r14d,%edi
mov    $0x5,%esi
call   1060 <listen@plt>
movl   $0xc,0x4(%rsp)
lea    0x18(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
call   10b0 <accept@plt>
test   %eax,%eax
js     12e8 <main+0x118>
mov    %eax,%ebp
lea    0x18(%rsp),%r15
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
js     12fe <main+0x12e>
je     1314 <main+0x144>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10b0 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12c0 <main+0xf0>
lea    0xd44(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xcfb(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %r14d,%edi
call   1050 <close@plt>
lea    0xcff(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1070 <CountTheVowels@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [28 x i8] c"\0APort number is missing...\0A\00"
@.str.1 = [20 x i8] c"Server has started\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [22 x i8] c"ERROR opening socket\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [18 x i8] c"ERROR on binding\0A\00"
@.str.4 = [17 x i8] c"ERROR on accept\0A\00"
@.str.5 = [15 x i8] c"ERROR on fork\0A\00"
@.str.6 = [18 x i8] c"Client Connected\0A\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 i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca [256 x i8]
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @AF_INET
%23 = load i32, i32* @SOCK_STREAM
%24 = call i32 @socket(i32 %22, i32 %23, i32 0)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %20
%31 = bitcast %struct.sockaddr_in* %10 to i8*
%32 = call i32 @bzero(i8* %31, i32 12)
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %8
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %37, i32* %38
%39 = load i32, i32* @INADDR_ANY
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %40, i32 0, i32 0
store i32 %39, i32* %41
%42 = load i32, i32* %8
%43 = call i32 @htons(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i32 %43, i32* %44
%45 = load i32, i32* %6
%46 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%47 = call i64 @bind(i32 %45, %struct.sockaddr* %46, i32 12)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %30
%50 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %30
%53 = load i32, i32* %6
%54 = call i32 @listen(i32 %53, i32 5)
store i32 12, i32* %9
br label %55
55: ; preds = %52, %84
%56 = load i32, i32* %6
%57 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%58 = call i32 @accept(i32 %56, %struct.sockaddr* %57, i32* %9)
store i32 %58, i32* %7
%59 = load i32, i32* %7
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %55
%65 = call i32 (...) @fork()
store i32 %65, i32* %14
%66 = load i32, i32* %14
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %64
%72 = load i32, i32* %14
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %71
%75 = load i32, i32* %6
%76 = call i32 @close(i32 %75)
%77 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* %7
%79 = call i32 @CountTheVowels(i32 %78)
%80 = call i32 @exit(i32 0)
unreachable
81: ; preds = %71
%82 = load i32, i32* %7
%83 = call i32 @close(i32 %82)
br label %84
84: ; preds = %81
br label %55
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i32 0
@.str.5 = [15 x i8] c"ERROR on fork\0A\00"
@str = [19 x i8] c"Server has started\00"
@str.7 = [17 x i8] c"Client Connected\00"
@str.8 = [16 x i8] c"ERROR on accept\00"
@str.9 = [17 x i8] c"ERROR on binding\00"
@str.10 = [21 x i8] c"ERROR opening socket\00"
@str.11 = [27 x i8] c"\0APort number is missing...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%12 = bitcast i32* %3 to i8*
%13 = bitcast %struct.sockaddr_in* %4 to i8*
%14 = bitcast %struct.sockaddr_in* %5 to i8*
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %10
%23 = call i32 @bzero(i8* %13, i32 12)
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %27, i32* %28
%29 = load i32, i32* @INADDR_ANY
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %29, i32* %30
%31 = tail call i32 @htons(i32 %26)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %31, i32* %32
%33 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%34 = call i64 @bind(i32 %17, %struct.sockaddr* %33, i32 12)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %22
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %22
%40 = call i32 @listen(i32 %17, i32 5)
store i32 12, i32* %3
%41 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%42 = call i32 @accept(i32 %17, %struct.sockaddr* %41, i32* %3)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %61, %39
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %39, %61
%48 = phi i32 [ %63, %61 ], [ %42, %39 ]
%49 = call i32 (...) @fork()
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %47
%55 = icmp eq i32 %49, 0
br i1 %55, label %56, label %61
56: ; preds = %54
%57 = call i32 @close(i32 %17)
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
%59 = call i32 @CountTheVowels(i32 %48)
%60 = call i32 @exit(i32 0)
unreachable
61: ; preds = %54
%62 = call i32 @close(i32 %48)
%63 = call i32 @accept(i32 %17, %struct.sockaddr* %41, i32* %3)
%64 = icmp slt i32 %63, 0
br i1 %64, label %44, label %47
}