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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int write(int, char *, int);
void procTransT(int socket) {
  int n;
  char buffer[1024];
  bzero(buffer, 1024);
  n = read(socket, buffer, 1023);
  if (n < 0)
    error("ERROR reading from socket ");
  printf("TCP message: %s", buffer);
  n = write(socket, buffer, sizeof(buffer));
  if (n < 0)
    error("ERROR writing to socket ");
}


x86 assembly (clang, -O0):
<procTransT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1070 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x3ff,%edx
call   1050 <read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    119c <procTransT+0x4c>
lea    0xe69(%rip),%rdi
call   1060 <error@plt>
lea    -0x410(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1030 <write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11dc <procTransT+0x8c>
lea    0xe54(%rip),%rdi
call   1060 <error@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<procTransT>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1070 <bzero@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3ff,%edx
call   1050 <read@plt>
test   %eax,%eax
jns    118b <procTransT+0x3b>
lea    0xe7a(%rip),%rdi
call   1060 <error@plt>
lea    0xe89(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1030 <write@plt>
test   %eax,%eax
jns    11bc <procTransT+0x6c>
lea    0xe74(%rip),%rdi
call   1060 <error@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [27 x i8] c"ERROR reading from socket \00"
@.str.1 = [16 x i8] c"TCP message: %s\00"
@.str.2 = [25 x i8] c"ERROR writing to socket \00"
define void @procTransT(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @bzero(i8* %3, i32 1024)
%5 = call i32 @read(i32 %0, i8* %3, i32 1023)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = call i32 @write(i32 %0, i8* %3, i32 1024)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
ret void
}