#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_get_str(char *, int, int /*<<< orphan*/);
int strlen(char *);
int mpz_palindrome(mpz_t rop) {
  char str[500];
  mpz_get_str(str, 10, rop);
  size_t l = strlen(str) - 1;
  size_t i;
  for (i = 0; i < l / 2 + 1; ++i) {
    if (str[i] != str[l - i])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<mpz_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x200(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0xa,%esi
call   1040 <mpz_get_str@plt>
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x208(%rbp)
movq   $0x0,-0x210(%rbp)
mov    -0x210(%rbp),%rax
mov    -0x208(%rbp),%rcx
shr    $0x1,%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    11d9 <mpz_palindrome+0xb9>
mov    -0x210(%rbp),%rax
movsbl -0x200(%rbp,%rax,1),%eax
ff
mov    -0x208(%rbp),%rcx
sub    -0x210(%rbp),%rcx
movsbl -0x200(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
je     11bd <mpz_palindrome+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <mpz_palindrome+0xc0>
jmp    11c2 <mpz_palindrome+0xa2>
mov    -0x210(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x210(%rbp)
jmp    1165 <mpz_palindrome+0x45>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpz_palindrome>:
push   %rbx
sub    $0x200,%rsp
mov    %edi,%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <mpz_get_str@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    -0x1(%rax),%rcx
shr    %rcx
add    $0x1,%rcx
lea    (%rsp,%rax,1),%rdx
add    $0xffffffffffffffff,%rdx
xor    %eax,%eax
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rsi,1),%ebx
cmp    (%rdx),%bl
jne    117a <mpz_palindrome+0x5a>
add    $0x1,%rsi
add    $0xffffffffffffffff,%rdx
cmp    %rsi,%rcx
jne    1160 <mpz_palindrome+0x40>
mov    $0x1,%eax
add    $0x200,%rsp
pop    %rbx
ret

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

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