#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 */
scalar_t__ check_palindrom(long);
long to_base(int, char *, long);
int generate_palindroms() {
  long number, sum = 0;
  for (number = 11; number <= 5000000; number++) {
    if (check_palindrom(number) && check_palindrom(to_base(2, "01", number))) {
      sum += number;
    }
  }
  return sum;
}


x86 assembly (clang, -O0):
<generate_palindroms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0xb,-0x8(%rbp)
cmpq   $0x4c4b40,-0x8(%rbp)
jg     11a2 <generate_palindroms+0x82>
mov    -0x8(%rbp),%rdi
call   1040 <check_palindrom@plt>
cmp    $0x0,%rax
je     118c <generate_palindroms+0x6c>
mov    -0x8(%rbp),%rdx
mov    $0x2,%edi
lea    0xe97(%rip),%rsi
call   1030 <to_base@plt>
mov    %rax,%rdi
call   1040 <check_palindrom@plt>
cmp    $0x0,%rax
je     118c <generate_palindroms+0x6c>
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1191 <generate_palindroms+0x71>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1138 <generate_palindroms+0x18>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_palindroms>:
push   %r15
push   %r14
push   %rbx
mov    $0xb,%ebx
xor    %r14d,%r14d
lea    0xecc(%rip),%r15
jmp    1150 <generate_palindroms+0x30>
cs nopw 0x0(%rax,%rax,1)
add    %rax,%r14
add    $0x1,%rbx
cmp    $0x4c4b41,%rbx
je     117f <generate_palindroms+0x5f>
mov    %rbx,%rdi
call   1040 <check_palindrom@plt>
test   %rax,%rax
je     1143 <generate_palindroms+0x23>
mov    $0x2,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <to_base@plt>
mov    %rax,%rdi
call   1040 <check_palindrom@plt>
test   %rax,%rax
je     1140 <generate_palindroms+0x20>
mov    %rbx,%rax
jmp    1140 <generate_palindroms+0x20>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"01\00"
define i32 @generate_palindroms() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %2
store i64 11, i64* %1
br label %3
3: ; preds = %20, %0
%4 = load i64, i64* %1
%5 = icmp sle i64 %4, 5000000
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = load i64, i64* %1
%8 = call i64 @check_palindrom(i64 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load i64, i64* %1
%12 = call i64 @to_base(i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = call i64 @check_palindrom(i64 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i64, i64* %1
%17 = load i64, i64* %2
%18 = add nsw i64 %17, %16
store i64 %18, i64* %2
br label %19
19: ; preds = %15, %10, %6
br label %20
20: ; preds = %19
%21 = load i64, i64* %1
%22 = add nsw i64 %21, 1
store i64 %22, i64* %1
br label %3
23: ; preds = %3
%24 = load i64, i64* %2
%25 = trunc i64 %24 to i32
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"01\00"
define i32 @generate_palindroms() {
br label %1
1: ; preds = %0, %12
%2 = phi i64 [ 0, %0 ], [ %13, %12 ]
%3 = phi i64 [ 11, %0 ], [ %14, %12 ]
%4 = tail call i64 @check_palindrom(i64 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = tail call i64 @to_base(i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 %3)
%8 = tail call i64 @check_palindrom(i64 %7)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i64 0, i64 %3
%11 = add nsw i64 %10, %2
br label %12
12: ; preds = %6, %1
%13 = phi i64 [ %2, %1 ], [ %11, %6 ]
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, 5000001
br i1 %15, label %16, label %1
16: ; preds = %12
%17 = trunc i64 %13 to i32
ret i32 %17
}