#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 /*<<< orphan*/ err(int, char *);
int handle_data(int, char *, int);
int recv(int, char *, int, int /*<<< orphan*/);
void handle_dude(int dude, int raw) {
  char buf[4096];
  int rd;
  while (1) {
    rd = recv(raw, buf, sizeof(buf), 0);
    if (rd == -1)
      err(1, "recv()");
    if (handle_data(dude, buf, rd) == -1)
      return;
  }
}


x86 assembly (clang, -O0):
<handle_dude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1010(%rbp),%rsi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0xffffffff,-0x1014(%rbp)
jne    117b <handle_dude+0x4b>
mov    $0x1,%edi
lea    0xe8a(%rip),%rsi
call   1050 <err@plt>
mov    -0x4(%rbp),%edi
lea    -0x1010(%rbp),%rsi
mov    -0x1014(%rbp),%edx
call   1040 <handle_data@plt>
cmp    $0xffffffff,%eax
jne    11a2 <handle_dude+0x72>
add    $0x1020,%rsp
pop    %rbp
ret
jmp    1141 <handle_dude+0x11>

x86 assembly (clang, -O2):
<handle_dude>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %esi,%r14d
mov    %edi,%r12d
mov    %rsp,%rbx
lea    0xeb1(%rip),%r15
jmp    1172 <handle_dude+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <handle_data@plt>
cmp    $0xffffffff,%eax
je     119a <handle_dude+0x6a>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1160 <handle_dude+0x30>
mov    $0x1,%edi
mov    %r15,%rsi
call   1050 <err@plt>
jmp    1160 <handle_dude+0x30>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"recv()\00"
define void @handle_dude(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4096 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
br label %7
7: ; preds = %2, %22
%8 = load i32, i32* %4
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%10 = call i32 @recv(i32 %8, i8* %9, i32 4096, i32 0)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
%16 = load i32, i32* %3
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%18 = load i32, i32* %6
%19 = call i32 @handle_data(i32 %16, i8* %17, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %15
ret void
22: ; preds = %15
br label %7
}

LLVM IR (-O2):
@.str = [7 x i8] c"recv()\00"
define void @handle_dude(i32 %0, i32 %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %10, %2
%6 = call i32 @recv(i32 %1, i8* %4, i32 4096, i32 0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = call i32 @handle_data(i32 %0, i8* %4, i32 %6)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %5
13: ; preds = %10
ret void
}