#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__ ispalindromein(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int i, answer = 0;
  for (i = 1; i < 1e6; i++) {
    if (ispalindromein(i, 2) && ispalindromein(i, 10))
      answer += i;
  }
  printf("%i\n", answer);
  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,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xeaf(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a5 <main+0x85>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   1040 <ispalindromein@plt>
cmp    $0x0,%rax
je     1192 <main+0x72>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   1040 <ispalindromein@plt>
cmp    $0x0,%rax
je     1192 <main+0x72>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1197 <main+0x77>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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    113b <main+0x1b>
add    $0x1,%ebp
cmp    $0xf4240,%ebp
je     1165 <main+0x45>
mov    %ebp,%edi
mov    $0x2,%esi
call   1040 <ispalindromein@plt>
test   %rax,%rax
je     1130 <main+0x10>
mov    %ebp,%edi
mov    $0xa,%esi
call   1040 <ispalindromein@plt>
test   %rax,%rax
mov    %ebp,%eax
cmove  %r14d,%eax
add    %eax,%ebx
jmp    1130 <main+0x10>
lea    0xe94(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%i\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* %7
store i32 1, i32* %6
br label %8
8: ; preds = %25, %2
%9 = load i32, i32* %6
%10 = sitofp i32 %9 to double
%11 = fcmp olt double %10, 1.000000e+06
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %6
%14 = call i64 @ispalindromein(i32 %13, i32 2)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* %6
%18 = call i64 @ispalindromein(i32 %17, i32 10)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = add nsw i32 %22, %21
store i32 %23, i32* %7
br label %24
24: ; preds = %20, %16, %12
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %8
28: ; preds = %8
%29 = load i32, i32* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
ret i32 0
}

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