#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 string[500];
  int i, l;
  printf("Vuvedi string  ");
  scanf("%s", string);
  printf("\n");
  l = strlen(string);
  for (i = l - 1; i >= 0; i--) {
    printf("%c", string[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x200(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1050 <scanf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x208(%rbp)
mov    -0x208(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x204(%rbp)
cmpl   $0x0,-0x204(%rbp)
jl     11d0 <main+0xa0>
movslq -0x204(%rbp),%rax
movsbl -0x200(%rbp,%rax,1),%esi
ff
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x204(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x204(%rbp)
jmp    1192 <main+0x62>
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x200,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11a6 <main+0x66>
mov    %eax,%ebx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x2(%rbx),%eax
movsbl (%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <main+0x50>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"Vuvedi string \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @putchar(i32 10)
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ %9, %8 ], [ %12, %10 ]
%12 = add nsw i64 %11, -1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = icmp ugt i64 %11, 1
br i1 %18, label %10, label %19
19: ; preds = %10, %0
ret i32 0
}