#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() {
  char str[125], temp;
  int i, lenght;
  printf("Enter a string:\n");
  scanf("%s", &str);
  lenght = strlen(str);
  for (i = 0; i < lenght; i++) {
    temp = str[i];
    str[i] = str[lenght - 1];
    str[lenght - 1] = temp;
    lenght--;
  }
  printf("The reversed string: \n");
  printf("%s", str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x8c(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x8c(%rbp),%eax
jge    11e7 <main+0xb7>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%al
mov    %al,-0x81(%rbp)
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x80(%rbp,%rax,1),%cl
movslq -0x88(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x81(%rbp),%cl
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x8c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1172 <main+0x42>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    119e <main+0x5e>
mov    %eax,%eax
add    $0xffffffffffffffff,%rax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movzbl (%rsp,%rcx,1),%edx
movzbl (%rsp,%rax,1),%ebx
mov    %bl,(%rsp,%rcx,1)
mov    %dl,(%rsp,%rax,1)
add    $0x1,%rcx
lea    -0x1(%rax),%rdx
cmp    %rax,%rcx
mov    %rdx,%rax
jl     1180 <main+0x40>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4f(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [16 x i8] c"Enter a string:\00"
@str.3 = [22 x i8] c"The reversed string: \00"
define void @main() {
%1 = alloca [125 x i8]
%2 = getelementptr inbounds [125 x i8], [125 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = bitcast [125 x i8]* %1 to i8**
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %18, %10 ]
%12 = phi i64 [ %9, %8 ], [ %15, %10 ]
%13 = getelementptr inbounds [125 x i8], [125 x i8]* %1, i64 0, i64 %11
%14 = load i8, i8* %13
%15 = add nsw i64 %12, -1
%16 = getelementptr inbounds [125 x i8], [125 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %13
store i8 %14, i8* %16
%18 = add nuw nsw i64 %11, 1
%19 = icmp slt i64 %18, %15
br i1 %19, label %10, label %20
20: ; preds = %10, %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret void
}