#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, char *);
int main(void) {
  char str[20];
  int i = 0, j;
  while (scanf("%c", &str[i]) != EOF)
    i++;
  for (j = i - 2; j >= 0; j--)
    printf("%c", str[j]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rsi
add    %rax,%rsi
lea    0xeb8(%rip),%rdi
call   1040 <scanf@plt>
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
je     116b <main+0x4b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1136 <main+0x16>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     11a3 <main+0x83>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1174 <main+0x54>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xfffffffd,%ebp
mov    $0xffffffffffffffff,%rbx
lea    0xec3(%rip),%r14
mov    0x2ea4(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rsp,%rbx,1),%rsi
add    $0x1,%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
add    $0x1,%ebp
add    $0x1,%rbx
cmp    (%r15),%rax
jne    1150 <main+0x30>
test   $0xfffffffe,%ebx
je     1193 <main+0x73>
mov    %ebp,%eax
add    $0x1,%ebp
lea    (%rsp,%rax,1),%rbx
nopl   (%rax)
movsbl (%rbx),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rbx
test   %ebp,%ebp
jg     1180 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %7
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 2
store i32 %17, i32* %4
br label %18
18: ; preds = %28, %15
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
store i32 %30, i32* %4
br label %18
31: ; preds = %18
%32 = 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):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ %9, %3 ], [ 0, %0 ]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %4
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
%9 = add nuw i64 %4, 1
br i1 %8, label %10, label %3
10: ; preds = %3
%11 = and i64 %4, 4294967294
%12 = icmp eq i64 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %10
%14 = add i64 %4, 4294967294
%15 = and i64 %14, 4294967295
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ %15, %13 ], [ %22, %16 ]
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 @putchar(i32 %20)
%22 = add nsw i64 %17, -1
%23 = trunc i64 %17 to i32
%24 = icmp sgt i32 %23, 0
br i1 %24, label %16, label %25
25: ; preds = %16, %10
%26 = call i32 @putchar(i32 10)
ret i32 0
}