#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 *, char *);
int /*<<< orphan*/ putchar(char);
int main() {
  int len, index, j;
  len = index = j = 0;
  char line[1024];
  while ((len = getline(line, 1024)) > 0) {
    if (len > 80) {
      index = 0;
      while (len > 0) {
        if (index > 0) {
          putchar('\t');
        }
        for (j = 0; j < 80 && j < len; ++j) {
          putchar(line[index]);
          ++index;
        }
        putchar('\n');
        len -= j;
      }
    } else {
      printf("%s", line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1050 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    123d <main+0x10d>
cmpl   $0x50,-0x8(%rbp)
jle    1225 <main+0xf5>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1220 <main+0xf0>
cmpl   $0x0,-0xc(%rbp)
jle    11a3 <main+0x73>
mov    $0x9,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x50,-0x10(%rbp)
mov    %al,-0x411(%rbp)
jge    11cb <main+0x9b>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
setl   %al
mov    %al,-0x411(%rbp)
mov    -0x411(%rbp),%al
test   $0x1,%al
jne    11de <main+0xae>
jmp    1206 <main+0xd6>
movslq -0xc(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11aa <main+0x7a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    1185 <main+0x55>
jmp    1238 <main+0x108>
lea    -0x410(%rbp),%rsi
lea    0xdcd(%rip),%rdi
call   1040 <printf@plt>
jmp    1157 <main+0x27>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    11fc <main+0xcc>
mov    %eax,%ebx
jmp    1182 <main+0x52>
nopw   0x0(%rax,%rax,1)
lea    0xe99(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <getline@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11fc <main+0xcc>
cmp    $0x51,%ebx
jb     1160 <main+0x30>
xor    %ebp,%ebp
nopl   0x0(%rax)
test   %ebp,%ebp
jle    119e <main+0x6e>
mov    $0x9,%edi
call   1030 <putchar@plt>
movslq %ebp,%rax
lea    -0x1(%rbx),%r14d
cmp    $0x4f,%r14d
mov    $0x4f,%ecx
cmovae %ecx,%r14d
mov    %r14d,%r13d
not    %r13d
lea    (%rsp,%rax,1),%r15
add    $0x1,%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15,%r12,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    %r12d,%r14d
jne    11d0 <main+0xa0>
add    %r12d,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %r13d,%ebx
test   %ebx,%ebx
jg     1190 <main+0x60>
jmp    116f <main+0x3f>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
br label %6
6: ; preds = %52, %0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = call i32 @getline(i8* %7, i32 1024)
store i32 %8, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %53
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 80
br i1 %12, label %13, label %49
13: ; preds = %10
store i32 0, i32* %3
br label %14
14: ; preds = %43, %13
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %48
17: ; preds = %14
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @putchar(i8 signext 9)
br label %22
22: ; preds = %20, %17
store i32 0, i32* %4
br label %23
23: ; preds = %40, %22
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 80
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %4
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br label %30
30: ; preds = %26, %23
%31 = phi i1 [ false, %23 ], [ %29, %26 ]
br i1 %31, label %32, label %43
32: ; preds = %30
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @putchar(i8 signext %36)
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %40
40: ; preds = %32
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %23
43: ; preds = %30
%44 = call i32 @putchar(i8 signext 10)
%45 = load i32, i32* %4
%46 = load i32, i32* %2
%47 = sub nsw i32 %46, %45
store i32 %47, i32* %2
br label %14
48: ; preds = %14
br label %52
49: ; preds = %10
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %49, %48
br label %6
53: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @getline(i8* %2, i32 1024)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %38
5: ; preds = %0, %35
%6 = phi i32 [ %36, %35 ], [ %3, %0 ]
%7 = icmp ugt i32 %6, 80
br i1 %7, label %8, label %33
8: ; preds = %5, %28
%9 = phi i32 [ %29, %28 ], [ 0, %5 ]
%10 = phi i32 [ %31, %28 ], [ %6, %5 ]
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @putchar(i8 signext 9)
br label %14
14: ; preds = %8, %12
%15 = sext i32 %9 to i64
%16 = add nsw i32 %10, -1
%17 = call i32 @llvm.umin.i32(i32 %16, i32 79)
%18 = xor i32 %17, -1
br label %19
19: ; preds = %14, %19
%20 = phi i64 [ %15, %14 ], [ %25, %19 ]
%21 = phi i32 [ 0, %14 ], [ %26, %19 ]
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %20
%23 = load i8, i8* %22
%24 = call i32 @putchar(i8 signext %23)
%25 = add nsw i64 %20, 1
%26 = add nuw nsw i32 %21, 1
%27 = icmp eq i32 %21, %17
br i1 %27, label %28, label %19
28: ; preds = %19
%29 = trunc i64 %25 to i32
%30 = call i32 @putchar(i8 signext 10)
%31 = add i32 %10, %18
%32 = icmp sgt i32 %31, 0
br i1 %32, label %8, label %35
33: ; preds = %5
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %35
35: ; preds = %28, %33
%36 = call i32 @getline(i8* %2, i32 1024)
%37 = icmp sgt i32 %36, 0
br i1 %37, label %5, label %38
38: ; preds = %35, %0
ret i32 0
}