#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ convert(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
scalar_t__ ispal(int /*<<< orphan*/);
void main() {
  int n, s, b, i, q = 0, z = 0;
  FILE *in = fopen("dualpal.in", "r");
  fscanf(in, "%d %d", &n, &s);
  fclose(in);
  FILE *out = fopen("dualpal.out", "w");
  for (i = s + 1;; i++) {
    for (b = 2; b <= 10; b++) {
      if (ispal(convert(i, b))) {
        q++;
        if (q == 2) {
          z++;
          fprintf(out, "%d\n", i);
          break;
        }
      }
    }
    q = 0;
    if (z == n)
      break;
  }
  fclose(out);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe65(%rip),%rsi
lea    -0x4(%rbp),%rdx
lea    -0x8(%rbp),%rcx
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe4e(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     1257 <main+0xe7>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
cmp    $0x0,%rax
je     1244 <main+0xd4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jne    123f <main+0xcf>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xdec(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1257 <main+0xe7>
jmp    1244 <main+0xd4>
jmp    1249 <main+0xd9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e5 <main+0x75>
movl   $0x0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    126f <main+0xff>
jmp    1282 <main+0x112>
jmp    1274 <main+0x104>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11de <main+0x6e>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7e(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe5c(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    (%rsp),%ebp
add    $0x1,%ebp
xor    %r12d,%r12d
jmp    1203 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
mov    %r15,%rdi
lea    0xe33(%rip),%rsi
mov    %ebp,%edx
call   1060 <fprintf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%r12d
je     135c <main+0x1ec>
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
mov    %rax,%rcx
or     %rbx,%rcx
sete   %r13b
test   %rax,%rax
je     1240 <main+0xd0>
test   %rbx,%rbx
jne    11e0 <main+0x70>
mov    %ebp,%edi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
sete   %r14b
mov    %r14d,%eax
or     %r13b,%al
cmp    $0x1,%al
jne    11e0 <main+0x70>
and    %r13b,%r14b
mov    %r14d,%eax
xor    $0x1,%al
movzbl %al,%ebx
mov    %ebp,%edi
mov    $0x5,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
sete   %al
mov    $0x1,%ecx
cmovne %ecx,%ebx
or     %r14b,%al
cmp    $0x1,%al
jne    11e0 <main+0x70>
mov    %ebp,%edi
mov    $0x6,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
je     12c4 <main+0x154>
test   %ebx,%ebx
mov    $0x1,%ebx
jne    11e0 <main+0x70>
mov    %ebp,%edi
mov    $0x7,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
je     12e9 <main+0x179>
test   %ebx,%ebx
mov    $0x1,%ebx
jne    11e0 <main+0x70>
mov    %ebp,%edi
mov    $0x8,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
je     130e <main+0x19e>
test   %ebx,%ebx
mov    $0x1,%ebx
jne    11e0 <main+0x70>
mov    %ebp,%edi
mov    $0x9,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
je     1333 <main+0x1c3>
test   %ebx,%ebx
mov    $0x1,%ebx
jne    11e0 <main+0x70>
mov    %ebp,%edi
mov    $0xa,%esi
call   1030 <convert@plt>
mov    %eax,%edi
call   1090 <ispal@plt>
test   %rax,%rax
je     11f5 <main+0x85>
test   %ebx,%ebx
jne    11e0 <main+0x70>
jmp    11f5 <main+0x85>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"dualpal.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [12 x i8] c"dualpal.out\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%12 = load i32*, i32** %7
%13 = call i32 @fclose(i32* %12)
%14 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %14, i32** %8
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %49, %0
store i32 2, i32* %3
br label %18
18: ; preds = %40, %17
%19 = load i32, i32* %3
%20 = icmp sle i32 %19, 10
br i1 %20, label %21, label %43
21: ; preds = %18
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = call i32 @convert(i32 %22, i32 %23)
%25 = call i64 @ispal(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %21
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
%35 = load i32*, i32** %8
%36 = load i32, i32* %4
%37 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %36)
br label %43
38: ; preds = %27
br label %39
39: ; preds = %38, %21
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %18
43: ; preds = %32, %18
store i32 0, i32* %5
%44 = load i32, i32* %6
%45 = load i32, i32* %1
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
br label %52
48: ; preds = %43
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %17
52: ; preds = %47
%53 = load i32*, i32** %8
%54 = call i32 @fclose(i32* %53)
%55 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"dualpal.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [12 x i8] c"dualpal.out\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%7 = call i32 @fclose(i32* %5)
%8 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = load i32, i32* %2
br label %10
10: ; preds = %73, %0
%11 = phi i32 [ 0, %0 ], [ %74, %73 ]
%12 = phi i32 [ %9, %0 ], [ %13, %73 ]
%13 = add nsw i32 %12, 1
%14 = call i32 @convert(i32 %13, i32 2)
%15 = call i64 @ispal(i32 %14)
%16 = icmp eq i64 %15, 0
%17 = call i32 @convert(i32 %13, i32 3)
%18 = call i64 @ispal(i32 %17)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i1 true, i1 %16
%21 = select i1 %19, i1 %16, i1 false
br i1 %20, label %25, label %22
22: ; preds = %31, %25, %66, %10, %64, %57, %50, %43
%23 = add nsw i32 %11, 1
%24 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %13)
br label %73
25: ; preds = %10
%26 = call i32 @convert(i32 %13, i32 4)
%27 = call i64 @ispal(i32 %26)
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i1 true, i1 %21
%30 = select i1 %28, i1 %21, i1 false
br i1 %29, label %31, label %22
31: ; preds = %25
%32 = xor i1 %30, true
%33 = zext i1 %32 to i32
%34 = call i32 @convert(i32 %13, i32 5)
%35 = call i64 @ispal(i32 %34)
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i1 true, i1 %30
%38 = select i1 %36, i32 %33, i32 1
br i1 %37, label %39, label %22
39: ; preds = %31
%40 = call i32 @convert(i32 %13, i32 6)
%41 = call i64 @ispal(i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = icmp eq i32 %38, 1
br i1 %44, label %22, label %45
45: ; preds = %43, %39
%46 = phi i32 [ 1, %43 ], [ %38, %39 ]
%47 = call i32 @convert(i32 %13, i32 7)
%48 = call i64 @ispal(i32 %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %45
%51 = icmp eq i32 %46, 1
br i1 %51, label %22, label %52
52: ; preds = %50, %45
%53 = phi i32 [ 1, %50 ], [ %46, %45 ]
%54 = call i32 @convert(i32 %13, i32 8)
%55 = call i64 @ispal(i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %52
%58 = icmp eq i32 %53, 1
br i1 %58, label %22, label %59
59: ; preds = %57, %52
%60 = phi i32 [ 1, %57 ], [ %53, %52 ]
%61 = call i32 @convert(i32 %13, i32 9)
%62 = call i64 @ispal(i32 %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %59
%65 = icmp eq i32 %60, 1
br i1 %65, label %22, label %66
66: ; preds = %64, %59
%67 = phi i32 [ 1, %64 ], [ %60, %59 ]
%68 = call i32 @convert(i32 %13, i32 10)
%69 = call i64 @ispal(i32 %68)
%70 = icmp ne i64 %69, 0
%71 = icmp eq i32 %67, 1
%72 = select i1 %70, i1 %71, i1 false
br i1 %72, label %22, label %73
73: ; preds = %66, %22
%74 = phi i32 [ %23, %22 ], [ %11, %66 ]
%75 = load i32, i32* %1
%76 = icmp eq i32 %74, %75
br i1 %76, label %77, label %10
77: ; preds = %73
%78 = call i32 @fclose(i32* %8)
%79 = call i32 @exit(i32 0)
unreachable
}