#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*/ reverse_string(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int isPalindrome(int n) {
  char str[10];
  char rev[10];
  sprintf(str, "%d", n);
  strcpy(rev, str);
  reverse_string(rev);
  if (strcmp(str, rev) == 0) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xea7(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <reverse_string@plt>
lea    -0x12(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1197 <isPalindrome+0x57>
movl   $0x1,-0x4(%rbp)
jmp    119e <isPalindrome+0x5e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPalindrome>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%edx
lea    0xeb0(%rip),%rsi
lea    0xe(%rsp),%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <reverse_string@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @isPalindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
store i32 %0, i32* %3
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%13 = call i32 @reverse_string(i8* %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%16 = call i64 @strcmp(i8* %14, i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %1
store i32 1, i32* %2
br label %20
19: ; preds = %1
store i32 0, i32* %2
br label %20
20: ; preds = %19, %18
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @isPalindrome(i32 %0) {
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%7 = call i32 @strcpy(i8* %5, i8* %4)
%8 = call i32 @reverse_string(i8* %5)
%9 = call i64 @strcmp(i8* %4, i8* %5)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
ret i32 %11
}