#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_palindrome_b(int);
scalar_t__ is_palindrome_d(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int i;
  int sum = 0;
  for (i = 1; i < 1000000; i++) {
    if (is_palindrome_d(i) && is_palindrome_b(i)) {
      sum += i;
    }
  }
  printf("%d\n", sum);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    119a <main+0x6a>
mov    -0x8(%rbp),%edi
call   1040 <is_palindrome_d@plt>
cmp    $0x0,%rax
je     1187 <main+0x57>
mov    -0x8(%rbp),%edi
call   1050 <is_palindrome_b@plt>
cmp    $0x0,%rax
je     1187 <main+0x57>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x5c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    114b <main+0x1b>
add    $0x1,%ebp
cmp    $0xf4240,%ebp
je     116b <main+0x3b>
mov    %ebp,%edi
call   1040 <is_palindrome_d@plt>
test   %rax,%rax
je     1140 <main+0x10>
mov    %ebp,%edi
call   1050 <is_palindrome_b@plt>
test   %rax,%rax
mov    %ebp,%eax
cmove  %r14d,%eax
add    %eax,%ebx
jmp    1140 <main+0x10>
lea    0xe8e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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