#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 *, char *);
int strlen(char *);
main() {
  char p[] = "MalayalaM";
  char t;
  int i, j;
  for (i = 0, j = strlen(p); i < j; i++) {
    t = p[i];
    p[i] = p[j - i];
    p[j - i] = t;
  }
  printf("%s", p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0x6(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0xe(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a0 <main+0x80>
movslq -0x14(%rbp),%rax
mov    -0xe(%rbp,%rax,1),%al
mov    %al,-0xf(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
mov    -0xe(%rbp,%rax,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0xe(%rbp,%rax,1)
mov    -0xf(%rbp),%cl
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
mov    %cl,-0xe(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1158 <main+0x38>
lea    -0xe(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0x616c6179616c614d,%rax
61 6c 61
mov    %rax,0x8(%rsp)
movw   $0x4d,0x10(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11cb <main+0xab>
mov    %eax,%r8d
cmp    $0x1,%eax
jne    115e <main+0x3e>
xor    %eax,%eax
test   $0x1,%r8b
jne    11b6 <main+0x96>
jmp    11cb <main+0xab>
lea    0x9(%rsp),%rdx
lea    (%rsp,%r8,1),%rsi
add    $0x8,%rsi
mov    %r8d,%edi
and    $0xfffffffe,%edi
neg    %rdi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movzbl -0x1(%rdx),%r9d
movzbl (%rsi,%rax,1),%ecx
mov    %cl,-0x1(%rdx)
mov    %r9b,(%rsi,%rax,1)
movzbl (%rdx),%r9d
movzbl -0x1(%rsi,%rax,1),%ecx
mov    %cl,(%rdx)
mov    %r9b,-0x1(%rsi,%rax,1)
add    $0x2,%rdx
add    $0xfffffffffffffffe,%rax
cmp    %rax,%rdi
jne    1180 <main+0x60>
neg    %rax
test   $0x1,%r8b
je     11cb <main+0xab>
mov    0x8(%rsp,%rax,1),%cl
sub    %rax,%r8
mov    0x8(%rsp,%r8,1),%dl
mov    %dl,0x8(%rsp,%rax,1)
mov    %cl,0x8(%rsp,%r8,1)
lea    0xe38(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@__const.main.p = [10 x i8] c"MalayalaM\00"
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %38
5: ; preds = %0
%6 = zext i32 %3 to i64
%7 = zext i32 %3 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %3, 1
br i1 %9, label %29, label %10
10: ; preds = %5
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %26, %12 ]
%14 = phi i64 [ 0, %10 ], [ %27, %12 ]
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %13
%16 = load i8, i8* %15
%17 = sub nsw i64 %6, %13
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
store i8 %19, i8* %15
store i8 %16, i8* %18
%20 = or i64 %13, 1
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sub nsw i64 %6, %20
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
store i8 %25, i8* %21
store i8 %22, i8* %24
%26 = add nuw nsw i64 %13, 2
%27 = add i64 %14, 2
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %12
29: ; preds = %12, %5
%30 = phi i64 [ 0, %5 ], [ %26, %12 ]
%31 = icmp eq i64 %8, 0
br i1 %31, label %38, label %32
32: ; preds = %29
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %30
%34 = load i8, i8* %33
%35 = sub nsw i64 %6, %30
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %35
%37 = load i8, i8* %36
store i8 %37, i8* %33
store i8 %34, i8* %36
br label %38
38: ; preds = %32, %29, %0
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}