#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 uint8_t;
struct rudp {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int rudp_recv(struct rudp *, char *);
void dump_recv(struct rudp *U) {
  char tmp[(0x7fff - 4)];
  int n;
  while ((n = rudp_recv(U, tmp))) {
    if (n < 0) {
      printf("CORRPUT\n");
      break;
    }
    int i;
    printf("RECV ");
    for (i = 0; i < n; i++) {
      printf("%02x ", (uint8_t)tmp[i]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump_recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8020,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8010(%rbp),%rsi
call   1030 <rudp_recv@plt>
mov    %eax,-0x8014(%rbp)
cmp    $0x0,%eax
je     11dc <dump_recv+0xbc>
cmpl   $0x0,-0x8014(%rbp)
jge    116e <dump_recv+0x4e>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11dc <dump_recv+0xbc>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8018(%rbp)
mov    -0x8018(%rbp),%eax
cmp    -0x8014(%rbp),%eax
jge    11c9 <dump_recv+0xa9>
movslq -0x8018(%rbp),%rax
movsbl -0x8010(%rbp,%rax,1),%esi
ff
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8018(%rbp)
jmp    1186 <dump_recv+0x66>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    112f <dump_recv+0xf>
add    $0x8020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_recv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8008,%rsp
mov    %rdi,%r15
mov    %rsp,%rsi
call   1040 <rudp_recv@plt>
test   %eax,%eax
je     11e0 <dump_recv+0xa0>
mov    %eax,%ebp
lea    0xe93(%rip),%r14
lea    0xe92(%rip),%r13
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
test   %ebp,%ebp
js     11d4 <dump_recv+0x94>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <dump_recv+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <rudp_recv@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1180 <dump_recv+0x40>
jmp    11e0 <dump_recv+0xa0>
lea    0xe31(%rip),%rdi
call   1050 <puts@plt>
add    $0x8008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rudp = type { i32 }
@.str = [9 x i8] c"CORRPUT\0A\00"
@.str.1 = [6 x i8] c"RECV \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @dump_recv(%struct.rudp* %0) {
%2 = alloca %struct.rudp*
%3 = alloca [32763 x i8]
%4 = alloca i32
%5 = alloca i32
store %struct.rudp* %0, %struct.rudp** %2
br label %6
6: ; preds = %32, %1
%7 = load %struct.rudp*, %struct.rudp** %2
%8 = getelementptr inbounds [32763 x i8], [32763 x i8]* %3, i64 0, i64 0
%9 = call i32 @rudp_recv(%struct.rudp* %7, i8* %8)
store i32 %9, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %34
11: ; preds = %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %34
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %18
18: ; preds = %29, %16
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [32763 x i8], [32763 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %18
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %6
34: ; preds = %14, %6
ret void
}

LLVM IR (-O2):
%struct.rudp = type { i32 }
@.str.1 = [6 x i8] c"RECV \00"
@.str.2 = [6 x i8] c"%02x \00"
@str = [8 x i8] c"CORRPUT\00"
define void @dump_recv(%struct.rudp* %0) {
%2 = alloca [32763 x i8]
%3 = getelementptr inbounds [32763 x i8], [32763 x i8]* %2, i64 0, i64 0
%4 = call i32 @rudp_recv(%struct.rudp* %0, i8* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %1, %22
%7 = phi i32 [ %24, %22 ], [ %4, %1 ]
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %26
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = zext i32 %7 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %20, %14 ]
%16 = getelementptr inbounds [32763 x i8], [32763 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14
%23 = call i32 @putchar(i32 10)
%24 = call i32 @rudp_recv(%struct.rudp* %0, i8* %3)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %6
26: ; preds = %22, %1, %9
ret void
}