#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 */
int /*<<< orphan*/ findPrimeList();
scalar_t__ isSmithNumber(long);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long int numTest, num, nextNum;
  findPrimeList();
  scanf("%ld", &numTest);
  while (numTest > 0) {
    scanf("%ld", &num);
    nextNum = num + 1;
    while (1) {
      if (isSmithNumber(nextNum)) {
        printf("%ld\n", nextNum);
        break;
      }
      nextNum++;
    }
    numTest--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <findPrimeList@plt>
lea    0xea3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jle    11d7 <main+0x97>
lea    0xe88(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <isSmithNumber@plt>
cmp    $0x0,%rax
je     11b5 <main+0x75>
mov    -0x20(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <main+0x86>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118d <main+0x4d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1166 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <findPrimeList@plt>
lea    0xea7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
jle    11c0 <main+0x80>
lea    0xe8e(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe86(%rip),%r12
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x10(%rsp),%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <isSmithNumber@plt>
test   %rax,%rax
je     1190 <main+0x50>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
cmp    $0x1,%rax
jg     1180 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (...) @findPrimeList()
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%7 = load i64, i64* %1
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %0, %17
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ %11, %9 ], [ %14, %12 ]
%14 = add nsw i64 %13, 1
%15 = call i64 @isSmithNumber(i64 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %12, label %17
17: ; preds = %12
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%19 = load i64, i64* %1
%20 = add nsw i64 %19, -1
store i64 %20, i64* %1
%21 = icmp sgt i64 %19, 1
br i1 %21, label %9, label %22
22: ; preds = %17, %0
ret i32 0
}