#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 */
typedef int /*<<< orphan*/ data;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ handleData0(char *, int);
int /*<<< orphan*/ handleData1(char *, int);
int /*<<< orphan*/ handleData2(char *, int);
int /*<<< orphan*/ handleData3(char *, int);
int /*<<< orphan*/ handleData4(char *, int);
int /*<<< orphan*/ handleData5(char *, int);
int /*<<< orphan*/ printf(char *, int, int);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
void doprocessing(int sock, int serversock) {
  char data[1024];
  int n = 0;
  int len = 0;
  while (1) {
    bzero(data, sizeof(data));
    len = read(sock, data, 1024);
    if (len == 0 || len <= 1) {
      return;
    }
    printf("# vulnserver_cov: Received data with len: %i on state: %i\n", len,
           n);
    switch (data[0]) {
    case 'A':
      handleData0(data, len);
      write(sock, "ok", 2);
      break;
    case 'B':
      handleData1(data, len);
      write(sock, "ok", 2);
      break;
    case 'C':
      handleData2(data, len);
      write(sock, "ok", 2);
      break;
    case 'D':
      handleData3(data, len);
      write(sock, "ok", 2);
      break;
    case 'E':
      handleData4(data, len);
      write(sock, "ok", 2);
      break;
    case 'F':
      handleData5(data, len);
      write(sock, "ok", 2);
      close(serversock);
      break;
    default:
      return;
    }
    n++;
  }
}


x86 assembly (clang, -O0):
<doprocessing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x0,-0x418(%rbp)
je     121a <doprocessing+0x6a>
cmpl   $0x1,-0x418(%rbp)
jg     121f <doprocessing+0x6f>
jmp    138d <doprocessing+0x1dd>
mov    -0x418(%rbp),%esi
mov    -0x414(%rbp),%edx
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x410(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x420(%rbp)
sub    $0x5,%eax
ja     1374 <doprocessing+0x1c4>
mov    -0x420(%rbp),%rax
lea    0xd9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   1090 <handleData0@plt>
mov    -0x4(%rbp),%edi
lea    0xdcd(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    1379 <doprocessing+0x1c9>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   10d0 <handleData1@plt>
mov    -0x4(%rbp),%edi
lea    0xda2(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    1379 <doprocessing+0x1c9>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   1080 <handleData2@plt>
mov    -0x4(%rbp),%edi
lea    0xd77(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    1379 <doprocessing+0x1c9>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   10b0 <handleData3@plt>
mov    -0x4(%rbp),%edi
lea    0xd4c(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    1379 <doprocessing+0x1c9>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   1070 <handleData4@plt>
mov    -0x4(%rbp),%edi
lea    0xd21(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    1379 <doprocessing+0x1c9>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%esi
call   10c0 <handleData5@plt>
mov    -0x4(%rbp),%edi
lea    0xcf6(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
jmp    1379 <doprocessing+0x1c9>
jmp    138d <doprocessing+0x1dd>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11d5 <doprocessing+0x25>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doprocessing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %esi,0xc(%rsp)
mov    %edi,%ebp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
cmp    $0x2,%eax
jge    11ff <doprocessing+0x4f>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r14d
xor    %ebx,%ebx
lea    0xdf5(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xe3c(%rip),%r13
jmp    1266 <doprocessing+0xb6>
mov    %r12,%rdi
mov    %r14d,%esi
call   1090 <handleData0@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
add    $0x1,%ebx
mov    %r12,%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %eax,%r14d
cmp    $0x1,%eax
jle    11ed <doprocessing+0x3d>
lea    0xdab(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
movsbl 0x10(%rsp),%eax
add    $0xffffffbf,%eax
cmp    $0x5,%eax
ja     11ed <doprocessing+0x3d>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    %r12,%rdi
mov    %r14d,%esi
call   10d0 <handleData1@plt>
jmp    1230 <doprocessing+0x80>
mov    %r12,%rdi
mov    %r14d,%esi
call   1080 <handleData2@plt>
jmp    1230 <doprocessing+0x80>
mov    %r12,%rdi
mov    %r14d,%esi
call   10b0 <handleData3@plt>
jmp    1230 <doprocessing+0x80>
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <handleData4@plt>
jmp    1230 <doprocessing+0x80>
mov    %r12,%rdi
mov    %r14d,%esi
call   10c0 <handleData5@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
jmp    123f <doprocessing+0x8f>

LLVM IR (-O0):
@.str = [59 x i8] c"# vulnserver_cov: Received data with len: %i on state: %i\0A\00"
@.str.1 = [3 x i8] c"ok\00"
define void @doprocessing(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %2, %66
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = call i32 @bzero(i8* %9, i32 1024)
%11 = load i32, i32* %3
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 1024)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %8
%17 = load i32, i32* %7
%18 = icmp sle i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %16, %8
br label %69
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
switch i32 %26, label %65 [
i32 65, label %27
i32 66, label %33
i32 67, label %39
i32 68, label %45
i32 69, label %51
i32 70, label %57
]
27: ; preds = %20
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%29 = load i32, i32* %7
%30 = call i32 @handleData0(i8* %28, i32 %29)
%31 = load i32, i32* %3
%32 = call i32 @write(i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %66
33: ; preds = %20
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%35 = load i32, i32* %7
%36 = call i32 @handleData1(i8* %34, i32 %35)
%37 = load i32, i32* %3
%38 = call i32 @write(i32 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %66
39: ; preds = %20
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%41 = load i32, i32* %7
%42 = call i32 @handleData2(i8* %40, i32 %41)
%43 = load i32, i32* %3
%44 = call i32 @write(i32 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %66
45: ; preds = %20
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%47 = load i32, i32* %7
%48 = call i32 @handleData3(i8* %46, i32 %47)
%49 = load i32, i32* %3
%50 = call i32 @write(i32 %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %66
51: ; preds = %20
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%53 = load i32, i32* %7
%54 = call i32 @handleData4(i8* %52, i32 %53)
%55 = load i32, i32* %3
%56 = call i32 @write(i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %66
57: ; preds = %20
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%59 = load i32, i32* %7
%60 = call i32 @handleData5(i8* %58, i32 %59)
%61 = load i32, i32* %3
%62 = call i32 @write(i32 %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%63 = load i32, i32* %4
%64 = call i32 @close(i32 %63)
br label %66
65: ; preds = %20
br label %69
66: ; preds = %57, %51, %45, %39, %33, %27
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %8
69: ; preds = %65, %19
ret void
}

LLVM IR (-O2):
@.str = [59 x i8] c"# vulnserver_cov: Received data with len: %i on state: %i\0A\00"
@.str.1 = [3 x i8] c"ok\00"
define void @doprocessing(i32 %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 1024)
%6 = call i32 @read(i32 %0, i8* %4, i32 1024)
%7 = icmp slt i32 %6, 2
br i1 %7, label %38, label %8
8: ; preds = %2, %33
%9 = phi i32 [ %36, %33 ], [ %6, %2 ]
%10 = phi i32 [ %34, %33 ], [ 0, %2 ]
%11 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
switch i32 %13, label %38 [
i32 65, label %14
i32 66, label %17
i32 67, label %20
i32 68, label %23
i32 69, label %26
i32 70, label %29
]
14: ; preds = %8
%15 = call i32 @handleData0(i8* %4, i32 %9)
%16 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %33
17: ; preds = %8
%18 = call i32 @handleData1(i8* %4, i32 %9)
%19 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %33
20: ; preds = %8
%21 = call i32 @handleData2(i8* %4, i32 %9)
%22 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %33
23: ; preds = %8
%24 = call i32 @handleData3(i8* %4, i32 %9)
%25 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %33
26: ; preds = %8
%27 = call i32 @handleData4(i8* %4, i32 %9)
%28 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %33
29: ; preds = %8
%30 = call i32 @handleData5(i8* %4, i32 %9)
%31 = call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%32 = call i32 @close(i32 %1)
br label %33
33: ; preds = %29, %26, %23, %20, %17, %14
%34 = add nuw nsw i32 %10, 1
%35 = call i32 @bzero(i8* %4, i32 1024)
%36 = call i32 @read(i32 %0, i8* %4, i32 1024)
%37 = icmp slt i32 %36, 2
br i1 %37, label %38, label %8
38: ; preds = %33, %8, %2
ret void
}