#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 *);
void main() {
  int i;
  char niz[15];
  printf("Vuvedi niz: ");
  scanf("%s", niz);
  for (i = 0; i <= strlen(niz); i++)
    printf("%c", niz[strlen(niz) - i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x13(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x13(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     11a8 <main+0x78>
lea    -0x13(%rbp),%rdi
call   1030 <strlen@plt>
sub    -0x4(%rbp),%eax
cltq
movsbl -0x13(%rbp,%rax,1),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115d <main+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    0x1(%rsp),%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
js     11a6 <main+0x66>
mov    $0xffffffff,%ebp
mov    %r14,%rbx
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movsbl (%rbx,%rax,1),%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0x1,%ebp
add    $0xffffffffffffffff,%rbx
cmp    %eax,%ebp
jl     1180 <main+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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