#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
void main() {
  char a[50], b;
  int n, i, l;
  printf("Vav. a:");
  fgets(a, sizeof(a), stdin);
  l = strlen(a) - 1;
  printf("%d", l);
  for (i = 0; i < l; i++, l--) {
    b = a[i];
    a[i] = a[l];
    a[l] = b;
  }
  printf("\n %s", a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1050 <fgets@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    11cd <main+0x9d>
movslq -0x4c(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0x41(%rbp)
movslq -0x50(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%cl
movslq -0x4c(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x41(%rbp),%cl
movslq -0x50(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x50(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x50(%rbp)
jmp    1184 <main+0x54>
lea    -0x40(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%esi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebx
jl     11b0 <main+0x80>
mov    %ebx,%eax
add    $0xfffffffffffffffe,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rsp,%rcx,1),%edx
movzbl 0x1(%rsp,%rax,1),%ebx
mov    %bl,(%rsp,%rcx,1)
mov    %dl,0x1(%rsp,%rax,1)
add    $0x1,%rcx
lea    -0x1(%rax),%rdx
cmp    %rax,%rcx
mov    %rdx,%rax
jl     1190 <main+0x60>
lea    0xe54(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"Vav. a:\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A %s\00"
define void @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 ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 50, i32 %4)
%6 = call i32 @strlen(i8* %2)
%7 = add nsw i32 %6, -1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = icmp sgt i32 %6, 1
br i1 %9, label %10, label %23
10: ; preds = %0
%11 = zext i32 %6 to i64
%12 = add nsw i64 %11, -1
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %20, %13 ]
%15 = phi i64 [ %12, %10 ], [ %21, %13 ]
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %14
%17 = load i8, i8* %16
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %15
%19 = load i8, i8* %18
store i8 %19, i8* %16
store i8 %17, i8* %18
%20 = add nuw nsw i64 %14, 1
%21 = add nsw i64 %15, -1
%22 = icmp slt i64 %20, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %0
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %2)
ret void
}