#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 recv(int, char *, int, int /*<<< orphan*/);
bool recv_line(int fd, char *buff) {
  char c;
  if (recv(fd, &c, 1, 0) == -1) {
    return false;
  }
  while (c != '\r') {
    *buff++ = c;
    if (recv(fd, &c, 1, 0) == -1) {
      return false;
    }
  }
  *buff = '\0';
  if (recv(fd, &c, 1, 0) == -1) {
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<recv_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
jne    1147 <recv_line+0x37>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <recv_line+0xc0>
jmp    114c <recv_line+0x3c>
movsbl -0x11(%rbp),%eax
cmp    $0xd,%eax
je     119a <recv_line+0x8a>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
jne    1195 <recv_line+0x85>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <recv_line+0xc0>
jmp    114c <recv_line+0x3c>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
jne    11c9 <recv_line+0xb9>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <recv_line+0xc0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recv_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0x7(%rsp),%rsi
xor    %ebp,%ebp
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     1188 <recv_line+0x78>
lea    0x7(%rsp),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
movzbl 0x7(%rsp),%eax
cmp    $0xd,%al
je     1168 <recv_line+0x58>
mov    %al,(%rbx)
add    $0x1,%rbx
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
jne    1140 <recv_line+0x30>
jmp    1188 <recv_line+0x78>
movb   $0x0,(%rbx)
lea    0x7(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @recv_line(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i32, i32* %4
%8 = call i32 @recv(i32 %7, i8* %6, i32 1, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %32
11: ; preds = %2
br label %12
12: ; preds = %24, %11
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 13
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i8, i8* %6
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
store i8 %17, i8* %18
%20 = load i32, i32* %4
%21 = call i32 @recv(i32 %20, i8* %6, i32 1, i32 0)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %16
store i32 0, i32* %3
br label %32
24: ; preds = %16
br label %12
25: ; preds = %12
%26 = load i8*, i8** %5
store i8 0, i8* %26
%27 = load i32, i32* %4
%28 = call i32 @recv(i32 %27, i8* %6, i32 1, i32 0)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %3
br label %32
31: ; preds = %25
store i32 1, i32* %3
br label %32
32: ; preds = %31, %30, %23, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @recv_line(i32 %0, i8* nocapture writeonly %1) {
%3 = alloca i8
%4 = call i32 @recv(i32 %0, i8* %3, i32 1, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %18, label %6
6: ; preds = %2, %10
%7 = phi i8* [ %11, %10 ], [ %1, %2 ]
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 13
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %8, i8* %7
%12 = call i32 @recv(i32 %0, i8* %3, i32 1, i32 0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %18, label %6
14: ; preds = %6
store i8 0, i8* %7
%15 = call i32 @recv(i32 %0, i8* %3, i32 1, i32 0)
%16 = icmp ne i32 %15, -1
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %10, %14, %2
%19 = phi i32 [ 0, %2 ], [ %17, %14 ], [ 0, %10 ]
ret i32 %19
}