#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 scanf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char a[50], t;
  int i, n;
  printf("Input String : ");
  n = (scanf("%[^\n]%*c", a), strlen(a));
  for (i = 0; i < n / 2; i++) {
    t = a[i];
    a[i] = a[n - 1 - i];
    a[n - 1 - i] = t;
  }
  printf("%s\n", a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
cmp    %ecx,%eax
jge    11d0 <main+0xa0>
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0x41(%rbp)
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
sub    -0x48(%rbp),%eax
cltq
mov    -0x40(%rbp,%rax,1),%cl
movslq -0x48(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x41(%rbp),%cl
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
sub    -0x48(%rbp),%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1170 <main+0x40>
lea    -0x40(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11df <main+0x9f>
mov    %eax,%r8d
shr    %r8d
cmp    $0x1,%r8d
jne    1182 <main+0x42>
xor    %edx,%edx
jmp    11c5 <main+0x85>
mov    %r8d,%esi
and    $0xfffffffe,%esi
lea    -0x2(%rax),%edi
xor    %edx,%edx
nopl   (%rax)
movzbl (%rsp,%rdx,1),%r9d
lea    0x1(%rdi),%ecx
movslq %ecx,%rcx
movzbl (%rsp,%rcx,1),%ebx
mov    %bl,(%rsp,%rdx,1)
mov    %r9b,(%rsp,%rcx,1)
movzbl 0x1(%rsp,%rdx,1),%ecx
movslq %edi,%rdi
movzbl (%rsp,%rdi,1),%ebx
mov    %bl,0x1(%rsp,%rdx,1)
mov    %cl,(%rsp,%rdi,1)
add    $0x2,%rdx
add    $0xfffffffe,%edi
cmp    %rdx,%rsi
jne    1190 <main+0x50>
test   $0x1,%r8b
je     11df <main+0x9f>
mov    (%rsp,%rdx,1),%cl
mov    %edx,%esi
not    %esi
add    %esi,%eax
cltq
mov    (%rsp,%rax,1),%bl
mov    %bl,(%rsp,%rdx,1)
mov    %cl,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"Input String : \00"
@.str.1 = [9 x i8] c"%[^\0A]%*c\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %49
7: ; preds = %0
%8 = lshr i32 %5, 1
%9 = zext i32 %8 to i64
%10 = and i64 %9, 1
%11 = icmp eq i32 %8, 1
br i1 %11, label %37, label %12
12: ; preds = %7
%13 = and i64 %9, 2147483646
br label %14
14: ; preds = %14, %12
%15 = phi i64 [ 0, %12 ], [ %34, %14 ]
%16 = phi i64 [ 0, %12 ], [ %35, %14 ]
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %15
%18 = load i8, i8* %17
%19 = trunc i64 %15 to i32
%20 = xor i32 %19, -1
%21 = add i32 %5, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
store i8 %24, i8* %17
store i8 %18, i8* %23
%25 = or i64 %15, 1
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = trunc i64 %25 to i32
%29 = xor i32 %28, -1
%30 = add i32 %5, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
store i8 %33, i8* %26
store i8 %27, i8* %32
%34 = add nuw nsw i64 %15, 2
%35 = add i64 %16, 2
%36 = icmp eq i64 %35, %13
br i1 %36, label %37, label %14
37: ; preds = %14, %7
%38 = phi i64 [ 0, %7 ], [ %34, %14 ]
%39 = icmp eq i64 %10, 0
br i1 %39, label %49, label %40
40: ; preds = %37
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %38
%42 = load i8, i8* %41
%43 = trunc i64 %38 to i32
%44 = xor i32 %43, -1
%45 = add i32 %5, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %46
%48 = load i8, i8* %47
store i8 %48, i8* %41
store i8 %42, i8* %47
br label %49
49: ; preds = %40, %37, %0
%50 = call i32 @puts(i8* %2)
ret i32 0
}