#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*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int write(int, char *, int);
void doprocessing(int sock) {
  int n;
  char buffer[256];
  bzero(buffer, 256);
  n = read(sock, buffer, 255);
  if (n < 0) {
    perror("MSS: ERROR reading from socket\n");
    exit(1);
  }
  printf("Here is the message: %s\n", buffer);
  n = write(sock, "I got your message", 18);
  if (n < 0) {
    perror("MSS: ERROR writing to socket\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<doprocessing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1070 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   1050 <read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11b6 <doprocessing+0x56>
lea    0xe59(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x110(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    0xe66(%rip),%rsi
mov    $0x12,%edx
call   1030 <write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1200 <doprocessing+0xa0>
lea    0xe5b(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doprocessing>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1070 <bzero@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xff,%edx
call   1050 <read@plt>
test   %eax,%eax
js     11c0 <doprocessing+0x60>
lea    0xe8a(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
lea    0xe94(%rip),%rsi
mov    %ebx,%edi
mov    $0x12,%edx
call   1030 <write@plt>
test   %eax,%eax
js     11c9 <doprocessing+0x69>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe39(%rip),%rdi
jmp    11d0 <doprocessing+0x70>
lea    0xe7c(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"MSS: ERROR reading from socket\0A\00"
@.str.1 = [25 x i8] c"Here is the message: %s\0A\00"
@.str.2 = [19 x i8] c"I got your message\00"
@.str.3 = [30 x i8] c"MSS: ERROR writing to socket\0A\00"
define void @doprocessing(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
store i32 %0, i32* %2
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @bzero(i8* %5, i32 256)
%7 = load i32, i32* %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 255)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %1
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* %2
%19 = call i32 @write(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 18)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"MSS: ERROR reading from socket\0A\00"
@.str.1 = [25 x i8] c"Here is the message: %s\0A\00"
@.str.2 = [19 x i8] c"I got your message\00"
@.str.3 = [30 x i8] c"MSS: ERROR writing to socket\0A\00"
define void @doprocessing(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @bzero(i8* %3, i32 256)
%5 = call i32 @read(i32 %0, i8* %3, i32 255)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%12 = call i32 @write(i32 %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 18)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
ret void
}