#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 ap_getline(char **, int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char *line = NULL;
  int len = 0;
  while (!feof(stdin)) {
    len = ap_getline(&line, stdin);
    printf("%s", line);
    free(line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1181 <main+0x41>
jmp    11b4 <main+0x74>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdi
call   1050 <ap_getline@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    115e <main+0x1e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2e8f(%rip),%rbx
mov    (%rbx),%edi
call   1060 <feof@plt>
test   %eax,%eax
jne    119c <main+0x5c>
lea    0x8(%rsp),%r14
lea    0xe90(%rip),%r15
mov    (%rbx),%esi
mov    %r14,%rdi
call   1050 <ap_getline@plt>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%rbx),%edi
call   1060 <feof@plt>
test   %eax,%eax
je     1170 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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 i32
store i32 0, i32* %1
store i8* null, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %9, %0
%5 = load i32, i32* @stdin
%6 = call i32 @feof(i32 %5)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %16
9: ; preds = %4
%10 = load i32, i32* @stdin
%11 = call i32 @ap_getline(i8** %2, i32 %10)
store i32 %11, i32* %3
%12 = load i8*, i8** %2
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
br label %4
16: ; preds = %4
ret i32 0
}

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