#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reverse(char *);
int main() {
  int c, n;
  char buf[100];
  n = 0;
  while ((c = getchar()) != EOF) {
    if (c != '\n') {
      if (n < 100) {
        buf[n++] = c;
      }
    } else {
      if (n < 100) {
        buf[n] = '\0';
      } else {
        buf[--n] = '\0';
      }
      reverse(buf);
      printf("%s\n", buf);
      n = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11db <main+0xab>
cmpl   $0xa,-0x8(%rbp)
je     118e <main+0x5e>
cmpl   $0x64,-0xc(%rbp)
jge    1189 <main+0x59>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
cltq
mov    %cl,-0x70(%rbp,%rax,1)
jmp    11d6 <main+0xa6>
cmpl   $0x64,-0xc(%rbp)
jge    11a6 <main+0x76>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
jmp    11b6 <main+0x86>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x70(%rbp),%rsi
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9f(%rip),%r12
cmp    (%r12),%eax
jne    115d <main+0x2d>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsp,%r15
lea    0xe99(%rip),%r14
xor    %ebx,%ebx
jmp    11a3 <main+0x73>
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%eax
cmp    $0x64,%ebx
movslq %ebx,%rcx
cmovge %rax,%rcx
movb   $0x0,(%rsp,%rcx,1)
mov    %r15,%rdi
call   1030 <reverse@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r12),%eax
je     114f <main+0x1f>
cmp    $0xa,%eax
je     1170 <main+0x40>
cmp    $0x63,%ebx
jg     1196 <main+0x66>
movslq %ebx,%rcx
add    $0x1,%ebx
mov    %al,(%rsp,%rcx,1)
jmp    1196 <main+0x66>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %40, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %41
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 100
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %2
%17 = trunc i32 %16 to i8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %20
store i8 %17, i8* %21
br label %22
22: ; preds = %15, %12
br label %40
23: ; preds = %9
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 100
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %28
store i8 0, i8* %29
br label %35
30: ; preds = %23
%31 = load i32, i32* %3
%32 = add nsw i32 %31, -1
store i32 %32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %33
store i8 0, i8* %34
br label %35
35: ; preds = %30, %26
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%37 = call i32 @reverse(i8* %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38)
store i32 0, i32* %3
br label %40
40: ; preds = %35, %22
br label %5
41: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %30, label %6
6: ; preds = %0, %25
%7 = phi i32 [ %27, %25 ], [ %3, %0 ]
%8 = phi i32 [ %26, %25 ], [ 0, %0 ]
%9 = icmp eq i32 %7, 10
%10 = icmp slt i32 %8, 100
br i1 %9, label %17, label %11
11: ; preds = %6
br i1 %10, label %12, label %25
12: ; preds = %11
%13 = trunc i32 %7 to i8
%14 = add nsw i32 %8, 1
%15 = sext i32 %8 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %15
store i8 %13, i8* %16
br label %25
17: ; preds = %6
%18 = add nsw i32 %8, -1
%19 = zext i32 %18 to i64
%20 = sext i32 %8 to i64
%21 = select i1 %10, i64 %20, i64 %19
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %21
store i8 0, i8* %22
%23 = call i32 @reverse(i8* %2)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %25
25: ; preds = %11, %12, %17
%26 = phi i32 [ %14, %12 ], [ %8, %11 ], [ 0, %17 ]
%27 = call i32 (...) @getchar()
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %6
30: ; preds = %25, %0
ret i32 0
}