#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, s[100];
  int i = 0, l = 0;
  printf("\nTekst:\n");
  scanf("%s", s);
  l = strlen(s) - 1;
  do {
    str = s[i];
    s[i] = s[l];
    s[l] = str;
    i++;
    l--;
  } while (i < l);
  printf("\nNaobratno e :%s\n", s);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x78(%rbp)
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x5(%rbp)
movslq -0x78(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x5(%rbp),%cl
movslq -0x78(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    -0x78(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x78(%rbp),%eax
jl     117d <main+0x4d>
lea    -0x70(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%rsp,%rcx,1),%edx
movzbl (%rsp,%rax,1),%ebx
mov    %bl,-0x1(%rsp,%rcx,1)
mov    %dl,(%rsp,%rax,1)
add    $0xffffffffffffffff,%rax
lea    0x1(%rcx),%rdx
cmp    %rax,%rcx
mov    %rdx,%rcx
jl     1180 <main+0x40>
lea    0xe5c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

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

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