#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 */
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char *lineptr;
  lineptr = malloc(8192);
  size_t n = 8192;
  while (getline(&lineptr, &n, stdin) > 0) {
    printf("%s", lineptr);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2000,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movq   $0x2000,-0x18(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <getline@plt>
cmp    $0x0,%rax
jle    118a <main+0x5a>
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    1155 <main+0x25>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x2000,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%rsp)
movq   $0x2000,0x10(%rsp)
mov    0x2e8e(%rip),%r12
mov    (%r12),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <getline@plt>
test   %rax,%rax
jle    11b1 <main+0x81>
lea    0xe87(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <getline@plt>
test   %rax,%rax
jg     1190 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
store i32 0, i32* %1
%4 = call i8* @malloc(i32 8192)
store i8* %4, i8** %2
store i64 8192, i64* %3
br label %5
5: ; preds = %9, %0
%6 = load i32, i32* @stdin
%7 = call i64 @getline(i8** %2, i64* %3, i32 %6)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %5
12: ; preds = %5
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
%4 = tail call dereferenceable_or_null(8192) i8* @malloc(i32 8192)
store i8* %4, i8** %1
%5 = bitcast i64* %2 to i8*
store i64 8192, i64* %2
%6 = load i32, i32* @stdin
%7 = call i64 @getline(i8** %1, i64* %2, i32 %6)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %0, %9
%10 = load i8*, i8** %1
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @stdin
%13 = call i64 @getline(i8** %1, i64* %2, i32 %12)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9, %0
ret i32 0
}