#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;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int recv_one_byte(int *, int);
int32_t recv_from_client(uint8_t *buf) {
  int32_t message_length;
  uint8_t c;
  memset(buf, 0, 64);
  do {
    if (recv_one_byte(&c, 15) == -1)
      return -1;
  } while (c != 30);
  if (recv_one_byte(&c, 15) == -1)
    return -1;
  message_length = c;
  for (int32_t i = 0; i < message_length && i < 64; i++) {
    if (recv_one_byte(&c, 15) == -1)
      return -1;
    buf[i] = c;
  }
  return 0;
}


x86 assembly (clang, -O0):
<recv_from_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x18(%rbp),%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
cmp    $0xffffffff,%eax
jne    115f <recv_from_client+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <recv_from_client+0xef>
jmp    1164 <recv_from_client+0x44>
cmpl   $0x1e,-0x18(%rbp)
jne    113c <recv_from_client+0x1c>
lea    -0x18(%rbp),%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
cmp    $0xffffffff,%eax
jne    1191 <recv_from_client+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <recv_from_client+0xef>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x1d(%rbp)
jge    11b9 <recv_from_client+0x99>
cmpl   $0x40,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11c9 <recv_from_client+0xa9>
jmp    1208 <recv_from_client+0xe8>
lea    -0x18(%rbp),%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
cmp    $0xffffffff,%eax
jne    11ec <recv_from_client+0xcc>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <recv_from_client+0xef>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119e <recv_from_client+0x7e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recv_from_client>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    0xc(%rsp),%rbx
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
cmp    $0xffffffff,%eax
je     1202 <recv_from_client+0xe2>
cmpl   $0x1e,0xc(%rsp)
jne    1150 <recv_from_client+0x30>
lea    0xc(%rsp),%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
cmp    $0xffffffff,%eax
je     1202 <recv_from_client+0xe2>
mov    0xc(%rsp),%r15d
test   %r15d,%r15d
jle    1200 <recv_from_client+0xe0>
lea    -0x1(%r15),%eax
cmp    $0x3f,%eax
mov    $0x3f,%ebx
cmovb  %eax,%ebx
lea    0xc(%rsp),%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
cmp    $0xffffffff,%eax
je     1202 <recv_from_client+0xe2>
add    $0x1,%ebx
add    $0xffffffffffffffff,%rbx
xor    %ecx,%ecx
lea    0xc(%rsp),%r12
mov    %rcx,%rbp
mov    0xc(%rsp),%eax
mov    %eax,(%r14,%rcx,4)
cmp    %rcx,%rbx
je     11e6 <recv_from_client+0xc6>
mov    %r12,%rdi
mov    $0xf,%esi
call   1030 <recv_one_byte@plt>
lea    0x1(%rbp),%rcx
cmp    $0xffffffff,%eax
jne    11c0 <recv_from_client+0xa0>
lea    0x1(%rbp),%rax
cmp    %r15,%rax
setb   %al
cmp    $0x3f,%rbp
setb   %cl
and    %al,%cl
movzbl %cl,%ebp
neg    %ebp
jmp    1202 <recv_from_client+0xe2>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @recv_from_client(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = call i32 @memset(i32* %7, i32 0, i32 64)
br label %9
9: ; preds = %14, %1
%10 = call i32 @recv_one_byte(i32* %5, i32 15)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 -1, i32* %2
br label %46
13: ; preds = %9
br label %14
14: ; preds = %13
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 30
br i1 %16, label %9, label %17
17: ; preds = %14
%18 = call i32 @recv_one_byte(i32* %5, i32 15)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 -1, i32* %2
br label %46
21: ; preds = %17
%22 = load i32, i32* %5
store i32 %22, i32* %4
store i32 0, i32* %6
br label %23
23: ; preds = %42, %21
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 64
br label %30
30: ; preds = %27, %23
%31 = phi i1 [ false, %23 ], [ %29, %27 ]
br i1 %31, label %32, label %45
32: ; preds = %30
%33 = call i32 @recv_one_byte(i32* %5, i32 15)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 -1, i32* %2
br label %46
36: ; preds = %32
%37 = load i32, i32* %5
%38 = load i32*, i32** %3
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
store i32 %37, i32* %41
br label %42
42: ; preds = %36
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %23
45: ; preds = %30
store i32 0, i32* %2
br label %46
46: ; preds = %45, %35, %20, %12
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
define i32 @recv_from_client(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @memset(i32* %0, i32 0, i32 64)
br label %5
5: ; preds = %8, %1
%6 = call i32 @recv_one_byte(i32* %2, i32 15)
%7 = icmp eq i32 %6, -1
br i1 %7, label %39, label %8
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 30
br i1 %10, label %11, label %5
11: ; preds = %8
%12 = call i32 @recv_one_byte(i32* %2, i32 15)
%13 = icmp eq i32 %12, -1
br i1 %13, label %39, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = zext i32 %15 to i64
%19 = add nsw i32 %15, -1
%20 = call i32 @llvm.umin.i32(i32 %19, i32 63)
%21 = add nuw nsw i32 %20, 1
%22 = zext i32 %21 to i64
%23 = call i32 @recv_one_byte(i32* %2, i32 15)
%24 = icmp eq i32 %23, -1
br i1 %24, label %39, label %28
25: ; preds = %28
%26 = call i32 @recv_one_byte(i32* %2, i32 15)
%27 = icmp eq i32 %26, -1
br i1 %27, label %34, label %28
28: ; preds = %17, %25
%29 = phi i64 [ %32, %25 ], [ 0, %17 ]
%30 = load i32, i32* %2
%31 = getelementptr inbounds i32, i32* %0, i64 %29
store i32 %30, i32* %31
%32 = add nuw nsw i64 %29, 1
%33 = icmp eq i64 %32, %22
br i1 %33, label %34, label %25
34: ; preds = %28, %25
%35 = icmp ult i64 %32, %18
%36 = icmp ult i64 %29, 63
%37 = and i1 %35, %36
%38 = sext i1 %37 to i32
br label %39
39: ; preds = %5, %14, %17, %34, %11
%40 = phi i32 [ -1, %11 ], [ 0, %14 ], [ -1, %17 ], [ %38, %34 ], [ -1, %5 ]
ret i32 %40
}