#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 _getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int length;
  char line[1000];
  while ((length = _getline(line, 1000)) > 0) {
    printf("line length was: %d\n", length);
    if (length > 80) {
      printf("%s", line);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <_getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1184 <main+0x64>
mov    -0x8(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x50,-0x8(%rbp)
jle    117f <main+0x5f>
lea    -0x3f0(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1132 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <_getline@plt>
test   %eax,%eax
jle    1193 <main+0x73>
mov    %eax,%ebp
lea    0xeb9(%rip),%r15
lea    0xec7(%rip),%r14
mov    %rsp,%rbx
jmp    1173 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1040 <_getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1193 <main+0x73>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x51,%ebp
jb     1160 <main+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"line length was: %d\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %16, %0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = call i32 @_getline(i8* %5, i32 1000)
store i32 %6, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 80
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %8
br label %4
17: ; preds = %4
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [21 x i8] c"line length was: %d\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i32 @_getline(i8* %2, i32 1000)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %0, %11
%6 = phi i32 [ %12, %11 ], [ %3, %0 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp ugt i32 %6, 80
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %11
11: ; preds = %9, %5
%12 = call i32 @_getline(i8* %2, i32 1000)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %5, label %14
14: ; preds = %11, %0
ret i32 0
}