#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 ssize_t;

/* Variables and functions */
int errno;
int recv(int, void *, size_t, int /*<<< orphan*/);
int send(int, void const *, size_t, int /*<<< orphan*/);
void send_recv(int comm_socket, const void *data, size_t data_len, void *buffer,
               size_t buf_len, ssize_t *byte_sent, ssize_t *byte_rcvd,
               int *send_errno, int *recv_errno) {
  *byte_sent = send(comm_socket, data, data_len, 0);
  if (*byte_sent == -1) {
    *send_errno = errno;
  } else {
    *send_errno = 0;
  }
  *byte_rcvd = recv(comm_socket, buffer, buf_len, 0);
  if (*byte_rcvd == -1) {
    *recv_errno = errno;
  } else {
    *recv_errno = 0;
  }
}


x86 assembly (clang, -O0):
<send_recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1186 <send_recv+0x66>
mov    0x2e67(%rip),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1190 <send_recv+0x70>
mov    0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    11cb <send_recv+0xab>
mov    0x2e22(%rip),%rax
mov    (%rax),%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d5 <send_recv+0xb5>
mov    0x20(%rbp),%rax
movl   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_recv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %edi,%ebp
mov    0x48(%rsp),%r13
xor    %r12d,%r12d
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,(%rbx)
mov    0x2e92(%rip),%rdx
mov    $0x0,%ecx
cmp    $0xffffffff,%eax
jne    115a <send_recv+0x3a>
mov    (%rdx),%ecx
mov    0x50(%rsp),%rbx
mov    %ecx,0x0(%r13)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    0x40(%rsp),%rcx
mov    %eax,(%rcx)
cmp    $0xffffffff,%eax
jne    1188 <send_recv+0x68>
mov    0x2e5b(%rip),%rax
mov    (%rax),%r12d
mov    %r12d,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
define void @send_recv(i32 %0, i8* %1, i64 %2, i8* %3, i64 %4, i32* %5, i32* %6, i32* %7, i32* %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
store i32 %0, i32* %10
store i8* %1, i8** %11
store i64 %2, i64* %12
store i8* %3, i8** %13
store i64 %4, i64* %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i32* %7, i32** %17
store i32* %8, i32** %18
%19 = load i32, i32* %10
%20 = load i8*, i8** %11
%21 = load i64, i64* %12
%22 = call i32 @send(i32 %19, i8* %20, i64 %21, i32 0)
%23 = load i32*, i32** %15
store i32 %22, i32* %23
%24 = load i32*, i32** %15
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %9
%28 = load i32, i32* @errno
%29 = load i32*, i32** %17
store i32 %28, i32* %29
br label %32
30: ; preds = %9
%31 = load i32*, i32** %17
store i32 0, i32* %31
br label %32
32: ; preds = %30, %27
%33 = load i32, i32* %10
%34 = load i8*, i8** %13
%35 = load i64, i64* %14
%36 = call i32 @recv(i32 %33, i8* %34, i64 %35, i32 0)
%37 = load i32*, i32** %16
store i32 %36, i32* %37
%38 = load i32*, i32** %16
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i32, i32* @errno
%43 = load i32*, i32** %18
store i32 %42, i32* %43
br label %46
44: ; preds = %32
%45 = load i32*, i32** %18
store i32 0, i32* %45
br label %46
46: ; preds = %44, %41
ret void
}

LLVM IR (-O2):
@errno = global i32 0
define void @send_recv(i32 %0, i8* %1, i64 %2, i8* %3, i64 %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6, i32* nocapture writeonly %7, i32* nocapture writeonly %8) {
%10 = tail call i32 @send(i32 %0, i8* %1, i64 %2, i32 0)
store i32 %10, i32* %5
%11 = icmp eq i32 %10, -1
%12 = load i32, i32* @errno
%13 = select i1 %11, i32 %12, i32 0
store i32 %13, i32* %7
%14 = tail call i32 @recv(i32 %0, i8* %3, i64 %4, i32 0)
store i32 %14, i32* %6
%15 = icmp eq i32 %14, -1
%16 = load i32, i32* @errno
%17 = select i1 %15, i32 %16, i32 0
store i32 %17, i32* %8
ret void
}