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

/* Variables and functions */
int /*<<< orphan*/ close(int);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int snprintf(char *, int, char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int write(int, char *, int);
void *proc_routine(void *arg) {
  time_t tval;
  char timestr[32];
  int connfd = *(int *)arg;
  int wlen = 0;
  tval = time(0);
  wlen = snprintf(timestr, sizeof(timestr), "%.24s\r\n", ctime(&tval));
  if (write(connfd, timestr, wlen) != wlen)
    error(0, errno, "write");
  close(connfd);
  free(arg);
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<proc_routine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <ctime@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rcx
mov    $0x20,%esi
lea    0xe36(%rip),%rdx
call   1060 <snprintf@plt>
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%edx
call   1040 <write@plt>
cmp    -0x48(%rbp),%eax
je     1201 <proc_routine+0x81>
mov    0x2def(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    0xe0c(%rip),%rdx
call   10a0 <error@plt>
mov    -0x44(%rbp),%edi
call   1070 <close@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_routine>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
mov    (%rdi),%r15d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <ctime@plt>
lea    0xe54(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %rax,%rcx
call   1060 <snprintf@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    %ebp,%eax
je     11eb <proc_routine+0x6b>
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
lea    0xe24(%rip),%rdx
xor    %edi,%edi
call   10a0 <error@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1090 <pthread_exit@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%.24s\0D\0A\00"
@errno = global i32 0
@.str.1 = [6 x i8] c"write\00"
define i8* @proc_routine(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [32 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
store i32 %10, i32* %6
store i32 0, i32* %7
%11 = call i32 @time(i32 0)
store i32 %11, i32* %4
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = call i8* @ctime(i32* %4)
%14 = call i32 @snprintf(i8* %12, i32 32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* %7
%18 = call i32 @write(i32 %15, i8* %16, i32 %17)
%19 = load i32, i32* %7
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = load i32, i32* @errno
%23 = call i32 @error(i32 0, i32 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %1
%25 = load i32, i32* %6
%26 = call i32 @close(i32 %25)
%27 = load i8*, i8** %3
%28 = call i32 @free(i8* %27)
%29 = call i32 @pthread_exit(i32* null)
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
@.str = [8 x i8] c"%.24s\0D\0A\00"
@errno = global i32 0
@.str.1 = [6 x i8] c"write\00"
define noalias i8* @proc_routine(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = bitcast i8* %0 to i32*
%7 = load i32, i32* %6
%8 = tail call i32 @time(i32 0)
store i32 %8, i32* %2
%9 = call i8* @ctime(i32* %2)
%10 = call i32 @snprintf(i8* %5, i32 32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @write(i32 %7, i8* %5, i32 %10)
%12 = icmp eq i32 %11, %10
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i32, i32* @errno
%15 = call i32 @error(i32 0, i32 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %13, %1
%17 = call i32 @close(i32 %7)
%18 = call i32 @free(i8* %0)
%19 = call i32 @pthread_exit(i32* null)
ret i8* undef
}