#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*/ assert(int);
int is_palindrome(unsigned long long);
int largest_palindrome(int);
int main(void) {
  unsigned long long palindromes[] = {0, 11, 121, 10201, 9009, 12321};
  unsigned long long non_palindromes[] = {12, 123, 11210, 9109, 12345};
  for (int i = 0; i < 6; i++) {
    assert(is_palindrome(palindromes[i]));
    assert(is_palindrome(non_palindromes[i]) == false);
  }
  assert(9009 == largest_palindrome(100));
  assert(222222 == largest_palindrome(500));
  assert(906609 == largest_palindrome(1000));
  assert(99000099 == largest_palindrome(10000));
  assert(9966006699 == largest_palindrome(100000));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
movq   $0xb,-0x38(%rbp)
movq   $0x79,-0x30(%rbp)
movq   $0x27d9,-0x28(%rbp)
movq   $0x2331,-0x20(%rbp)
movq   $0x3021,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movq   $0xc,-0x70(%rbp)
movq   $0x7b,-0x68(%rbp)
movq   $0x2bca,-0x60(%rbp)
movq   $0x2395,-0x58(%rbp)
movq   $0x3039,-0x50(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x6,-0x74(%rbp)
jge    1214 <main+0xd4>
movslq -0x74(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1050 <assert@plt>
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
call   1030 <is_palindrome@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11c9 <main+0x89>
mov    $0x64,%edi
call   1060 <largest_palindrome@plt>
mov    %eax,%ecx
mov    $0x2331,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <largest_palindrome@plt>
mov    %eax,%ecx
mov    $0x3640e,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <largest_palindrome@plt>
mov    %eax,%ecx
mov    $0xdd571,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x2710,%edi
call   1060 <largest_palindrome@plt>
mov    %eax,%ecx
mov    $0x5e69f23,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x186a0,%edi
call   1060 <largest_palindrome@plt>
movslq %eax,%rcx
movabs $0x2520531ab,%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0xc,%edi
call   1030 <is_palindrome@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0xb,%edi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0x7b,%edi
call   1030 <is_palindrome@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x79,%edi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0x2bca,%edi
call   1030 <is_palindrome@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x27d9,%edi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0x2395,%edi
call   1030 <is_palindrome@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x2331,%edi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    $0x3039,%edi
call   1030 <is_palindrome@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x3021,%edi
call   1030 <is_palindrome@plt>
mov    %eax,%edi
call   1040 <assert@plt>
call   1030 <is_palindrome@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x64,%edi
call   1050 <largest_palindrome@plt>
xor    %edi,%edi
cmp    $0x2331,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x1f4,%edi
call   1050 <largest_palindrome@plt>
xor    %edi,%edi
cmp    $0x3640e,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x3e8,%edi
call   1050 <largest_palindrome@plt>
xor    %edi,%edi
cmp    $0xdd571,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x2710,%edi
call   1050 <largest_palindrome@plt>
xor    %edi,%edi
cmp    $0x5e69f23,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x186a0,%edi
call   1050 <largest_palindrome@plt>
xor    %edi,%edi
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i64]
%3 = alloca [5 x i64]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [6 x i64]* %2 to i8*
%6 = bitcast i8* %5 to [6 x i64]*
%7 = getelementptr inbounds [6 x i64], [6 x i64]* %6, i32 0, i32 1
store i64 11, i64* %7
%8 = getelementptr inbounds [6 x i64], [6 x i64]* %6, i32 0, i32 2
store i64 121, i64* %8
%9 = getelementptr inbounds [6 x i64], [6 x i64]* %6, i32 0, i32 3
store i64 10201, i64* %9
%10 = getelementptr inbounds [6 x i64], [6 x i64]* %6, i32 0, i32 4
store i64 9009, i64* %10
%11 = getelementptr inbounds [6 x i64], [6 x i64]* %6, i32 0, i32 5
store i64 12321, i64* %11
%12 = bitcast [5 x i64]* %3 to i8*
%13 = bitcast i8* %12 to [5 x i64]*
%14 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 0
store i64 12, i64* %14
%15 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 1
store i64 123, i64* %15
%16 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 2
store i64 11210, i64* %16
%17 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 3
store i64 9109, i64* %17
%18 = getelementptr inbounds [5 x i64], [5 x i64]* %13, i32 0, i32 4
store i64 12345, i64* %18
store i32 0, i32* %4
br label %19
19: ; preds = %37, %0
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 6
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 %24
%26 = load i64, i64* %25
%27 = call i32 @is_palindrome(i64 %26)
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 %30
%32 = load i64, i64* %31
%33 = call i32 @is_palindrome(i64 %32)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
br label %37
37: ; preds = %22
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %19
40: ; preds = %19
%41 = call i32 @largest_palindrome(i32 100)
%42 = icmp eq i32 9009, %41
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 @largest_palindrome(i32 500)
%46 = icmp eq i32 222222, %45
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @largest_palindrome(i32 1000)
%50 = icmp eq i32 906609, %49
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = call i32 @largest_palindrome(i32 10000)
%54 = icmp eq i32 99000099, %53
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = call i32 @largest_palindrome(i32 100000)
%58 = sext i32 %57 to i64
%59 = icmp eq i64 9966006699, %58
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @is_palindrome(i64 0)
%2 = tail call i32 @assert(i32 %1)
%3 = tail call i32 @is_palindrome(i64 12)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @is_palindrome(i64 11)
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @is_palindrome(i64 123)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @is_palindrome(i64 121)
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @is_palindrome(i64 11210)
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i32 @is_palindrome(i64 10201)
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @is_palindrome(i64 9109)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32 @is_palindrome(i64 9009)
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i32 @is_palindrome(i64 12345)
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call i32 @is_palindrome(i64 12321)
%32 = tail call i32 @assert(i32 %31)
%33 = tail call i32 @is_palindrome(i64 poison)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = tail call i32 @largest_palindrome(i32 100)
%38 = icmp eq i32 %37, 9009
%39 = zext i1 %38 to i32
%40 = tail call i32 @assert(i32 %39)
%41 = tail call i32 @largest_palindrome(i32 500)
%42 = icmp eq i32 %41, 222222
%43 = zext i1 %42 to i32
%44 = tail call i32 @assert(i32 %43)
%45 = tail call i32 @largest_palindrome(i32 1000)
%46 = icmp eq i32 %45, 906609
%47 = zext i1 %46 to i32
%48 = tail call i32 @assert(i32 %47)
%49 = tail call i32 @largest_palindrome(i32 10000)
%50 = icmp eq i32 %49, 99000099
%51 = zext i1 %50 to i32
%52 = tail call i32 @assert(i32 %51)
%53 = tail call i32 @largest_palindrome(i32 100000)
%54 = tail call i32 @assert(i32 0)
ret i32 0
}