#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char a[500], b[500];
  int p = 0, i;
  printf("Enter Text: ");
  scanf("%s", a);
  i = strlen(a);
  while (i >= 0) {
    b[p] = a[i];
    p++;
    i--;
  }
  while (i <= p) {
    printf("%c", b[i]);
    i++;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x404(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x200(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x408(%rbp)
cmpl   $0x0,-0x408(%rbp)
jl     11cb <main+0x9b>
movslq -0x408(%rbp),%rax
mov    -0x200(%rbp,%rax,1),%cl
movslq -0x404(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
mov    -0x408(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x408(%rbp)
jmp    117f <main+0x4f>
jmp    11d0 <main+0xa0>
mov    -0x408(%rbp),%eax
cmp    -0x404(%rbp),%eax
jg     1213 <main+0xe3>
movslq -0x408(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%esi
ff
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    11d0 <main+0xa0>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xead(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea9(%rip),%rdi
lea    0x200(%rsp),%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
js     12fe <main+0x1be>
mov    %eax,%r8d
lea    0x1(%rax),%r15d
cmp    $0x7,%eax
jae    1197 <main+0x57>
xor    %eax,%eax
jmp    12c7 <main+0x187>
cmp    $0x1f,%eax
jae    11a3 <main+0x63>
xor    %eax,%eax
jmp    125c <main+0x11c>
mov    %r15d,%eax
and    $0xffffffe0,%eax
lea    0x10(%rsp),%rdx
mov    %rax,%rsi
neg    %rsi
lea    (%r8,%r14,1),%rdi
add    $0xfffffffffffffff1,%rdi
xor    %ecx,%ecx
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqu -0x10(%rdi,%rcx,1),%xmm1
movdqu (%rdi,%rcx,1),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqa %xmm2,-0x10(%rdx)
movdqa %xmm1,(%rdx)
add    $0x20,%rdx
add    $0xffffffffffffffe0,%rcx
cmp    %rcx,%rsi
jne    11d0 <main+0x90>
cmp    %r15,%rax
je     12f3 <main+0x1b3>
test   $0x18,%r15b
je     12c4 <main+0x184>
mov    %rax,%rcx
mov    %r15d,%eax
and    $0xfffffff8,%eax
lea    (%rsp,%rcx,1),%rdx
mov    %rax,%rsi
neg    %rsi
neg    %rcx
lea    (%r8,%r14,1),%rdi
add    $0xfffffffffffffff9,%rdi
sub    %rax,%r8
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movq   (%rdi,%rcx,1),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rdx)
add    $0x8,%rdx
add    $0xfffffffffffffff8,%rcx
cmp    %rcx,%rsi
jne    1290 <main+0x150>
cmp    %r15,%rax
jne    12c7 <main+0x187>
jmp    12f3 <main+0x1b3>
sub    %rax,%r8
lea    (%rsp,%r8,1),%rcx
add    $0x200,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rcx),%edx
mov    %dl,(%rsp,%rax,1)
add    $0x1,%rax
add    $0xffffffffffffffff,%rcx
cmp    %rax,%r15
jne    12e0 <main+0x1a0>
mov    $0xffffffff,%eax
cmp    $0xffffffff,%r15d
jl     1323 <main+0x1e3>
cltq
lea    (%rsp,%rax,1),%r14
sub    %eax,%r15d
add    $0x1,%r15d
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1310 <main+0x1d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Enter Text: \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = alloca [500 x i8]
%3 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @strlen(i8* %3)
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %65
9: ; preds = %0
%10 = zext i32 %7 to i64
%11 = add nuw i32 %7, 1
%12 = zext i32 %11 to i64
%13 = icmp ult i32 %7, 7
br i1 %13, label %60, label %14
14: ; preds = %9
%15 = icmp ult i32 %7, 31
br i1 %15, label %42, label %16
16: ; preds = %14
%17 = and i64 %12, 4294967264
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %34, %18 ]
%20 = sub i64 %10, %19
%21 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -15
%23 = bitcast i8* %22 to <16 x i8>*
%24 = load <16 x i8>, <16 x i8>* %23
%25 = shufflevector <16 x i8> %24, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%26 = getelementptr inbounds i8, i8* %21, i64 -31
%27 = bitcast i8* %26 to <16 x i8>*
%28 = load <16 x i8>, <16 x i8>* %27
%29 = shufflevector <16 x i8> %28, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%30 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %19
%31 = bitcast i8* %30 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %31
%32 = getelementptr inbounds i8, i8* %30, i64 16
%33 = bitcast i8* %32 to <16 x i8>*
store <16 x i8> %29, <16 x i8>* %33
%34 = add nuw i64 %19, 32
%35 = icmp eq i64 %34, %17
br i1 %35, label %36, label %18
36: ; preds = %18
%37 = icmp eq i64 %17, %12
br i1 %37, label %63, label %38
38: ; preds = %36
%39 = sub nsw i64 %10, %17
%40 = and i64 %12, 24
%41 = icmp eq i64 %40, 0
br i1 %41, label %60, label %42
42: ; preds = %14, %38
%43 = phi i64 [ %17, %38 ], [ 0, %14 ]
%44 = and i64 %12, 4294967288
%45 = sub nsw i64 %10, %44
br label %46
46: ; preds = %46, %42
%47 = phi i64 [ %43, %42 ], [ %56, %46 ]
%48 = sub i64 %10, %47
%49 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %48
%50 = getelementptr inbounds i8, i8* %49, i64 -7
%51 = bitcast i8* %50 to <8 x i8>*
%52 = load <8 x i8>, <8 x i8>* %51
%53 = shufflevector <8 x i8> %52, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%54 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %47
%55 = bitcast i8* %54 to <8 x i8>*
store <8 x i8> %53, <8 x i8>* %55
%56 = add nuw i64 %47, 8
%57 = icmp eq i64 %56, %44
br i1 %57, label %58, label %46
58: ; preds = %46
%59 = icmp eq i64 %44, %12
br i1 %59, label %63, label %60
60: ; preds = %9, %38, %58
%61 = phi i64 [ 0, %9 ], [ %17, %38 ], [ %44, %58 ]
%62 = phi i64 [ %10, %9 ], [ %39, %38 ], [ %45, %58 ]
br label %70
63: ; preds = %70, %58, %36
%64 = icmp slt i32 %11, -1
br i1 %64, label %88, label %65
65: ; preds = %0, %63
%66 = phi i32 [ -1, %63 ], [ %7, %0 ]
%67 = phi i32 [ %11, %63 ], [ 0, %0 ]
%68 = sext i32 %66 to i64
%69 = add nuw i32 %67, 1
br label %79
70: ; preds = %60, %70
%71 = phi i64 [ %76, %70 ], [ %61, %60 ]
%72 = phi i64 [ %77, %70 ], [ %62, %60 ]
%73 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %72
%74 = load i8, i8* %73
%75 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %71
store i8 %74, i8* %75
%76 = add nuw nsw i64 %71, 1
%77 = add nsw i64 %72, -1
%78 = icmp eq i64 %76, %12
br i1 %78, label %63, label %70
79: ; preds = %65, %79
%80 = phi i64 [ %68, %65 ], [ %85, %79 ]
%81 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %80
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = call i32 @putchar(i32 %83)
%85 = add nsw i64 %80, 1
%86 = trunc i64 %85 to i32
%87 = icmp eq i32 %69, %86
br i1 %87, label %88, label %79
88: ; preds = %79, %63
%89 = call i32 @putchar(i32 10)
ret i32 0
}