#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*/ empty();
int /*<<< orphan*/ full();
char getchar();
int pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char);
int main() {
  char ch;
  while ((ch = getchar()) != '\n') {
    if (!full()) {
      push(ch);
    }
  }
  while (!empty()) {
    printf("%c", pop());
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11a3 <main+0x43>
mov    $0x0,%al
call   1080 <full@plt>
cmp    $0x0,%eax
jne    119e <main+0x3e>
movsbl -0x5(%rbp),%edi
call   1070 <push@plt>
jmp    116f <main+0xf>
jmp    11a8 <main+0x48>
mov    $0x0,%al
call   1050 <empty@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c4 <main+0x64>
jmp    11e0 <main+0x80>
mov    $0x0,%al
call   1040 <pop@plt>
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <main+0x48>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     11ae <main+0x4e>
mov    %eax,%ebx
jmp    117d <main+0x1d>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%al
je     11ae <main+0x4e>
xor    %eax,%eax
call   1080 <full@plt>
test   %eax,%eax
jne    1170 <main+0x10>
movsbl %bl,%edi
call   1070 <push@plt>
jmp    1170 <main+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <pop@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <empty@plt>
test   %eax,%eax
je     11a0 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %13, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = call i32 (...) @full()
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i8, i8* %2
%12 = call i32 @push(i8 signext %11)
br label %13
13: ; preds = %10, %7
br label %3
14: ; preds = %3
br label %15
15: ; preds = %19, %14
%16 = call i32 (...) @empty()
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = call i32 (...) @pop()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %15
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = icmp eq i8 %1, 10
br i1 %2, label %3, label %6
3: ; preds = %12, %0
%4 = tail call i32 (...) @empty()
%5 = icmp eq i32 %4, 0
br i1 %5, label %15, label %20
6: ; preds = %0, %12
%7 = phi i8 [ %13, %12 ], [ %1, %0 ]
%8 = tail call i32 (...) @full()
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @push(i8 signext %7)
br label %12
12: ; preds = %10, %6
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %3, label %6
15: ; preds = %3, %15
%16 = tail call i32 (...) @pop()
%17 = tail call i32 @putchar(i32 %16)
%18 = tail call i32 (...) @empty()
%19 = icmp eq i32 %18, 0
br i1 %19, label %15, label %20
20: ; preds = %15, %3
%21 = tail call i32 @putchar(i32 10)
ret i32 0
}