#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*/ sprintf(char *, char *, int);
int strlen(char *);
int check_palindrome(int num) {
  char str[10];
  int len, i;
  sprintf(str, "%d", num);
  len = strlen(str);
  for (i = 0; i < len / 2; i++) {
    if (str[i] != str[len - i - 1])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xec7(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11b0 <check_palindrome+0x90>
movslq -0x1c(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%eax
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x12(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     119d <check_palindrome+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <check_palindrome+0x97>
jmp    11a2 <check_palindrome+0x82>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <check_palindrome+0x31>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_palindrome>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%edx
lea    0xed2(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x2,%ecx
jl     117e <check_palindrome+0x5e>
mov    %ecx,%edx
shr    %edx
add    $0xffffffff,%ecx
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movzbl 0x6(%rsp,%rsi,1),%ebx
movslq %ecx,%rdi
cmp    0x6(%rsp,%rdi,1),%bl
jne    117c <check_palindrome+0x5c>
add    $0x1,%rsi
add    $0xffffffff,%ecx
cmp    %rsi,%rdx
jne    1160 <check_palindrome+0x40>
jmp    117e <check_palindrome+0x5e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @check_palindrome(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i32 @strlen(i8* %3)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %24
7: ; preds = %1
%8 = lshr i32 %5, 1
%9 = zext i32 %8 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %23, %9
br i1 %11, label %24, label %12
12: ; preds = %7, %10
%13 = phi i64 [ 0, %7 ], [ %23, %10 ]
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = trunc i64 %13 to i32
%17 = xor i32 %16, -1
%18 = add i32 %5, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %15, %21
%23 = add nuw nsw i64 %13, 1
br i1 %22, label %10, label %24
24: ; preds = %12, %10, %1
%25 = phi i32 [ 1, %1 ], [ 1, %10 ], [ 0, %12 ]
ret i32 %25
}