#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 check(char *string) {
  int i = 0, beg = 0, end = strlen(string) - 1;
  for (; i < (strlen(string) - 1) / 2; i++, beg++, end--) {
    if (string[beg] != string[end])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11b1 <check+0xa1>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     118c <check+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <check+0xa8>
jmp    1191 <check+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <check+0x29>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    $0x3,%eax
jl     1173 <check+0x63>
movslq %ebp,%rbp
add    $0xffffffffffffffff,%rbp
xor    %ebx,%ebx
nopl   (%rax)
movzbl (%r15,%rbx,1),%eax
cmp    (%r15,%rbp,1),%al
jne    1170 <check+0x60>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
add    $0xffffffffffffffff,%rbp
cmp    %ebx,%eax
jg     1140 <check+0x30>
jmp    1173 <check+0x63>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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