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

/* Variables and functions */
scalar_t__ errno;
int recv_socket(int, char *, int);
int /*<<< orphan*/ send_socket(int, char *, int);
int do_processing(int sockfd) {
  int result = 0;
  if (sockfd != -1) {
    int read;
    char buffer[256] = {0};
    if ((read = recv_socket(sockfd, buffer, 255)) > 0) {
      send_socket(sockfd, buffer, read);
      result = 1;
    }
    if (read == 0)
      errno = 0;
  }
  return result;
}


x86 assembly (clang, -O0):
<do_processing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     11b8 <do_processing+0x88>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   1040 <recv_socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    119b <do_processing+0x6b>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <send_socket@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11b3 <do_processing+0x83>
mov    0x2e34(%rip),%rax
movq   $0x0,(%rax)
jmp    11b8 <do_processing+0x88>
mov    -0x8(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_processing>:
cmp    $0xffffffff,%edi
je     11c1 <do_processing+0xa1>
push   %rbx
sub    $0x100,%rsp
mov    %edi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0xff,%edx
call   1030 <recv_socket@plt>
mov    %eax,%edx
test   %eax,%eax
jle    11c4 <do_processing+0xa4>
mov    %rsp,%rsi
mov    %ebx,%edi
call   1040 <send_socket@plt>
mov    $0x1,%eax
jmp    11d8 <do_processing+0xb8>
xor    %eax,%eax
ret
xor    %eax,%eax
test   %edx,%edx
jne    11d8 <do_processing+0xb8>
mov    0x2e0f(%rip),%rcx
movq   $0x0,(%rcx)
add    $0x100,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@errno = global i64 0
define i32 @do_processing(i32 %0) {
%2 = alloca [256 x i8]
%3 = icmp eq i32 %0, -1
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = call i32 @recv_socket(i32 %0, i8* %5, i32 255)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = call i32 @send_socket(i32 %0, i8* %5, i32 %6)
br label %13
10: ; preds = %4
%11 = icmp eq i32 %6, 0
br i1 %11, label %12, label %13
12: ; preds = %10
store i64 0, i64* @errno
br label %13
13: ; preds = %8, %12, %10
%14 = phi i32 [ 1, %8 ], [ 0, %12 ], [ 0, %10 ]
br label %15
15: ; preds = %13, %1
%16 = phi i32 [ %14, %13 ], [ 0, %1 ]
ret i32 %16
}