#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 getaline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
main() {
  char line[1000];
  int len = 0, i;
  for (len = getaline(line, 1000); len > 1; len = getaline(line, 1000)) {
    (len >= 80) ? printf("%s", line) : printf("%i\n", len);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <getaline@plt>
mov    %eax,-0x3f4(%rbp)
cmpl   $0x1,-0x3f4(%rbp)
jle    11b7 <main+0x97>
cmpl   $0x50,-0x3f4(%rbp)
jl     1187 <main+0x67>
lea    -0x3f0(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    119b <main+0x7b>
mov    -0x3f4(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <getaline@plt>
mov    %eax,-0x3f4(%rbp)
jmp    1153 <main+0x33>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1030 <getaline@plt>
cmp    $0x2,%eax
jl     1192 <main+0x72>
lea    0xebb(%rip),%r14
mov    %rsp,%rbx
lea    0xeb4(%rip),%r15
jmp    117e <main+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1030 <getaline@plt>
cmp    $0x1,%eax
jle    1192 <main+0x72>
cmp    $0x50,%eax
jb     1160 <main+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116c <main+0x4c>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%i\0A\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 @getaline(i8* %2, i32 1000)
%4 = icmp sgt i32 %3, 1
br i1 %4, label %5, label %15
5: ; preds = %0, %12
%6 = phi i32 [ %13, %12 ], [ %3, %0 ]
%7 = icmp ugt i32 %6, 79
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %12
10: ; preds = %5
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %12
12: ; preds = %8, %10
%13 = call i32 @getaline(i8* %2, i32 1000)
%14 = icmp sgt i32 %13, 1
br i1 %14, label %5, label %15
15: ; preds = %12, %0
ret i32 0
}