#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 get_line(char *, int);
int /*<<< orphan*/ printf(char *, char *);
main() {
  int len;
  char line[3 + 1];
  int longline = 0;
  while ((len = get_line(line, 3 + 1)) > 0) {
    if (line[len - 1] != '\n') {
      printf("%s", line);
      longline = 1;
    } else if (longline) {
      printf("%s", line);
      longline = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1030 <get_line@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11ad <main+0x8d>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xc(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     1182 <main+0x62>
lea    -0xc(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    11a8 <main+0x88>
cmpl   $0x0,-0x10(%rbp)
je     11a3 <main+0x83>
lea    -0xc(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    11a8 <main+0x88>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    118a <main+0x6a>
xor    %ebx,%ebx
lea    0x4(%rsp),%r15
lea    0xeb8(%rip),%r14
jmp    116e <main+0x4e>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %ebp,%ebx
mov    %r15,%rdi
mov    $0x4,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    118a <main+0x6a>
add    $0xffffffff,%eax
mov    $0x1,%ebp
cmpb   $0xa,0x4(%rsp,%rax,1)
jne    1150 <main+0x30>
xor    %ebp,%ebp
test   %ebx,%ebx
mov    $0x0,%ebx
jne    1150 <main+0x30>
jmp    115d <main+0x3d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 [4 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %27, %0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = call i32 @get_line(i8* %6, i32 4)
store i32 %7, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %28
9: ; preds = %5
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %4
br label %27
20: ; preds = %9
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 0, i32* %4
br label %26
26: ; preds = %23, %20
br label %27
27: ; preds = %26, %17
br label %5
28: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%3 = call i32 @get_line(i8* %2, i32 4)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %22
5: ; preds = %0, %18
%6 = phi i32 [ %20, %18 ], [ %3, %0 ]
%7 = phi i32 [ %19, %18 ], [ 0, %0 ]
%8 = add nsw i32 %6, -1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %15
13: ; preds = %5
%14 = icmp eq i32 %7, 0
br i1 %14, label %18, label %15
15: ; preds = %13, %5
%16 = phi i32 [ 1, %5 ], [ 0, %13 ]
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ 0, %13 ], [ %16, %15 ]
%20 = call i32 @get_line(i8* %2, i32 4)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %5, label %22
22: ; preds = %18, %0
ret i32 0
}