#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;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ stdout;
void input(char *b, uint8_t l) {
  int c;
  fflush(stdout);
  while ((c = getchar()) != '\n') {
    if (c == EOF)
      exit(1);
    if (l > 1) {
      *b++ = c;
      l--;
    }
  }
  *b = 0;
}


x86 assembly (clang, -O0):
<input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x10(%rbp)
cmp    $0xa,%eax
je     11aa <input+0x7a>
mov    -0x10(%rbp),%eax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
jne    117c <input+0x4c>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x1,-0xc(%rbp)
jle    11a5 <input+0x75>
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <input+0x1d>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%eax
jne    115b <input+0x2b>
movb   $0x0,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e86(%rip),%r14
jmp    117c <input+0x4c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%eax
je     1153 <input+0x23>
cmp    (%r14),%eax
je     1191 <input+0x61>
cmp    $0x2,%ebp
jl     1170 <input+0x40>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%ebp
jmp    1170 <input+0x40>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@EOF = global i32 0
define void @input(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* @stdout
%7 = call i32 @fflush(i32 %6)
br label %8
8: ; preds = %27, %2
%9 = call i32 (...) @getchar()
store i32 %9, i32* %5
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load i32, i32* %5
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %11
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %5
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
store i8 %22, i8* %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, -1
store i32 %26, i32* %4
br label %27
27: ; preds = %20, %17
br label %8
28: ; preds = %8
%29 = load i8*, i8** %3
store i8 0, i8* %29
ret void
}

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