#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 */

/* Variables and functions */
int /*<<< orphan*/ abs(int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ exit(int);
int floor(int /*<<< orphan*/);
int /*<<< orphan*/ log10(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int write(int, char *, int);
void CountTheVowels(int sock) {
  int quit = 0;
  while (quit == 0) {
    int n;
    char buffer[256];
    bzero(buffer, 256);
    n = read(sock, buffer, 255);
    if (n < 0) {
      perror("ERROR reading from socket\n");
      exit(1);
    }
    if (strstr(buffer, "Bye") == NULL) {
      printf("Sentence recieved: %s\n", buffer);
      int i;
      int vowel_count = 0;
      for (i = 0; i < strlen(buffer); i++) {
        if (buffer[i] == 'a' || buffer[i] == 'e' || buffer[i] == 'i' ||
            buffer[i] == 'o' || buffer[i] == 'u')
          vowel_count++;
      }
      int char_count = floor(log10(abs(vowel_count))) + 1;
      char message[12];
      snprintf(message, 12, "%d", vowel_count);
      n = write(sock, message, char_count);
      if (n < 0) {
        perror("ERROR writing to socket\n");
        exit(1);
      }
    } else {
      quit = 1;
      printf("Connection Closing\n");
    }
  }
}


x86 assembly (clang, -O0):
<CountTheVowels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    13cc <CountTheVowels+0x20c>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   1080 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1227 <CountTheVowels+0x67>
lea    0xde8(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x110(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
jne    13b2 <CountTheVowels+0x1f2>
lea    -0x110(%rbp),%rsi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x118(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x12c(%rbp),%eax
cmp    %ecx,%eax
jge    1335 <CountTheVowels+0x175>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x61,%eax
je     130d <CountTheVowels+0x14d>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x65,%eax
je     130d <CountTheVowels+0x14d>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x69,%eax
je     130d <CountTheVowels+0x14d>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x6f,%eax
je     130d <CountTheVowels+0x14d>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x75,%eax
jne    131c <CountTheVowels+0x15c>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    1321 <CountTheVowels+0x161>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    126d <CountTheVowels+0xad>
mov    -0x118(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%edi
call   10b0 <log10@plt>
mov    %eax,%edi
call   10d0 <floor@plt>
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
lea    -0x128(%rbp),%rdi
mov    -0x118(%rbp),%ecx
mov    $0xc,%esi
lea    0xcc6(%rip),%rdx
call   1070 <snprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x128(%rbp),%rsi
mov    -0x11c(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    13ad <CountTheVowels+0x1ed>
lea    0xc9b(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    13c7 <CountTheVowels+0x207>
movl   $0x1,-0x8(%rbp)
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11d5 <CountTheVowels+0x15>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CountTheVowels>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %edi,%ebp
lea    0x20(%rsp),%rbx
mov    $0x495,%r13d
mov    %edi,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1080 <read@plt>
test   %eax,%eax
js     1306 <CountTheVowels+0x146>
mov    %rbx,%rdi
lea    0xdfd(%rip),%rsi
call   10e0 <strstr@plt>
test   %rax,%rax
jne    12e8 <CountTheVowels+0x128>
mov    %rax,0x8(%rsp)
xor    %r12d,%r12d
lea    0xde4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1290 <CountTheVowels+0xd0>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1273 <CountTheVowels+0xb3>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1290 <CountTheVowels+0xd0>
movzbl 0x20(%rsp,%rbp,1),%eax
add    $0x9f,%al
ror    %al
cmp    $0xa,%al
ja     1260 <CountTheVowels+0xa0>
movzbl %al,%eax
bt     %rax,%r13
jae    1260 <CountTheVowels+0xa0>
add    $0x1,%r12d
jmp    1260 <CountTheVowels+0xa0>
nop
mov    %r12d,%edi
neg    %edi
cmovs  %r12d,%edi
call   10b0 <log10@plt>
mov    %eax,%edi
call   10d0 <floor@plt>
lea    0x1(%rax),%r14d
lea    0x14(%rsp),%r15
mov    %r15,%rdi
mov    $0xc,%esi
lea    0xd79(%rip),%rdx
mov    %r12d,%ecx
call   1070 <snprintf@plt>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <write@plt>
test   %eax,%eax
js     130f <CountTheVowels+0x14f>
cmpq   $0x0,0x8(%rsp)
je     11f0 <CountTheVowels+0x30>
jmp    12f4 <CountTheVowels+0x134>
lea    0xd63(%rip),%rdi
call   1030 <puts@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf3(%rip),%rdi
jmp    1316 <CountTheVowels+0x156>
lea    0xd23(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"ERROR reading from socket\0A\00"
@.str.1 = [4 x i8] c"Bye\00"
@.str.2 = [23 x i8] c"Sentence recieved: %s\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [25 x i8] c"ERROR writing to socket\0A\00"
@.str.5 = [20 x i8] c"Connection Closing\0A\00"
define void @CountTheVowels(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [12 x i8]
store i32 %0, i32* %2
store i32 0, i32* %3
br label %10
10: ; preds = %99, %1
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %100
13: ; preds = %10
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @bzero(i8* %14, i32 256)
%16 = load i32, i32* %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%18 = call i32 @read(i32 %16, i8* %17, i32 255)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %13
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%26 = call i32* @strstr(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %97
28: ; preds = %24
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %29)
store i32 0, i32* %7
store i32 0, i32* %6
br label %31
31: ; preds = %75, %28
%32 = load i32, i32* %6
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %78
36: ; preds = %31
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 97
br i1 %42, label %71, label %43
43: ; preds = %36
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 101
br i1 %49, label %71, label %50
50: ; preds = %43
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 105
br i1 %56, label %71, label %57
57: ; preds = %50
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 111
br i1 %63, label %71, label %64
64: ; preds = %57
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 117
br i1 %70, label %71, label %74
71: ; preds = %64, %57, %50, %43, %36
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
br label %74
74: ; preds = %71, %64
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %31
78: ; preds = %31
%79 = load i32, i32* %7
%80 = call i32 @abs(i32 %79)
%81 = call i32 @log10(i32 %80)
%82 = call i32 @floor(i32 %81)
%83 = add nsw i32 %82, 1
store i32 %83, i32* %8
%84 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%85 = load i32, i32* %7
%86 = call i32 @snprintf(i8* %84, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %2
%88 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%89 = load i32, i32* %8
%90 = call i32 @write(i32 %87, i8* %88, i32 %89)
store i32 %90, i32* %4
%91 = load i32, i32* %4
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %78
%94 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %78
br label %99
97: ; preds = %24
store i32 1, i32* %3
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %99
99: ; preds = %97, %96
br label %10
100: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"ERROR reading from socket\0A\00"
@.str.1 = [4 x i8] c"Bye\00"
@.str.2 = [23 x i8] c"Sentence recieved: %s\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [25 x i8] c"ERROR writing to socket\0A\00"
@str = [19 x i8] c"Connection Closing\00"
define void @CountTheVowels(i32 %0) {
%2 = alloca [256 x i8]
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
br label %6
6: ; preds = %1, %49
%7 = call i32 @bzero(i8* %4, i32 256)
%8 = call i32 @read(i32 %0, i8* %4, i32 255)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = call i32* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %47
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%18 = call i32 @strlen(i8* %4)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %16, %29
%21 = phi i64 [ %31, %29 ], [ 0, %16 ]
%22 = phi i32 [ %30, %29 ], [ 0, %16 ]
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %21
%24 = load i8, i8* %23
%25 = add i8 %24, -97
%26 = call i8 @llvm.fshl.i8(i8 %25, i8 %25, i8 7)
switch i8 %26, label %29 [
i8 0, label %27
i8 2, label %27
i8 4, label %27
i8 7, label %27
i8 10, label %27
]
27: ; preds = %20, %20, %20, %20, %20
%28 = add nsw i32 %22, 1
br label %29
29: ; preds = %20, %27
%30 = phi i32 [ %28, %27 ], [ %22, %20 ]
%31 = add nuw nsw i64 %21, 1
%32 = call i32 @strlen(i8* %4)
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %20, label %35
35: ; preds = %29, %16
%36 = phi i32 [ 0, %16 ], [ %30, %29 ]
%37 = call i32 @llvm.abs.i32(i32 %36, i1 true)
%38 = call i32 @log10(i32 %37)
%39 = call i32 @floor(i32 %38)
%40 = add nsw i32 %39, 1
%41 = call i32 @snprintf(i8* %5, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%42 = call i32 @write(i32 %0, i8* %5, i32 %40)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %35
%45 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %13
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %50
49: ; preds = %35
br i1 %15, label %6, label %50
50: ; preds = %49, %47
ret void
}