#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*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int read(int, char *, int);
void *doProcessingSrv(void *socket) {
  int n;
  char buffer[16];
  bzero(buffer, 16);
  n = read(*((int *)socket), buffer, 16);
  if (n < 0) {
    perror("\nERROR - Couldn't read from socket.");
    pthread_exit(NULL);
  }
  if (n < 0) {
    perror("\nERROR - Couldn't write to socket.");
    pthread_exit(NULL);
  }
  close(*((int *)socket));
  free(socket);
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<doProcessingSrv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bzero@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11b0 <doProcessingSrv+0x50>
lea    0xe5e(%rip),%rdi
call   1070 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <pthread_exit@plt>
cmpl   $0x0,-0x14(%rbp)
jge    11cf <doProcessingSrv+0x6f>
lea    0xe63(%rip),%rdi
call   1070 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <pthread_exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doProcessingSrv>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x10,%esi
call   1080 <bzero@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   1050 <read@plt>
test   %eax,%eax
js     11aa <doProcessingSrv+0x4a>
mov    (%rbx),%edi
call   1040 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1060 <pthread_exit@plt>
lea    0xe4f(%rip),%rdi
call   1070 <perror@plt>
xor    %edi,%edi
call   1060 <pthread_exit@plt>
lea    0xe60(%rip),%rdi
call   1070 <perror@plt>
xor    %edi,%edi
call   1060 <pthread_exit@plt>
jmp    118d <doProcessingSrv+0x2d>

LLVM IR (-O0):
@.str = [36 x i8] c"\0AERROR - Couldn't read from socket.\00"
@.str.1 = [35 x i8] c"\0AERROR - Couldn't write to socket.\00"
define i8* @doProcessingSrv(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [16 x i8]
store i8* %0, i8** %3
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 16)
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%12 = call i32 @read(i32 %10, i8* %11, i32 16)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @pthread_exit(i32* null)
br label %18
18: ; preds = %15, %1
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @pthread_exit(i32* null)
br label %24
24: ; preds = %21, %18
%25 = load i8*, i8** %3
%26 = bitcast i8* %25 to i32*
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = load i8*, i8** %3
%30 = call i32 @free(i8* %29)
%31 = call i32 @pthread_exit(i32* null)
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0AERROR - Couldn't read from socket.\00"
@.str.1 = [35 x i8] c"\0AERROR - Couldn't write to socket.\00"
define noalias i8* @doProcessingSrv(i8* nocapture %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = call i32 @bzero(i8* %3, i32 16)
%5 = bitcast i8* %0 to i32*
%6 = load i32, i32* %5
%7 = call i32 @read(i32 %6, i8* %3, i32 16)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @pthread_exit(i32* null)
%12 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @pthread_exit(i32* null)
br label %14
14: ; preds = %1, %9
%15 = load i32, i32* %5
%16 = tail call i32 @close(i32 %15)
%17 = tail call i32 @free(i8* %0)
%18 = tail call i32 @pthread_exit(i32* null)
ret i8* undef
}