#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*/ feof(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ stdin;
unsigned int readInput(char *buff, unsigned int len) {
  size_t count = 0;
  char c;
  while ((c = getchar()) != '\n' && !feof(stdin)) {
    if (count < (len - 1)) {
      buff[count] = c;
      count++;
    }
  }
  buff[count] = '\x00';
  return count;
}


x86 assembly (clang, -O0):
<readInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     116b <readInput+0x4b>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    117b <readInput+0x5b>
jmp    11af <readInput+0x8f>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
cmp    %rcx,%rax
jae    11aa <readInput+0x8a>
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <readInput+0x17>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readInput>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    114f <readInput+0x2f>
movb   $0x0,(%r14,%r12,1)
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %eax,%ebx
add    $0xffffffff,%r15d
mov    0x2e8c(%rip),%r13
xor    %r12d,%r12d
jmp    117d <readInput+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%al
je     113d <readInput+0x1d>
mov    0x0(%r13),%edi
call   1040 <feof@plt>
test   %eax,%eax
jne    113d <readInput+0x1d>
cmp    %r15,%r12
jae    1170 <readInput+0x50>
mov    %bl,(%r14,%r12,1)
add    $0x1,%r12
jmp    1170 <readInput+0x50>

LLVM IR (-O0):
@stdin = global i32 0
define i32 @readInput(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i64 0, i64* %5
br label %7
7: ; preds = %31, %2
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %6
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i32, i32* @stdin
%13 = call i32 @feof(i32 %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br label %16
16: ; preds = %11, %7
%17 = phi i1 [ false, %7 ], [ %15, %11 ]
br i1 %17, label %18, label %32
18: ; preds = %16
%19 = load i64, i64* %5
%20 = load i32, i32* %4
%21 = sub i32 %20, 1
%22 = zext i32 %21 to i64
%23 = icmp ult i64 %19, %22
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i8, i8* %6
%26 = load i8*, i8** %3
%27 = load i64, i64* %5
%28 = getelementptr inbounds i8, i8* %26, i64 %27
store i8 %25, i8* %28
%29 = load i64, i64* %5
%30 = add i64 %29, 1
store i64 %30, i64* %5
br label %31
31: ; preds = %24, %18
br label %7
32: ; preds = %16
%33 = load i8*, i8** %3
%34 = load i64, i64* %5
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8 0, i8* %35
%36 = load i64, i64* %5
%37 = trunc i64 %36 to i32
ret i32 %37
}

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