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

/* Variables and functions */
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, size_t, char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char *line = NULL;
  size_t size = 0;
  ssize_t ret;
  while ((ret = getline(&line, &size, stdin)) != -1)
    printf("(%lu) %s", size, line);
  return 0;
}


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    0x2ea2(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     117a <main+0x5a>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%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,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2ea4(%rip),%r12
mov    (%r12),%edx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <getline@plt>
cmp    $0xffffffff,%eax
je     1196 <main+0x76>
lea    0xe9d(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rbx
nopl   (%rax)
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <getline@plt>
cmp    $0xffffffff,%eax
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [9 x i8] c"(%lu) %s\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 i32 @getline(i8** %1, i64* %2, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %15, label %8
8: ; preds = %0, %8
%9 = load i64, i64* %2
%10 = load i8*, i8** %1
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %9, i8* %10)
%12 = load i32, i32* @stdin
%13 = call i32 @getline(i8** %1, i64* %2, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %8
15: ; preds = %8, %0
ret i32 0
}