#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__ palinbase(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int n, s = 0;
  for (n = 1; n < 1000000; n += 2)
    if (palinbase(n, 10) && palinbase(n, 2))
      s += n;
  printf("%d\n", s);
  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)
cmpl   $0xf4240,-0x14(%rbp)
jge    119b <main+0x7b>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   1030 <palinbase@plt>
cmp    $0x0,%rax
je     1188 <main+0x68>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   1030 <palinbase@plt>
cmp    $0x0,%rax
je     1188 <main+0x68>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118d <main+0x6d>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xe5b(%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    %r14d,%r14d
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
jmp    1138 <main+0x18>
cmp    $0xf423e,%ebp
jae    1165 <main+0x45>
add    $0x2,%ebp
mov    %ebp,%edi
mov    $0xa,%esi
call   1030 <palinbase@plt>
test   %rax,%rax
je     1130 <main+0x10>
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <palinbase@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   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\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 @palinbase(i32 %5, i32 10)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = tail call i64 @palinbase(i32 %5, i32 2)
%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, 2
%16 = icmp ult i32 %5, 999998
br i1 %16, label %3, label %17
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
}