#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*/ is_palindrome(char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ print_bits(int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int sprintf(char *, char *, int);
char *start(char *, int);
int strlen(char *);
int main(int argc, char *argv[]) {
  int sum = 0;
  for (int i = 1; i < 1000000; i++) {
    char buffer[33];
    int dec_len = sprintf(buffer, "%i", i);
    if (!is_palindrome(buffer, dec_len)) {
      continue;
    }
    memset(buffer, '\0', 33);
    print_bits(i, buffer, 33);
    char *bin = start(buffer, 32);
    if (bin == NULL) {
      printf("null\n");
      return 0;
    }
    int bin_len = strlen(bin);
    if (!is_palindrome(bin, bin_len)) {
      continue;
    }
    sum += i;
  }
  printf("%i", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0xf4240,-0x18(%rbp)
jge    1266 <main+0xf6>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe51(%rip),%rsi
call   1090 <sprintf@plt>
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <is_palindrome@plt>
cmp    $0x0,%eax
jne    11d1 <main+0x61>
jmp    1258 <main+0xe8>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x21,%edx
call   1080 <print_bits@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1070 <start@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1229 <main+0xb9>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127e <main+0x10e>
mov    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1030 <is_palindrome@plt>
cmp    $0x0,%eax
jne    124f <main+0xdf>
jmp    1258 <main+0xe8>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1194 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    $0x1,%ebp
xor    %r15d,%r15d
lea    0xe65(%rip),%r14
mov    %rsp,%r12
jmp    11ab <main+0x2b>
add    $0x1,%ebp
cmp    $0xf4240,%ebp
je     1215 <main+0x95>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <is_palindrome@plt>
test   %eax,%eax
je     11a0 <main+0x20>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1070 <memset@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x21,%edx
call   1090 <print_bits@plt>
mov    %r12,%rdi
mov    $0x20,%esi
call   1080 <start@plt>
test   %rax,%rax
je     1228 <main+0xa8>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <is_palindrome@plt>
test   %eax,%eax
cmovne %ebp,%eax
add    %eax,%r15d
jmp    11a0 <main+0x20>
lea    0xde4(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1234 <main+0xb4>
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [6 x i8] c"null\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [33 x i8]
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %12
12: ; preds = %48, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 1000000
br i1 %14, label %15, label %51
15: ; preds = %12
%16 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%17 = load i32, i32* %7
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 %18, i32* %9
%19 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%20 = load i32, i32* %9
%21 = call i32 @is_palindrome(i8* %19, i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %15
br label %48
24: ; preds = %15
%25 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%26 = call i32 @memset(i8* %25, i8 signext 0, i32 33)
%27 = load i32, i32* %7
%28 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%29 = call i32 @print_bits(i32 %27, i8* %28, i32 33)
%30 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%31 = call i8* @start(i8* %30, i32 32)
store i8* %31, i8** %10
%32 = load i8*, i8** %10
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %54
36: ; preds = %24
%37 = load i8*, i8** %10
%38 = call i32 @strlen(i8* %37)
store i32 %38, i32* %11
%39 = load i8*, i8** %10
%40 = load i32, i32* %11
%41 = call i32 @is_palindrome(i8* %39, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %36
br label %48
44: ; preds = %36
%45 = load i32, i32* %7
%46 = load i32, i32* %6
%47 = add nsw i32 %46, %45
store i32 %47, i32* %6
br label %48
48: ; preds = %44, %43, %23
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %12
51: ; preds = %12
%52 = load i32, i32* %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %52)
store i32 0, i32* %3
br label %54
54: ; preds = %51, %34
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@str = [5 x i8] c"null\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [33 x i8]
%4 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %2, %22
%6 = phi i32 [ 0, %2 ], [ %23, %22 ]
%7 = phi i32 [ 1, %2 ], [ %24, %22 ]
%8 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @is_palindrome(i8* %4, i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %5
%12 = call i32 @memset(i8* %4, i8 signext 0, i32 33)
%13 = call i32 @print_bits(i32 %7, i8* %4, i32 33)
%14 = call i8* @start(i8* %4, i32 32)
%15 = icmp eq i8* %14, null
br i1 %15, label %26, label %16
16: ; preds = %11
%17 = call i32 @strlen(i8* %14)
%18 = call i32 @is_palindrome(i8* %14, i32 %17)
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i32 0, i32 %7
%21 = add nsw i32 %20, %6
br label %22
22: ; preds = %16, %5
%23 = phi i32 [ %6, %5 ], [ %21, %16 ]
%24 = add nuw nsw i32 %7, 1
%25 = icmp eq i32 %24, 1000000
br i1 %25, label %28, label %5
26: ; preds = %11
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %30
28: ; preds = %22
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %30
30: ; preds = %26, %28
ret i32 0
}