#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char text[100], temp;
  int lenght, beg, mid, end;
  printf("Text: ");
  fgets(text, 100, stdin);
  beg = 0;
  lenght = strlen(text);
  mid = lenght / 2;
  if (lenght % 2 == 0)
    mid--;
  end = lenght - 1;
  while (end != mid) {
    temp = text[end];
    text[end] = text[beg];
    text[beg] = temp;
    beg++;
    end--;
  }
  printf("%s\n", text);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
movl   $0x0,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a5 <main+0x75>
mov    -0x80(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x80(%rbp),%eax
je     1209 <main+0xd9>
movslq -0x84(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x71(%rbp)
movslq -0x7c(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x84(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x71(%rbp),%cl
movslq -0x7c(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
jmp    11b1 <main+0x81>
lea    -0x70(%rbp),%rsi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %eax,%edi
and    $0x1,%edi
lea    (%rdi,%rsi,1),%edx
mov    %eax,%r8d
sub    %edx,%r8d
je     1206 <main+0xc6>
lea    -0x1(%rax),%edx
movslq %edx,%rdx
not    %esi
add    %eax,%esi
cmp    %edi,%esi
jne    11a5 <main+0x65>
xor    %eax,%eax
test   $0x1,%r8b
jne    11fa <main+0xba>
jmp    1206 <main+0xc6>
mov    %r8d,%esi
and    $0xfffffffe,%esi
neg    %esi
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rsp,%rdx,1),%ebx
movzbl -0x1(%rsp,%rax,1),%ecx
mov    %cl,(%rsp,%rdx,1)
mov    %bl,-0x1(%rsp,%rax,1)
movzbl -0x1(%rsp,%rdx,1),%ecx
movzbl (%rsp,%rax,1),%ebx
mov    %bl,-0x1(%rsp,%rdx,1)
mov    %cl,(%rsp,%rax,1)
add    $0xfffffffffffffffe,%rdx
add    $0x2,%rax
lea    (%rsi,%rax,1),%ecx
cmp    $0x1,%ecx
jne    11c0 <main+0x80>
add    $0xffffffffffffffff,%rax
test   $0x1,%r8b
je     1206 <main+0xc6>
mov    (%rsp,%rdx,1),%cl
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    $0x70,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"Text: \00"
@stdin = global i32 0
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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 100, i32 %4)
%6 = call i32 @strlen(i8* %2)
%7 = sdiv i32 %6, 2
%8 = and i32 %6, 1
%9 = add nsw i32 %8, -1
%10 = add nsw i32 %9, %7
%11 = add i32 %6, -1
%12 = icmp eq i32 %11, %10
br i1 %12, label %50, label %13
13: ; preds = %0
%14 = sext i32 %11 to i64
%15 = add nsw i32 %7, %8
%16 = sub i32 %6, %15
%17 = xor i32 %7, -1
%18 = add i32 %6, %17
%19 = and i32 %16, 1
%20 = icmp eq i32 %18, %8
br i1 %20, label %41, label %21
21: ; preds = %13
%22 = and i32 %16, -2
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %37, %23 ]
%25 = phi i64 [ %14, %21 ], [ %38, %23 ]
%26 = phi i32 [ 0, %21 ], [ %39, %23 ]
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
%28 = load i8, i8* %27
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %24
%30 = load i8, i8* %29
store i8 %30, i8* %27
store i8 %28, i8* %29
%31 = or i64 %24, 1
%32 = add nsw i64 %25, -1
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %31
%36 = load i8, i8* %35
store i8 %36, i8* %33
store i8 %34, i8* %35
%37 = add nuw nsw i64 %24, 2
%38 = add nsw i64 %25, -2
%39 = add i32 %26, 2
%40 = icmp eq i32 %39, %22
br i1 %40, label %41, label %23
41: ; preds = %23, %13
%42 = phi i64 [ 0, %13 ], [ %37, %23 ]
%43 = phi i64 [ %14, %13 ], [ %38, %23 ]
%44 = icmp eq i32 %19, 0
br i1 %44, label %50, label %45
45: ; preds = %41
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %43
%47 = load i8, i8* %46
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %42
%49 = load i8, i8* %48
store i8 %49, i8* %46
store i8 %47, i8* %48
br label %50
50: ; preds = %45, %41, %0
%51 = call i32 @puts(i8* %2)
ret i32 0
}