#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*/ timestr;
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int read(int, char *, int);
void time_recv(int connfd) {
  ssize_t rlen;
  char timestr[64];
  rlen = read(connfd, timestr, sizeof(timestr));
  if (rlen == -1)
    error(EXIT_FAILURE, errno, "read");
  else
    timestr[rlen] = 0;
  close(connfd);
}


x86 assembly (clang, -O0):
<time_recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x40,%edx
call   1040 <read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    117c <time_recv+0x4c>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdx
call   1050 <error@plt>
jmp    1185 <time_recv+0x55>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_recv>:
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
mov    %rsp,%rsi
mov    $0x40,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
je     1151 <time_recv+0x21>
cltq
movb   $0x0,(%rsp,%rax,1)
jmp    116f <time_recv+0x3f>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdx
call   1050 <error@plt>
mov    %ebx,%edi
add    $0x40,%rsp
pop    %rbx
jmp    1030 <close@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@errno = global i32 0
@.str = [5 x i8] c"read\00"
define void @time_recv(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [64 x i8]
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = call i32 @read(i32 %5, i8* %6, i32 64)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @EXIT_FAILURE
%12 = load i32, i32* @errno
%13 = call i32 @error(i32 %11, i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %18
14: ; preds = %1
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %14, %10
%19 = load i32, i32* %2
%20 = call i32 @close(i32 %19)
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@errno = global i32 0
@.str = [5 x i8] c"read\00"
define void @time_recv(i32 %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 %0, i8* %3, i32 64)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @EXIT_FAILURE
%8 = load i32, i32* @errno
%9 = tail call i32 @error(i32 %7, i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %13
10: ; preds = %1
%11 = sext i32 %4 to i64
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %11
store i8 0, i8* %12
br label %13
13: ; preds = %10, %6
%14 = tail call i32 @close(i32 %0)
ret void
}