#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__ is_bin_palindrome(unsigned int);
scalar_t__ is_palindrome(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char *argv[]) {
  unsigned sum = 0;
  for (unsigned i = 0; i < 1000000; i++) {
    if (is_palindrome(i) && is_bin_palindrome(i)) {
      printf("%d\n", i);
      sum += i;
    }
  }
  printf("Sum: %u\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xf4240,-0x18(%rbp)
jae    11b0 <main+0x80>
mov    -0x18(%rbp),%edi
call   1030 <is_palindrome@plt>
cmp    $0x0,%rax
je     119d <main+0x6d>
mov    -0x18(%rbp),%edi
call   1050 <is_bin_palindrome@plt>
cmp    $0x0,%rax
je     119d <main+0x6d>
mov    -0x18(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11a2 <main+0x72>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
lea    0xec3(%rip),%r14
xor    %ebx,%ebx
jmp    115b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0xf4240,%ebp
je     1181 <main+0x51>
mov    %ebp,%edi
call   1030 <is_palindrome@plt>
test   %rax,%rax
je     1150 <main+0x20>
mov    %ebp,%edi
call   1050 <is_bin_palindrome@plt>
test   %rax,%rax
je     1150 <main+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    %ebp,%ebx
jmp    1150 <main+0x20>
lea    0xe7c(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [9 x i8] c"Sum: %u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %26, %2
%9 = load i32, i32* %7
%10 = icmp ult i32 %9, 1000000
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %7
%13 = call i64 @is_palindrome(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i32, i32* %7
%17 = call i64 @is_bin_palindrome(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32, i32* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = add i32 %23, %22
store i32 %24, i32* %6
br label %25
25: ; preds = %19, %15, %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %7
%28 = add i32 %27, 1
store i32 %28, i32* %7
br label %8
29: ; preds = %8
%30 = load i32, i32* %6
%31 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [9 x i8] c"Sum: %u\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %5
3: ; preds = %16
%4 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
ret i32 0
5: ; preds = %2, %16
%6 = phi i32 [ 0, %2 ], [ %18, %16 ]
%7 = phi i32 [ 0, %2 ], [ %17, %16 ]
%8 = tail call i64 @is_palindrome(i32 %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = tail call i64 @is_bin_palindrome(i32 %6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%15 = add i32 %6, %7
br label %16
16: ; preds = %5, %10, %13
%17 = phi i32 [ %15, %13 ], [ %7, %10 ], [ %7, %5 ]
%18 = add nuw nsw i32 %6, 1
%19 = icmp eq i32 %18, 1000000
br i1 %19, label %3, label %5
}