#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*/ free(char *);
scalar_t__ getLine(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char *line = NULL;
  size_t size = 0;
  while (getLine(&line, &size, stdin) > 0) {
    printf("read: %s\n", line);
  }
  free(line);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <getLine@plt>
cmp    $0x0,%rax
jle    1184 <main+0x54>
mov    -0x10(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
jmp    114f <main+0x1f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
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
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e94(%rip),%r12
mov    (%r12),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <getLine@plt>
test   %rax,%rax
jle    11a1 <main+0x71>
lea    0xe8d(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%rbx
nopl   (%rax)
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <getLine@plt>
test   %rax,%rax
jg     1180 <main+0x50>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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