#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 fdnrPrime(int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int lines, i, num, prime;
  scanf("%d", &lines);
  getchar();
  for (i = 0; i < lines; i++) {
    scanf("%d", &num);
    getchar();
    prime = fdnrPrime(num, 0);
    printf("%d %d\n", prime, (prime - num > 0 ? prime - num : num - prime));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f0 <main+0xb0>
lea    0xe79(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1060 <fdnrPrime@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    $0x0,%eax
jle    11c7 <main+0x87>
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11d0 <main+0x90>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <main+0x34>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmpl   $0x0,0x4(%rsp)
jle    11bb <main+0x7b>
lea    0xe93(%rip),%r14
mov    %rsp,%r15
lea    0xe8c(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    (%rsp),%edi
xor    %esi,%esi
call   1060 <fdnrPrime@plt>
mov    %eax,%ecx
sub    (%rsp),%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %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
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%11 = call i32 (...) @getchar()
store i32 0, i32* %7
br label %12
12: ; preds = %37, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %40
16: ; preds = %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%18 = call i32 (...) @getchar()
%19 = load i32, i32* %8
%20 = call i32 @fdnrPrime(i32 %19, i32 0)
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = load i32, i32* %9
%23 = load i32, i32* %8
%24 = sub nsw i32 %22, %23
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %16
%27 = load i32, i32* %9
%28 = load i32, i32* %8
%29 = sub nsw i32 %27, %28
br label %34
30: ; preds = %16
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = sub nsw i32 %31, %32
br label %34
34: ; preds = %30, %26
%35 = phi i32 [ %29, %26 ], [ %33, %30 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %35)
br label %37
37: ; preds = %34
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %12
40: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = call i32 (...) @getchar()
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %2, %11
%12 = phi i32 [ %21, %11 ], [ 0, %2 ]
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = call i32 (...) @getchar()
%15 = load i32, i32* %4
%16 = call i32 @fdnrPrime(i32 %15, i32 0)
%17 = load i32, i32* %4
%18 = sub nsw i32 %16, %17
%19 = call i32 @llvm.abs.i32(i32 %18, i1 false)
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %19)
%21 = add nuw nsw i32 %12, 1
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %11, label %24
24: ; preds = %11, %2
ret i32 0
}