#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 /*<<< orphan*/ system(char *);
int main() {
  int cont;
  int i;
  char parola[100];
  int palindromo;
  int medio;
  printf("Inserire una parola:");
  scanf("%s", parola);
  cont = 0;
  while (parola[cont] != 0) {
    cont++;
  }
  i = 0;
  palindromo = 1;
  medio = cont / 2;
  while (i < medio && palindromo == 1) {
    if (parola[cont - 1] != parola[i]) {
      palindromo = 0;
    }
    cont--;
    i++;
  }
  if (palindromo == 1) {
    printf("\nPalindromo.");
  } else {
    printf("\nNon palindromo.");
  }
  system("PAUSE");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1185 <main+0x55>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <main+0x35>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x74(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x78(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x78(%rbp),%ecx
mov    %al,-0x79(%rbp)
jge    11bc <main+0x8c>
cmpl   $0x1,-0x74(%rbp)
sete   %al
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%al
test   $0x1,%al
jne    11cc <main+0x9c>
jmp    1208 <main+0xd8>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x70(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11f1 <main+0xc1>
movl   $0x0,-0x74(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a1 <main+0x71>
cmpl   $0x1,-0x74(%rbp)
jne    1223 <main+0xf3>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
jmp    122f <main+0xff>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
lea    0xe00(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%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     11d3 <main+0xa3>
shr    %ecx
sar    $0x20,%rax
mov    $0x1,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rsp,%rax,1),%esi
movzbl -0x1(%rsp,%rdx,1),%edi
cmp    %rcx,%rdx
jae    11bc <main+0x8c>
add    $0xffffffffffffffff,%rax
add    $0x1,%rdx
cmp    %dil,%sil
je     11a0 <main+0x70>
cmp    %dil,%sil
lea    0xe52(%rip),%rax
lea    0xe58(%rip),%rdi
cmove  %rax,%rdi
jmp    11da <main+0xaa>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Inserire una parola:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [13 x i8] c"\0APalindromo.\00"
@.str.3 = [17 x i8] c"\0ANon palindromo.\00"
@.str.4 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
store i32 0, i32* %2
br label %10
10: ; preds = %17, %0
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %10
20: ; preds = %10
store i32 0, i32* %3
store i32 1, i32* %5
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 2
store i32 %22, i32* %6
br label %23
23: ; preds = %46, %20
%24 = load i32, i32* %3
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 1
br label %30
30: ; preds = %27, %23
%31 = phi i1 [ false, %23 ], [ %29, %27 ]
br i1 %31, label %32, label %51
32: ; preds = %30
%33 = load i32, i32* %2
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %38, %43
br i1 %44, label %45, label %46
45: ; preds = %32
store i32 0, i32* %5
br label %46
46: ; preds = %45, %32
%47 = load i32, i32* %2
%48 = add nsw i32 %47, -1
store i32 %48, i32* %2
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %23
51: ; preds = %30
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %58
56: ; preds = %51
%57 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
%59 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [21 x i8] c"Inserire una parola:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [13 x i8] c"\0APalindromo.\00"
@.str.3 = [17 x i8] c"\0ANon palindromo.\00"
@.str.4 = [6 x i8] c"PAUSE\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 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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 %33, 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
br label %19
19: ; preds = %14, %19
%20 = phi i64 [ 0, %14 ], [ %28, %19 ]
%21 = phi i64 [ %17, %14 ], [ %22, %19 ]
%22 = add nsw i64 %21, -1
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%26 = load i8, i8* %25
%27 = icmp eq i8 %24, %26
%28 = add nuw nsw i64 %20, 1
%29 = icmp ult i64 %28, %18
%30 = and i1 %29, %27
br i1 %30, label %19, label %31
31: ; preds = %19
%32 = select i1 %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0)
br label %33
33: ; preds = %31, %11
%34 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %11 ], [ %32, %31 ]
%35 = call i32 @printf(i8* dereferenceable(1) %34)
%36 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}