#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*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int recvLine(int pSockId, char *pOut, int pOutSize) {
  int received = 0;
  char letter;
  memset(pOut, 0, pOutSize);
  for (; received < pOutSize - 1; received++) {
    if (recv(pSockId, (char *)&letter, 1, 0) > 0) {
      pOut[received] = letter;
      if (letter == '\n')
        break;
    } else
      break;
  }
  return received;
}


x86 assembly (clang, -O0):
<recvLine>:
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    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b2 <recvLine+0x92>
mov    -0x4(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jle    119a <recvLine+0x7a>
mov    -0x19(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1195 <recvLine+0x75>
jmp    11b2 <recvLine+0x92>
jmp    119f <recvLine+0x7f>
jmp    11b2 <recvLine+0x92>
jmp    11a4 <recvLine+0x84>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <recvLine+0x27>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recvLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %edi,%r15d
xor    %ebx,%ebx
mov    %rsi,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
cmp    $0x2,%r14d
jl     1190 <recvLine+0x70>
add    $0xffffffff,%r14d
mov    %r14d,%r13d
xor    %ebx,%ebx
lea    0x7(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jle    1190 <recvLine+0x70>
movzbl 0x7(%rsp),%eax
mov    %al,0x0(%rbp,%rbx,1)
cmp    $0xa,%al
je     1190 <recvLine+0x70>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <recvLine+0x40>
mov    %r14d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @recvLine(i32 %0, i8* %1, i32 %2) {
%4 = alloca i8
%5 = tail call i32 @memset(i8* %1, i32 0, i32 %2)
%6 = add i32 %2, -1
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %25
8: ; preds = %3
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %18
%11 = phi i64 [ 0, %8 ], [ %19, %18 ]
%12 = call i64 @recv(i32 %0, i8* %4, i32 1, i32 0)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i8, i8* %4
%16 = getelementptr inbounds i8, i8* %1, i64 %11
store i8 %15, i8* %16
%17 = icmp eq i8 %15, 10
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = add nuw nsw i64 %11, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %25, label %10
21: ; preds = %10
%22 = trunc i64 %11 to i32
br label %25
23: ; preds = %14
%24 = trunc i64 %11 to i32
br label %25
25: ; preds = %18, %21, %23, %3
%26 = phi i32 [ 0, %3 ], [ %22, %21 ], [ %24, %23 ], [ %6, %18 ]
ret i32 %26
}