#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 /*<<< orphan*/ copy(char *, char *);
int entab(char *, char *, int);
int getlinelength(char *, int);
int /*<<< orphan*/ printf(char *, char *);
main() {
  int length;
  char line[1000];
  char aux[1000];
  while ((length = getlinelength(line, 1000)) > 0) {
    length = entab(line, aux, length);
    copy(line, aux);
    printf("%s\n", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <getlinelength@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11b3 <main+0x73>
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <entab@plt>
mov    %eax,-0x8(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
call   1040 <copy@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x7e0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1060 <getlinelength@plt>
test   %eax,%eax
jle    11a4 <main+0x64>
mov    %rsp,%rbx
lea    0x3f0(%rsp),%r14
lea    0xe91(%rip),%r15
nop
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <entab@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <copy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1060 <getlinelength@plt>
test   %eax,%eax
jg     1170 <main+0x30>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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