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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int write(int, char *, int);
void rpc(int sock) {
  int n;
  char buffer[256];
  bzero(buffer, 256);
  n = read(sock, buffer, 255);
  if (n < 0)
    error("ERROR reading from socket");
  time_t clock = time(NULL);
  printf("message recieved: %s", buffer);
  printf("	Current time is %s\n", ctime(&clock));
  n = write(sock, "message recieved", 16);
  if (n < 0)
    error("ERROR writing to socket");
}


x86 assembly (clang, -O0):
<rpc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1090 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   1060 <read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11bc <rpc+0x4c>
lea    0xe49(%rip),%rdi
call   1080 <error@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
lea    -0x114(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
lea    0xe41(%rip),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1226 <rpc+0xb6>
lea    0xe34(%rip),%rdi
call   1080 <error@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpc>:
push   %rbp
push   %rbx
sub    $0x118,%rsp
mov    %edi,%ebp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1090 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1060 <read@plt>
test   %eax,%eax
jns    11ac <rpc+0x3c>
lea    0xe59(%rip),%rdi
call   1080 <error@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xe5c(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <printf@plt>
lea    0xc(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xe56(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe5c(%rip),%rsi
mov    %ebp,%edi
mov    $0x10,%edx
call   1030 <write@plt>
test   %eax,%eax
jns    1204 <rpc+0x94>
lea    0xe56(%rip),%rdi
call   1080 <error@plt>
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"ERROR reading from socket\00"
@.str.1 = [21 x i8] c"message recieved: %s\00"
@.str.2 = [21 x i8] c"\09Current time is %s\0A\00"
@.str.3 = [17 x i8] c"message recieved\00"
@.str.4 = [24 x i8] c"ERROR writing to socket\00"
define void @rpc(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca i32
store i32 %0, i32* %2
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 256)
%8 = load i32, i32* %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = call i32 @read(i32 %8, i8* %9, i32 255)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %1
%16 = call i32 @time(i32* null)
store i32 %16, i32* %5
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i8* @ctime(i32* %5)
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %2
%22 = call i32 @write(i32 %21, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 16)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %15
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"ERROR reading from socket\00"
@.str.1 = [21 x i8] c"message recieved: %s\00"
@.str.2 = [21 x i8] c"\09Current time is %s\0A\00"
@.str.3 = [17 x i8] c"message recieved\00"
@.str.4 = [24 x i8] c"ERROR writing to socket\00"
define void @rpc(i32 %0) {
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 256)
%6 = call i32 @read(i32 %0, i8* %4, i32 255)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = bitcast i32* %3 to i8*
%12 = tail call i32 @time(i32* null)
store i32 %12, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%14 = call i8* @ctime(i32* %3)
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = call i32 @write(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 16)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18, %10
ret void
}