#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 main() {
  char str[100];
  printf("Enter a string: \n");
  scanf("%s", str);
  int i, length = 0;
  for (i = 0; str[i] != '\0'; i++)
    ;
  length = i;
  for (i = 0; i < length / 2; i++) {
    char temp = str[i];
    str[i] = str[length - i - 1];
    str[length - i - 1] = temp;
  }
  printf("Reverse of the string is: %s", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xee1(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1183 <main+0x63>
jmp    1175 <main+0x55>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    115e <main+0x3e>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
cmp    %ecx,%eax
jge    11f0 <main+0xd0>
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x79(%rbp)
mov    -0x78(%rbp),%eax
sub    -0x74(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x79(%rbp),%cl
mov    -0x78(%rbp),%eax
sub    -0x74(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1190 <main+0x70>
lea    -0x70(%rbp),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xed3(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    $0xffffffffffffffff,%rcx
movabs $0xffffffff00000000,%rax
ff ff ff
movabs $0x100000000,%rdx
nopw   0x0(%rax,%rax,1)
add    %rdx,%rax
cmpb   $0x0,0x1(%rsp,%rcx,1)
lea    0x1(%rcx),%rcx
jne    1170 <main+0x40>
test   $0xfffffffe,%ecx
je     121f <main+0xef>
mov    %rcx,%r8
shr    %r8
mov    %r8d,%edx
and    $0x7fffffff,%edx
cmp    $0x1,%edx
jne    11a8 <main+0x78>
xor    %edx,%edx
test   $0x1,%r8b
jne    1206 <main+0xd6>
jmp    121f <main+0xef>
lea    0x1(%rsp),%rsi
movslq %ecx,%rcx
lea    (%rsp,%rcx,1),%rdi
add    $0xffffffffffffffff,%rdi
mov    %r8d,%r9d
and    $0x1,%r9d
mov    %r8d,%edx
and    $0x7fffffff,%edx
sub    %rdx,%r9
xor    %edx,%edx
nopl   (%rax)
movzbl -0x1(%rsi),%r10d
movzbl (%rdi,%rdx,1),%ecx
mov    %cl,-0x1(%rsi)
mov    %r10b,(%rdi,%rdx,1)
movzbl (%rsi),%r10d
movzbl -0x1(%rdi,%rdx,1),%ecx
mov    %cl,(%rsi)
mov    %r10b,-0x1(%rdi,%rdx,1)
add    $0x2,%rsi
add    $0xfffffffffffffffe,%rdx
cmp    %rdx,%r9
jne    11d0 <main+0xa0>
neg    %rdx
test   $0x1,%r8b
je     121f <main+0xef>
sar    $0x20,%rax
mov    (%rsp,%rdx,1),%cl
mov    %rdx,%rsi
not    %rsi
add    %rax,%rsi
mov    (%rsp,%rsi,1),%al
mov    %al,(%rsp,%rdx,1)
mov    %cl,(%rsp,%rsi,1)
lea    0xdda(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [29 x i8] c"Reverse of the string is: %s\00"
@str = [17 x i8] c"Enter a string: \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 ([17 x i8], [17 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)
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %10, %5 ], [ 0, %0 ]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = add nuw i64 %6, 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = and i64 %6, 4294967294
%13 = icmp eq i64 %12, 0
br i1 %13, label %52, label %14
14: ; preds = %11
%15 = lshr i64 %6, 1
%16 = shl i64 %6, 32
%17 = ashr exact i64 %16, 32
%18 = and i64 %15, 2147483647
%19 = and i64 %15, 1
%20 = icmp eq i64 %18, 1
br i1 %20, label %42, label %21
21: ; preds = %14
%22 = sub nsw i64 %18, %19
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %39, %23 ]
%25 = phi i64 [ 0, %21 ], [ %40, %23 ]
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %24
%27 = load i8, i8* %26
%28 = xor i64 %24, -1
%29 = add nsw i64 %17, %28
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
store i8 %31, i8* %26
store i8 %27, i8* %30
%32 = or i64 %24, 1
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sub nuw nsw i64 -2, %24
%36 = add nsw i64 %17, %35
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %36
%38 = load i8, i8* %37
store i8 %38, i8* %33
store i8 %34, i8* %37
%39 = add nuw nsw i64 %24, 2
%40 = add i64 %25, 2
%41 = icmp eq i64 %40, %22
br i1 %41, label %42, label %23
42: ; preds = %23, %14
%43 = phi i64 [ 0, %14 ], [ %39, %23 ]
%44 = icmp eq i64 %19, 0
br i1 %44, label %52, label %45
45: ; preds = %42
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %43
%47 = load i8, i8* %46
%48 = xor i64 %43, -1
%49 = add nsw i64 %17, %48
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %49
%51 = load i8, i8* %50
store i8 %51, i8* %46
store i8 %47, i8* %50
br label %52
52: ; preds = %45, %42, %11
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %2)
ret i32 0
}