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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x28,%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 -0x40(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     1182 <main+0x62>
lea    -0x40(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
jmp    11a8 <main+0x88>
cmpl   $0x1,-0xc(%rbp)
jne    11a3 <main+0x83>
lea    -0x40(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    11a8 <main+0x88>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%rdi
mov    $0x28,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    118a <main+0x6a>
xor    %ebx,%ebx
lea    0xebc(%rip),%r14
mov    %rsp,%r15
jmp    116e <main+0x4e>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %ebp,%ebx
mov    %r15,%rdi
mov    $0x28,%esi
call   1030 <get_line@plt>
test   %eax,%eax
jle    118a <main+0x6a>
add    $0xffffffff,%eax
mov    $0x1,%ebp
cmpb   $0xa,(%rsp,%rax,1)
jne    1150 <main+0x30>
xor    %ebp,%ebp
cmp    $0x1,%ebx
mov    $0x0,%ebx
je     1150 <main+0x30>
jmp    115d <main+0x3d>
xor    %eax,%eax
add    $0x28,%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 i32
%4 = alloca [40 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %27, %0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%7 = call i32 @get_line(i8* %6, i32 40)
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 [40 x i8], [40 x i8]* %4, 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 [40 x i8], [40 x i8]* %4, 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* %3
br label %27
20: ; preds = %9
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = getelementptr inbounds [40 x i8], [40 x i8]* %4, 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* %3
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 [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = call i32 @get_line(i8* %2, i32 40)
%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 [40 x i8], [40 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, 1
br i1 %14, label %15, label %18
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 40)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %5, label %22
22: ; preds = %18, %0
ret i32 0
}