#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 my_getline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int c;
  int len = 0;
  char line[81];
  while ((len = my_getline(line, 81)) > 0) {
    if ((len == 81 - 1) && line[len - 1] != '\n') {
      printf("this line is longer than 80 characters - %s", line);
      while ((c = getchar()) != EOF && c != '\n')
        putchar(c);
      putchar('\n');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x51,%esi
call   1060 <my_getline@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    11f9 <main+0xb9>
cmpl   $0x50,-0xc(%rbp)
jne    11f4 <main+0xb4>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11f4 <main+0xb4>
lea    -0x60(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
mov    0x2e33(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x61(%rbp)
je     11ca <main+0x8a>
cmpl   $0xa,-0x8(%rbp)
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    11da <main+0x9a>
jmp    11ea <main+0xaa>
mov    -0x8(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsp,%rdi
mov    $0x51,%esi
call   1060 <my_getline@plt>
test   %eax,%eax
jle    11ca <main+0x8a>
mov    %rsp,%r15
lea    0xe9c(%rip),%r14
mov    0x2e7d(%rip),%rbx
jmp    118b <main+0x4b>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    $0x51,%esi
call   1060 <my_getline@plt>
test   %eax,%eax
jle    11ca <main+0x8a>
cmp    $0x50,%eax
jne    117a <main+0x3a>
cmpb   $0xa,0x4f(%rsp)
je     117a <main+0x3a>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     1170 <main+0x30>
cmp    (%rbx),%eax
je     1170 <main+0x30>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"this line is longer than 80 characters - %s\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [81 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %38, %0
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%7 = call i32 @my_getline(i8* %6, i32 81)
store i32 %7, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %39
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 80
br i1 %11, label %12, label %38
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %38
20: ; preds = %12
%21 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %32, %20
%24 = call i32 (...) @getchar()
store i32 %24, i32* %2
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %2
%29 = icmp ne i32 %28, 10
br label %30
30: ; preds = %27, %23
%31 = phi i1 [ false, %23 ], [ %29, %27 ]
br i1 %31, label %32, label %36
32: ; preds = %30
%33 = load i32, i32* %2
%34 = trunc i32 %33 to i8
%35 = call i32 @putchar(i8 signext %34)
br label %23
36: ; preds = %30
%37 = call i32 @putchar(i8 signext 10)
br label %38
38: ; preds = %36, %12, %9
br label %5
39: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"this line is longer than 80 characters - %s\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca [81 x i8]
%2 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%3 = call i32 @my_getline(i8* %2, i32 81)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %34
5: ; preds = %0
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 79
br label %7
7: ; preds = %5, %31
%8 = phi i32 [ %3, %5 ], [ %32, %31 ]
%9 = icmp ne i32 %8, 80
%10 = load i8, i8* %6
%11 = icmp eq i8 %10, 10
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %31, label %13
13: ; preds = %7
%14 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %2)
%15 = call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
%18 = icmp ne i32 %15, 10
%19 = and i1 %18, %17
br i1 %19, label %20, label %29
20: ; preds = %13, %20
%21 = phi i32 [ %24, %20 ], [ %15, %13 ]
%22 = trunc i32 %21 to i8
%23 = call i32 @putchar(i8 signext %22)
%24 = call i32 (...) @getchar()
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %24, %25
%27 = icmp ne i32 %24, 10
%28 = and i1 %27, %26
br i1 %28, label %20, label %29
29: ; preds = %20, %13
%30 = call i32 @putchar(i8 signext 10)
br label %31
31: ; preds = %29, %7
%32 = call i32 @my_getline(i8* %2, i32 81)
%33 = icmp sgt i32 %32, 0
br i1 %33, label %7, label %34
34: ; preds = %31, %0
ret i32 0
}