#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char *s = malloc(256);
  int i, ch, len;
  fgets(s, 256, stdin);
  if (strlen(s) > 0 && s[strlen(s) - 1] == '\n') {
    s[strlen(s) - 1] = '\0';
  }
  printf("%s\n", s);
  len = strlen(s);
  for (i = 0; i < len / 2; i++) {
    ch = s[i];
    s[i] = s[len - i - 1];
    s[len - i - 1] = ch;
  }
  printf("%s\n", s);
  free(s);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jle    11f1 <main+0x91>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11f1 <main+0x91>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1285 <main+0x125>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1214 <main+0xb4>
mov    -0x10(%rbp),%rsi
lea    0xd70(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x100,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11b5 <main+0x55>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r14,1)
jne    11b5 <main+0x55>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xe44(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1249 <main+0xe9>
mov    %eax,%r8d
shr    %r8d
cmp    $0x1,%r8d
jne    11e1 <main+0x81>
xor    %edx,%edx
jmp    122b <main+0xcb>
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
lea    -0x2(%rax),%edi
xor    %edx,%edx
nopl   (%rax)
movzbl (%r14,%rdx,1),%ecx
lea    0x1(%rdi),%esi
movslq %esi,%rsi
movzbl (%r14,%rsi,1),%ebx
mov    %bl,(%r14,%rdx,1)
mov    %cl,(%r14,%rsi,1)
movzbl 0x1(%r14,%rdx,1),%ecx
movslq %edi,%rdi
movzbl (%r14,%rdi,1),%ebx
mov    %bl,0x1(%r14,%rdx,1)
mov    %cl,(%r14,%rdi,1)
add    $0x2,%rdx
add    $0xfffffffe,%edi
cmp    %rdx,%r9
jne    11f0 <main+0x90>
test   $0x1,%r8b
je     1249 <main+0xe9>
mov    (%r14,%rdx,1),%cl
mov    %edx,%esi
not    %esi
add    %esi,%eax
cltq
mov    (%r14,%rax,1),%bl
mov    %bl,(%r14,%rdx,1)
mov    %cl,(%r14,%rax,1)
lea    0xdb0(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i8* @malloc(i32 256)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 256, i32 %8)
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %30
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %14, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %30
23: ; preds = %13
%24 = load i8*, i8** %2
%25 = load i8*, i8** %2
%26 = call i32 @strlen(i8* %25)
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %24, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %23, %13, %0
%31 = load i8*, i8** %2
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %2
%34 = call i32 @strlen(i8* %33)
store i32 %34, i32* %5
store i32 0, i32* %3
br label %35
35: ; preds = %68, %30
%36 = load i32, i32* %3
%37 = load i32, i32* %5
%38 = sdiv i32 %37, 2
%39 = icmp slt i32 %36, %38
br i1 %39, label %40, label %71
40: ; preds = %35
%41 = load i8*, i8** %2
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
store i32 %46, i32* %4
%47 = load i8*, i8** %2
%48 = load i32, i32* %5
%49 = load i32, i32* %3
%50 = sub nsw i32 %48, %49
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %47, i64 %52
%54 = load i8, i8* %53
%55 = load i8*, i8** %2
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 %54, i8* %58
%59 = load i32, i32* %4
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %2
%62 = load i32, i32* %5
%63 = load i32, i32* %3
%64 = sub nsw i32 %62, %63
%65 = sub nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %61, i64 %66
store i8 %60, i8* %67
br label %68
68: ; preds = %40
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %35
71: ; preds = %35
%72 = load i8*, i8** %2
%73 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %72)
%74 = load i8*, i8** %2
%75 = call i32 @free(i8* %74)
%76 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%2 = load i32, i32* @stdin
%3 = tail call i32 @fgets(i8* %1, i32 256, i32 %2)
%4 = tail call i32 @strlen(i8* %1)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %18
6: ; preds = %0
%7 = tail call i32 @strlen(i8* %1)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %18
13: ; preds = %6
%14 = tail call i32 @strlen(i8* %1)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %13, %6, %0
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%20 = tail call i32 @strlen(i8* %1)
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %64
22: ; preds = %18
%23 = lshr i32 %20, 1
%24 = zext i32 %23 to i64
%25 = and i64 %24, 1
%26 = icmp eq i32 %23, 1
br i1 %26, label %52, label %27
27: ; preds = %22
%28 = and i64 %24, 2147483646
br label %29
29: ; preds = %29, %27
%30 = phi i64 [ 0, %27 ], [ %49, %29 ]
%31 = phi i64 [ 0, %27 ], [ %50, %29 ]
%32 = getelementptr inbounds i8, i8* %1, i64 %30
%33 = load i8, i8* %32
%34 = trunc i64 %30 to i32
%35 = xor i32 %34, -1
%36 = add i32 %20, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %1, i64 %37
%39 = load i8, i8* %38
store i8 %39, i8* %32
store i8 %33, i8* %38
%40 = or i64 %30, 1
%41 = getelementptr inbounds i8, i8* %1, i64 %40
%42 = load i8, i8* %41
%43 = trunc i64 %40 to i32
%44 = xor i32 %43, -1
%45 = add i32 %20, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %1, i64 %46
%48 = load i8, i8* %47
store i8 %48, i8* %41
store i8 %42, i8* %47
%49 = add nuw nsw i64 %30, 2
%50 = add i64 %31, 2
%51 = icmp eq i64 %50, %28
br i1 %51, label %52, label %29
52: ; preds = %29, %22
%53 = phi i64 [ 0, %22 ], [ %49, %29 ]
%54 = icmp eq i64 %25, 0
br i1 %54, label %64, label %55
55: ; preds = %52
%56 = getelementptr inbounds i8, i8* %1, i64 %53
%57 = load i8, i8* %56
%58 = trunc i64 %53 to i32
%59 = xor i32 %58, -1
%60 = add i32 %20, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %1, i64 %61
%63 = load i8, i8* %62
store i8 %63, i8* %56
store i8 %57, i8* %62
br label %64
64: ; preds = %55, %52, %18
%65 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%66 = tail call i32 @free(i8* %1)
%67 = tail call i32 @exit(i32 0)
unreachable
}