#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 str[1000];
  char rev[1000];
  int i = 0, j = 0;
  printf("Enter any string : ");
  scanf("%s", str);
  i = strlen(str) - 1;
  while (i >= 0) {
    rev[j++] = str[i--];
  }
  rev[j] = '\0';
  printf("Reverse of string is : %s", rev);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7e4(%rbp)
movl   $0x0,-0x7e8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
cmpl   $0x0,-0x7e4(%rbp)
jl     11d2 <main+0xa2>
mov    -0x7e4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x7e4(%rbp)
cltq
mov    -0x3f0(%rbp,%rax,1),%cl
mov    -0x7e8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x7e8(%rbp)
cltq
mov    %cl,-0x7e0(%rbp,%rax,1)
jmp    118c <main+0x5c>
movslq -0x7e8(%rbp),%rax
movb   $0x0,-0x7e0(%rbp,%rax,1)
lea    -0x7e0(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
lea    0xebf(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x3f0(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    121a <main+0xea>
mov    %eax,%r14d
cmp    $0x8,%eax
jae    123d <main+0x10d>
xor    %ecx,%ecx
mov    %r14,%rdx
mov    %rcx,%rax
not    %rax
add    %r14,%rax
mov    %r14,%rsi
and    $0x3,%rsi
je     11bb <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rdx
mov    %edx,%edi
movzbl 0x3f0(%rsp,%rdi,1),%ebx
mov    %bl,(%rsp,%rcx,1)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    11a0 <main+0x70>
cmp    $0x3,%rax
jb     121a <main+0xea>
mov    $0xfffffffe,%eax
cs nopw 0x0(%rax,%rax,1)
lea    (%rdx,%rax,1),%rsi
lea    0x1(%rsi),%edi
movzbl 0x3f0(%rsp,%rdi,1),%ebx
mov    %bl,(%rsp,%rcx,1)
mov    %esi,%edi
movzbl 0x3f0(%rsp,%rdi,1),%ebx
mov    %bl,0x1(%rsp,%rcx,1)
add    $0xffffffff,%esi
movzbl 0x3f0(%rsp,%rsi,1),%ebx
mov    %bl,0x2(%rsp,%rcx,1)
add    $0xfffffffffffffffc,%rdx
mov    %edx,%esi
movzbl 0x3f0(%rsp,%rsi,1),%ebx
mov    %bl,0x3(%rsp,%rcx,1)
add    $0x4,%rcx
cmp    %rcx,%r14
jne    11d0 <main+0xa0>
movb   $0x0,(%rsp,%r14,1)
lea    0xdee(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret
lea    -0x1(%r14),%rsi
lea    -0x1(%rax),%edx
xor    %ecx,%ecx
cmp    %esi,%edx
jb     1180 <main+0x50>
mov    %rsi,%rdx
shr    $0x20,%rdx
mov    %r14,%rdx
jne    1183 <main+0x53>
cmp    $0x20,%eax
jae    126a <main+0x13a>
xor    %ecx,%ecx
jmp    131b <main+0x1eb>
mov    %r14d,%ecx
and    $0xffffffe0,%ecx
xor    %eax,%eax
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%edx
movdqu 0x3d1(%rsp,%rdx,1),%xmm1
movdqu 0x3e1(%rsp,%rdx,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,(%rsp,%rax,1)
movdqa %xmm1,0x10(%rsp,%rax,1)
add    $0x20,%rax
add    $0xffffffffffffffe0,%rsi
cmp    %rax,%rcx
jne    1280 <main+0x150>
cmp    %r14,%rcx
je     121a <main+0xea>
test   $0x18,%r14b
je     1382 <main+0x252>
mov    %rcx,%rax
mov    %r14d,%ecx
and    $0xfffffff8,%ecx
mov    %r14d,%edx
and    $0x7,%edx
mov    %rax,%rsi
not    %rsi
add    %r14,%rsi
pxor   %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
mov    %esi,%edi
movq   0x3e9(%rsp,%rdi,1),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rsp,%rax,1)
add    $0x8,%rax
add    $0xfffffffffffffff8,%rsi
cmp    %rax,%rcx
jne    1340 <main+0x210>
cmp    %r14,%rcx
jne    1183 <main+0x53>
jmp    121a <main+0xea>
mov    %r14d,%edx
and    $0x1f,%edx
jmp    1183 <main+0x53>

LLVM IR (-O0):
@.str = [20 x i8] c"Enter any string : \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Reverse of string is : %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [1000 x i8], [1000 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 [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %4
br label %12
12: ; preds = %15, %0
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %23
store i8 %20, i8* %24
br label %12
25: ; preds = %12
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter any string : \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Reverse of string is : %s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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, 0
br i1 %8, label %9, label %122
9: ; preds = %0
%10 = zext i32 %7 to i64
%11 = icmp ult i32 %7, 8
br i1 %11, label %69, label %12
12: ; preds = %9
%13 = add nsw i64 %10, -1
%14 = add i32 %7, -1
%15 = trunc i64 %13 to i32
%16 = icmp ult i32 %14, %15
%17 = icmp ugt i64 %13, 4294967295
%18 = or i1 %16, %17
br i1 %18, label %69, label %19
19: ; preds = %12
%20 = icmp ult i32 %7, 32
br i1 %20, label %49, label %21
21: ; preds = %19
%22 = and i64 %10, 4294967264
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %41, %23 ]
%25 = xor i64 %24, -1
%26 = add i64 %25, %10
%27 = and i64 %26, 4294967295
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 -15
%30 = bitcast i8* %29 to <16 x i8>*
%31 = load <16 x i8>, <16 x i8>* %30
%32 = shufflevector <16 x i8> %31, <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>
%33 = getelementptr inbounds i8, i8* %28, i64 -31
%34 = bitcast i8* %33 to <16 x i8>*
%35 = load <16 x i8>, <16 x i8>* %34
%36 = shufflevector <16 x i8> %35, <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>
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %24
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %38
%39 = getelementptr inbounds i8, i8* %37, i64 16
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %40
%41 = add nuw i64 %24, 32
%42 = icmp eq i64 %41, %22
br i1 %42, label %43, label %23
43: ; preds = %23
%44 = icmp eq i64 %22, %10
br i1 %44, label %120, label %45
45: ; preds = %43
%46 = and i64 %10, 31
%47 = and i64 %10, 24
%48 = icmp eq i64 %47, 0
br i1 %48, label %69, label %49
49: ; preds = %19, %45
%50 = phi i64 [ %22, %45 ], [ 0, %19 ]
%51 = and i64 %10, 4294967288
%52 = and i64 %10, 7
br label %53
53: ; preds = %53, %49
%54 = phi i64 [ %50, %49 ], [ %65, %53 ]
%55 = xor i64 %54, -1
%56 = add i64 %55, %10
%57 = and i64 %56, 4294967295
%58 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %57
%59 = getelementptr inbounds i8, i8* %58, i64 -7
%60 = bitcast i8* %59 to <8 x i8>*
%61 = load <8 x i8>, <8 x i8>* %60
%62 = shufflevector <8 x i8> %61, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%63 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %54
%64 = bitcast i8* %63 to <8 x i8>*
store <8 x i8> %62, <8 x i8>* %64
%65 = add nuw i64 %54, 8
%66 = icmp eq i64 %65, %51
br i1 %66, label %67, label %53
67: ; preds = %53
%68 = icmp eq i64 %51, %10
br i1 %68, label %120, label %69
69: ; preds = %12, %9, %45, %67
%70 = phi i64 [ 0, %9 ], [ 0, %12 ], [ %22, %45 ], [ %51, %67 ]
%71 = phi i64 [ %10, %9 ], [ %10, %12 ], [ %46, %45 ], [ %52, %67 ]
%72 = xor i64 %70, -1
%73 = add nsw i64 %72, %10
%74 = and i64 %10, 3
%75 = icmp eq i64 %74, 0
br i1 %75, label %88, label %76
76: ; preds = %69, %76
%77 = phi i64 [ %84, %76 ], [ %70, %69 ]
%78 = phi i64 [ %80, %76 ], [ %71, %69 ]
%79 = phi i64 [ %86, %76 ], [ 0, %69 ]
%80 = add nsw i64 %78, -1
%81 = and i64 %80, 4294967295
%82 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = add nuw nsw i64 %77, 1
%85 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %77
store i8 %83, i8* %85
%86 = add i64 %79, 1
%87 = icmp eq i64 %86, %74
br i1 %87, label %88, label %76
88: ; preds = %76, %69
%89 = phi i64 [ %70, %69 ], [ %84, %76 ]
%90 = phi i64 [ %71, %69 ], [ %80, %76 ]
%91 = icmp ult i64 %73, 3
br i1 %91, label %120, label %92
92: ; preds = %88, %92
%93 = phi i64 [ %117, %92 ], [ %89, %88 ]
%94 = phi i64 [ %113, %92 ], [ %90, %88 ]
%95 = add i64 %94, 4294967295
%96 = and i64 %95, 4294967295
%97 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %96
%98 = load i8, i8* %97
%99 = add nuw nsw i64 %93, 1
%100 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %93
store i8 %98, i8* %100
%101 = add i64 %94, 4294967294
%102 = and i64 %101, 4294967295
%103 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %102
%104 = load i8, i8* %103
%105 = add nuw nsw i64 %93, 2
%106 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %99
store i8 %104, i8* %106
%107 = add i64 %94, 4294967293
%108 = and i64 %107, 4294967295
%109 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %108
%110 = load i8, i8* %109
%111 = add nuw nsw i64 %93, 3
%112 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %105
store i8 %110, i8* %112
%113 = add nsw i64 %94, -4
%114 = and i64 %113, 4294967295
%115 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %114
%116 = load i8, i8* %115
%117 = add nuw nsw i64 %93, 4
%118 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %111
store i8 %116, i8* %118
%119 = icmp eq i64 %117, %10
br i1 %119, label %120, label %92
120: ; preds = %88, %92, %67, %43
%121 = zext i32 %7 to i64
br label %122
122: ; preds = %0, %120
%123 = phi i64 [ %121, %120 ], [ 0, %0 ]
%124 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %123
store i8 0, i8* %124
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}