#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 */
int /*<<< orphan*/ error(char *, int);
int recv(int, char *, int, int /*<<< orphan*/);
void toReceive(int socket, char *message, int size) {
  int bytes = 0;
  while (bytes != size) {
    int current;
    current = recv(socket, message, size, 0);
    if (current == -1) {
      error("Error in reading.\n", 7);
    }
    bytes += current;
  }
}


x86 assembly (clang, -O0):
<toReceive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1182 <toReceive+0x62>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1174 <toReceive+0x54>
lea    0xe96(%rip),%rdi
mov    $0x7,%esi
call   1040 <error@plt>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <toReceive+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toReceive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
je     117d <toReceive+0x5d>
mov    %edx,%r13d
mov    %rsi,%r14
mov    %edi,%r12d
xor    %ebx,%ebx
lea    0xebf(%rip),%r15
jmp    1157 <toReceive+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ebp,%ebx
cmp    %r13d,%ebx
je     117d <toReceive+0x5d>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1150 <toReceive+0x30>
mov    %r15,%rdi
mov    $0x7,%esi
call   1040 <error@plt>
jmp    1150 <toReceive+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Error in reading.\0A\00"
define void @toReceive(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %22, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = call i32 @recv(i32 %14, i8* %15, i32 %16, i32 0)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 7)
br label %22
22: ; preds = %20, %13
%23 = load i32, i32* %8
%24 = load i32, i32* %7
%25 = add nsw i32 %24, %23
store i32 %25, i32* %7
br label %9
26: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Error in reading.\0A\00"
define void @toReceive(i32 %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %14, label %5
5: ; preds = %3, %11
%6 = phi i32 [ %12, %11 ], [ 0, %3 ]
%7 = tail call i32 @recv(i32 %0, i8* %1, i32 %2, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 7)
br label %11
11: ; preds = %9, %5
%12 = add nsw i32 %7, %6
%13 = icmp eq i32 %12, %2
br i1 %13, label %14, label %5
14: ; preds = %11, %3
ret void
}