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

/* Variables and functions */
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
void *pipe_data(void *arg) {
  int from_sock = ((int *)arg)[0];
  int to_sock = ((int *)arg)[1];
  int l;
  char buf[256];
  while ((l = recv(from_sock, buf, sizeof(buf), 0)) > 0)
    if (send(to_sock, buf, l, 0) == -1)
      break;
  return NULL;
}


x86 assembly (clang, -O0):
<pipe_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    118b <pipe_data+0x6b>
mov    -0x10(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    1186 <pipe_data+0x66>
jmp    118b <pipe_data+0x6b>
jmp    1142 <pipe_data+0x22>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipe_data>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    (%rdi),%ebx
mov    0x4(%rdi),%r14d
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1169 <pipe_data+0x49>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    1140 <pipe_data+0x20>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @pipe_data(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x i8]
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = bitcast i8* %7 to i32*
%9 = getelementptr inbounds i32, i32* %8, i64 0
%10 = load i32, i32* %9
store i32 %10, i32* %3
%11 = load i8*, i8** %2
%12 = bitcast i8* %11 to i32*
%13 = getelementptr inbounds i32, i32* %12, i64 1
%14 = load i32, i32* %13
store i32 %14, i32* %4
br label %15
15: ; preds = %27, %1
%16 = load i32, i32* %3
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%18 = call i32 @recv(i32 %16, i8* %17, i32 256, i32 0)
store i32 %18, i32* %5
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = load i32, i32* %4
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %5
%24 = call i32 @send(i32 %21, i8* %22, i32 %23, i32 0)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %27
26: ; preds = %20
br label %28
27: ; preds = %20
br label %15
28: ; preds = %26, %15
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @pipe_data(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = getelementptr inbounds i8, i8* %0, i64 4
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %9
9: ; preds = %12, %1
%10 = call i32 @recv(i32 %4, i8* %8, i32 256, i32 0)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @send(i32 %7, i8* %8, i32 %10, i32 0)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %9
15: ; preds = %12, %9
ret i8* null
}