#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__ atoi(char *);
int nearest2(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char req[100];
  int N, i = 0;
  scanf("%d", &N);
  while (N--) {
    scanf("%s", req);
    i = 0;
    while (req[i] != 'K') {
      i++;
    }
    req[i] = '\0';
    printf("%u", nearest2((unsigned int)atoi(req)));
    printf("K\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xea0(%rip),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x74(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x74(%rbp)
cmp    $0x0,%eax
je     11f4 <main+0xb4>
lea    -0x70(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x78(%rbp)
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x4b,%eax
je     11b8 <main+0x78>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1198 <main+0x58>
movslq -0x78(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1030 <nearest2@plt>
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    116b <main+0x2b>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe9e(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     11ec <main+0x9c>
lea    0xe87(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe7e(%rip),%r15
lea    0xe7a(%rip),%r12
nop
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x4b,0x11(%rsp,%rax,1)
lea    0x1(%rax),%rax
jne    11b0 <main+0x60>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1030 <nearest2@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
subl   $0x1,0xc(%rsp)
jae    1190 <main+0x40>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [3 x i8] c"K\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %23, %0
%7 = load i32, i32* %3
%8 = add nsw i32 %7, -1
store i32 %8, i32* %3
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %33
10: ; preds = %6
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 0, i32* %4
br label %13
13: ; preds = %20, %10
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 75
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %13
23: ; preds = %13
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
store i8 0, i8* %26
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%28 = call i64 @atoi(i8* %27)
%29 = trunc i64 %28 to i32
%30 = call i32 @nearest2(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %6
33: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%u\00"
@str = [2 x i8] c"K\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = icmp eq i32 %6, 0
br i1 %8, label %28, label %9
9: ; preds = %0, %17
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ %16, %11 ], [ 0, %9 ]
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 75
%16 = add nuw i64 %12, 1
br i1 %15, label %17, label %11
17: ; preds = %11
%18 = and i64 %12, 4294967295
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i64 @atoi(i8* %3)
%21 = trunc i64 %20 to i32
%22 = call i32 @nearest2(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = add nsw i32 %25, -1
store i32 %26, i32* %2
%27 = icmp eq i32 %25, 0
br i1 %27, label %28, label %9
28: ; preds = %17, %0
ret i32 0
}