#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(int, char *, char *);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
main() {
  int len;
  char line[1000];
  char newline[1000];
  while ((len = getline(line, 1000)) > 0) {
    copy(len, newline, line);
    if (newline[0] != '\0')
      printf("%s", newline);
  }
  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   1050 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    119d <main+0x6d>
mov    -0x8(%rbp),%edi
lea    -0x7e0(%rbp),%rsi
lea    -0x3f0(%rbp),%rdx
call   1040 <copy@plt>
movsbl -0x7e0(%rbp),%eax
cmp    $0x0,%eax
je     1198 <main+0x68>
lea    -0x7e0(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1142 <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
lea    0x3f0(%rsp),%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    11a1 <main+0x71>
mov    %rsp,%r14
lea    0x3f0(%rsp),%rbx
lea    0xe9c(%rip),%r15
jmp    1181 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
test   %eax,%eax
jle    11a1 <main+0x71>
mov    %eax,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <copy@plt>
cmpb   $0x0,(%rsp)
je     1170 <main+0x40>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\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 = %21, %0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = call i32 @getline(i8* %6, i32 1000)
store i32 %7, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i32, i32* %2
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%13 = call i32 @copy(i32 %10, i8* %11, i8* %12)
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %9
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %9
br label %5
22: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\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 @getline(i8* %3, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %0, %14
%8 = phi i32 [ %15, %14 ], [ %5, %0 ]
%9 = call i32 @copy(i32 %8, i8* %4, i8* %3)
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %14
14: ; preds = %12, %7
%15 = call i32 @getline(i8* %3, i32 1000)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %7, label %17
17: ; preds = %14, %0
ret i32 0
}