#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 getchar();
int /*<<< orphan*/ putchar(char);
int main() {
  char s[256];
  int i;
  int c = getchar();
  for (i = 0; c != -1 && i < 256; i++) {
    s[i] = c;
    c = getchar();
  }
  for (; i > 0; i--) {
    putchar(s[i - 1]);
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x118(%rbp)
movl   $0x0,-0x114(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x118(%rbp)
mov    %al,-0x119(%rbp)
je     1171 <main+0x51>
cmpl   $0x100,-0x114(%rbp)
setl   %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    1184 <main+0x64>
jmp    11bb <main+0x9b>
mov    -0x118(%rbp),%eax
mov    %al,%cl
movslq -0x114(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x118(%rbp)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1149 <main+0x29>
jmp    11c0 <main+0xa0>
cmpl   $0x0,-0x114(%rbp)
jle    11f9 <main+0xd9>
mov    -0x114(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x114(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x114(%rbp)
jmp    11c0 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xffffffff,%eax
je     1184 <main+0x64>
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %al,(%rsp,%r14,1)
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0x1(%r14),%rbx
cmp    $0xffffffff,%eax
je     1160 <main+0x40>
cmp    $0xff,%r14
mov    %rbx,%r14
jb     1140 <main+0x20>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl -0x2(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1170 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = icmp eq i32 %3, -1
br i1 %4, label %24, label %7
5: ; preds = %7
%6 = and i64 %13, 4294967295
br label %17
7: ; preds = %0, %7
%8 = phi i64 [ %13, %7 ], [ 0, %0 ]
%9 = phi i32 [ %12, %7 ], [ %3, %0 ]
%10 = trunc i32 %9 to i8
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %8
store i8 %10, i8* %11
%12 = tail call i32 (...) @getchar()
%13 = add nuw nsw i64 %8, 1
%14 = icmp ne i32 %12, -1
%15 = icmp ult i64 %8, 255
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %7, label %5
17: ; preds = %5, %17
%18 = phi i64 [ %6, %5 ], [ %19, %17 ]
%19 = add nsw i64 %18, -1
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = tail call i32 @putchar(i8 signext %21)
%23 = icmp ugt i64 %18, 1
br i1 %23, label %17, label %24
24: ; preds = %17, %0
%25 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}