#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*/ allocate(unsigned char **, unsigned int *);
unsigned char getchar();
void eingabe(unsigned char **ein) {
  unsigned char c = 0;
  unsigned int length = 0;
  allocate(ein, &length);
  c = getchar();
  while (c != '\n') {
    (*ein)[length - 1] = c;
    allocate(ein, &length);
    c = getchar();
  }
}


x86 assembly (clang, -O0):
<eingabe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <allocate@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     118c <eingabe+0x6c>
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <allocate@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    114e <eingabe+0x2e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eingabe>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
call   1040 <allocate@plt>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     1173 <eingabe+0x53>
lea    0x4(%rsp),%r14
nopl   0x0(%rax)
mov    (%rbx),%rcx
mov    0x4(%rsp),%edx
add    $0xffffffff,%edx
mov    %al,(%rcx,%rdx,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <allocate@plt>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1150 <eingabe+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @eingabe(i8** %0) {
%2 = alloca i8**
%3 = alloca i8
%4 = alloca i32
store i8** %0, i8*** %2
store i8 0, i8* %3
store i32 0, i32* %4
%5 = load i8**, i8*** %2
%6 = call i32 @allocate(i8** %5, i32* %4)
%7 = call zeroext i8 (...) @getchar()
store i8 %7, i8* %3
br label %8
8: ; preds = %12, %1
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i8, i8* %3
%14 = load i8**, i8*** %2
%15 = load i8*, i8** %14
%16 = load i32, i32* %4
%17 = sub i32 %16, 1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 %13, i8* %19
%20 = load i8**, i8*** %2
%21 = call i32 @allocate(i8** %20, i32* %4)
%22 = call zeroext i8 (...) @getchar()
store i8 %22, i8* %3
br label %8
23: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @eingabe(i8** %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i32 @allocate(i8** %0, i32* %2)
%5 = call zeroext i8 (...) @getchar()
%6 = icmp eq i8 %5, 10
br i1 %6, label %17, label %7
7: ; preds = %1, %7
%8 = phi i8 [ %15, %7 ], [ %5, %1 ]
%9 = load i8*, i8** %0
%10 = load i32, i32* %2
%11 = add i32 %10, -1
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
store i8 %8, i8* %13
%14 = call i32 @allocate(i8** %0, i32* %2)
%15 = call zeroext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %7
17: ; preds = %7, %1
ret void
}