#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 strlen(char *);
int checkPall(char str[]) {
  for (int i = 0; i < strlen(str); i++) {
    if (str[i] != str[strlen(str) - i - 1]) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkPall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    119c <checkPall+0x8c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,%edx
mov    -0x1c(%rbp),%eax
sub    -0x14(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1189 <checkPall+0x79>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <checkPall+0x93>
jmp    118e <checkPall+0x7e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <checkPall+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPall>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    1172 <checkPall+0x62>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%r12d
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cltq
cmp    (%r15,%rax,1),%r12b
jne    116f <checkPall+0x5f>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1140 <checkPall+0x30>
jmp    1172 <checkPall+0x62>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkPall(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %30, %1
%6 = load i32, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %33
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = load i8*, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = load i32, i32* %4
%21 = sub nsw i32 %19, %20
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %17, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %16, %26
br i1 %27, label %28, label %29
28: ; preds = %10
store i32 0, i32* %2
br label %34
29: ; preds = %10
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %5
33: ; preds = %5
store i32 1, i32* %2
br label %34
34: ; preds = %33, %28
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @checkPall(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %9, label %22
4: ; preds = %9
%5 = add nuw nsw i32 %11, 1
%6 = tail call i32 @strlen(i8* %0)
%7 = sext i32 %6 to i64
%8 = icmp slt i64 %21, %7
br i1 %8, label %9, label %22
9: ; preds = %1, %4
%10 = phi i64 [ %21, %4 ], [ 0, %1 ]
%11 = phi i32 [ %5, %4 ], [ 0, %1 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %10
%13 = load i8, i8* %12
%14 = tail call i32 @strlen(i8* %0)
%15 = xor i32 %11, -1
%16 = add i32 %14, %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %13, %19
%21 = add nuw nsw i64 %10, 1
br i1 %20, label %4, label %22
22: ; preds = %4, %9, %1
%23 = phi i32 [ 1, %1 ], [ 0, %9 ], [ 1, %4 ]
ret i32 %23
}