#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  char line[20];
  while (fgets(line, 20, stdin) != NULL && line[0] != '\n')
    fputs(line, stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2eae(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1040 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1165 <main+0x45>
movsbl -0x20(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1175 <main+0x55>
jmp    118c <main+0x6c>
lea    -0x20(%rbp),%rdi
mov    0x2e58(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2eb8(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x14,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1186 <main+0x66>
cmpb   $0xa,(%rsp)
je     1186 <main+0x66>
mov    0x2e86(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%esi
mov    %rbx,%rdi
call   1030 <fputs@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1186 <main+0x66>
cmpb   $0xa,(%rsp)
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %15, %0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 20, i32 %5)
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br label %13
13: ; preds = %8, %3
%14 = phi i1 [ false, %3 ], [ %12, %8 ]
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%17 = load i32, i32* @stdout
%18 = call i32 @fputs(i8* %16, i32 %17)
br label %3
19: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32* @fgets(i8* %2, i32 20, i32 %3)
%5 = icmp ne i32* %4, null
%6 = load i8, i8* %2
%7 = icmp ne i8 %6, 10
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %18
9: ; preds = %0, %9
%10 = load i32, i32* @stdout
%11 = call i32 @fputs(i8* %2, i32 %10)
%12 = load i32, i32* @stdin
%13 = call i32* @fgets(i8* %2, i32 20, i32 %12)
%14 = icmp ne i32* %13, null
%15 = load i8, i8* %2
%16 = icmp ne i8 %15, 10
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %9, label %18
18: ; preds = %9, %0
ret i32 0
}