#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 */
char getchar();
int getLine(char *line) {
  char *a, b;
  int i, size = 0;
  a = line;
  b = getchar();
  while (b != '\n' && size < 80) {
    *(a + size) = b;
    size++;
    b = getchar();
  }
  return size;
}


x86 assembly (clang, -O0):
<getLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1d(%rbp)
je     1151 <getLine+0x41>
cmpl   $0x50,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1161 <getLine+0x51>
jmp    1187 <getLine+0x77>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x11(%rbp)
jmp    1135 <getLine+0x25>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLine>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     114c <getLine+0x3c>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %al,(%r14,%rbx,1)
lea    0x1(%rbx),%r15
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     114c <getLine+0x3c>
cmp    $0x4f,%rbx
mov    %r15,%rbx
jb     1130 <getLine+0x20>
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @getLine(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %6
%7 = load i8*, i8** %2
store i8* %7, i8** %3
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %4
br label %9
9: ; preds = %18, %1
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 80
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %27
18: ; preds = %16
%19 = load i8, i8* %4
%20 = load i8*, i8** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
%26 = call signext i8 (...) @getchar()
store i8 %26, i8* %4
br label %9
27: ; preds = %16
%28 = load i32, i32* %6
ret i32 %28
}

LLVM IR (-O2):
define i32 @getLine(i8* nocapture writeonly %0) {
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %15, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %8, %4 ], [ 0, %1 ]
%6 = phi i8 [ %9, %4 ], [ %2, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
store i8 %6, i8* %7
%8 = add nuw nsw i64 %5, 1
%9 = tail call signext i8 (...) @getchar()
%10 = icmp ne i8 %9, 10
%11 = icmp ult i64 %5, 79
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %4, label %13
13: ; preds = %4
%14 = trunc i64 %8 to i32
br label %15
15: ; preds = %13, %1
%16 = phi i32 [ 0, %1 ], [ %14, %13 ]
ret i32 %16
}