#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 EOF;
int getchar();
int /*<<< orphan*/ putchar(char);
int copyline(char *buffer) {
  size_t i;
  int c;
  int status = 1;
  for (i = 0; i < 81; i++)
    putchar(buffer[i]);
  while (status == 1) {
    c = getchar();
    if (c == EOF)
      status = -1;
    else if (c == '\n')
      status = 0;
    else
      putchar(c);
  }
  putchar('\n');
  return status;
}


x86 assembly (clang, -O0):
<copyline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x51,-0x10(%rbp)
jae    1168 <copyline+0x48>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113b <copyline+0x1b>
jmp    116d <copyline+0x4d>
cmpl   $0x1,-0x18(%rbp)
jne    11ca <copyline+0xaa>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
jne    119f <copyline+0x7f>
movl   $0xffffffff,-0x18(%rbp)
jmp    11c5 <copyline+0xa5>
cmpl   $0xa,-0x14(%rbp)
jne    11b5 <copyline+0x95>
movl   $0x0,-0x18(%rbp)
jmp    11c0 <copyline+0xa0>
mov    -0x14(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11c5 <copyline+0xa5>
jmp    116d <copyline+0x4d>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyline>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x51,%rbp
jne    1130 <copyline+0x10>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e97(%rip),%rbx
mov    $0xffffffff,%ebp
cmp    (%rbx),%eax
je     117c <copyline+0x5c>
nopw   0x0(%rax,%rax,1)
cmp    $0xa,%eax
je     117a <copyline+0x5a>
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
jne    1160 <copyline+0x40>
jmp    117c <copyline+0x5c>
xor    %ebp,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @copyline(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %5
store i64 0, i64* %3
br label %6
6: ; preds = %15, %1
%7 = load i64, i64* %3
%8 = icmp ult i64 %7, 81
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i64, i64* %3
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @putchar(i8 signext %13)
br label %15
15: ; preds = %9
%16 = load i64, i64* %3
%17 = add i64 %16, 1
store i64 %17, i64* %3
br label %6
18: ; preds = %6
br label %19
19: ; preds = %37, %18
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = call i32 (...) @getchar()
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 -1, i32* %5
br label %37
28: ; preds = %22
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 0, i32* %5
br label %36
32: ; preds = %28
%33 = load i32, i32* %4
%34 = trunc i32 %33 to i8
%35 = call i32 @putchar(i8 signext %34)
br label %36
36: ; preds = %32, %31
br label %37
37: ; preds = %36, %27
br label %19
38: ; preds = %19
%39 = call i32 @putchar(i8 signext 10)
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @copyline(i8* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %7, %2 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i32 @putchar(i8 signext %5)
%7 = add nuw nsw i64 %3, 1
%8 = icmp eq i64 %7, 81
br i1 %8, label %9, label %2
9: ; preds = %2
%10 = tail call i32 (...) @getchar()
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %22, label %13
13: ; preds = %9, %16
%14 = phi i32 [ %19, %16 ], [ %10, %9 ]
%15 = icmp eq i32 %14, 10
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = trunc i32 %14 to i8
%18 = tail call i32 @putchar(i8 signext %17)
%19 = tail call i32 (...) @getchar()
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %13
22: ; preds = %16, %13, %9
%23 = phi i32 [ -1, %9 ], [ -1, %16 ], [ 0, %13 ]
%24 = tail call i32 @putchar(i8 signext 10)
ret i32 %23
}