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


x86 assembly (clang, -O0):
<checkPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xf(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x7,%esi
lea    0xec2(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0xf(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11b5 <checkPalindrome+0x95>
movslq -0x18(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0xf(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11a2 <checkPalindrome+0x82>
movl   $0x0,-0x4(%rbp)
jmp    11bc <checkPalindrome+0x9c>
jmp    11a7 <checkPalindrome+0x87>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <checkPalindrome+0x36>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPalindrome>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ecx
lea    0xed2(%rip),%rdx
lea    0x9(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ecx
cmp    $0x2,%eax
jl     11a5 <checkPalindrome+0x85>
mov    0x9(%rsp),%dl
lea    -0x1(%rax),%ecx
movslq %ecx,%rsi
xor    %ecx,%ecx
cmp    0x9(%rsp,%rsi,1),%dl
jne    11a5 <checkPalindrome+0x85>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%r8
mov    %r8d,%ecx
add    $0xfffffffe,%eax
mov    $0x1,%edi
nopl   0x0(%rax,%rax,1)
mov    %rdi,%rsi
cmp    %rdi,%rcx
je     119d <checkPalindrome+0x7d>
movzbl 0x9(%rsp,%rsi,1),%ebx
movslq %eax,%rdx
lea    0x1(%rsi),%rdi
lea    -0x1(%rdx),%eax
cmp    0x9(%rsp,%rdx,1),%bl
je     1180 <checkPalindrome+0x60>
xor    %ecx,%ecx
cmp    %r8,%rsi
setge  %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @checkPalindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [7 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @snprintf(i8* %7, i32 7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [7 x i8], [7 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 [7 x i8], [7 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 [7 x i8], [7 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 @checkPalindrome(i32 %0) {
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i32 @strlen(i8* %3)
%6 = sdiv i32 %5, 2
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %35
8: ; preds = %1
%9 = sext i32 %6 to i64
%10 = zext i32 %6 to i64
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%12 = load i8, i8* %11
%13 = add i32 %5, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %12, %16
br i1 %17, label %18, label %35
18: ; preds = %8, %21
%19 = phi i64 [ %31, %21 ], [ 1, %8 ]
%20 = icmp eq i64 %19, %10
br i1 %20, label %32, label %21
21: ; preds = %18
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %19
%23 = load i8, i8* %22
%24 = trunc i64 %19 to i32
%25 = xor i32 %24, -1
%26 = add i32 %5, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %23, %29
%31 = add nuw nsw i64 %19, 1
br i1 %30, label %18, label %32
32: ; preds = %18, %21
%33 = icmp sge i64 %19, %9
%34 = zext i1 %33 to i32
br label %35
35: ; preds = %32, %8, %1
%36 = phi i32 [ 1, %1 ], [ 0, %8 ], [ %34, %32 ]
ret i32 %36
}