#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 abs(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int num_cases;
  double n;
  int result;
  scanf("%d\n", &num_cases);
  while (num_cases-- > 0) {
    scanf("%lf\n", &n);
    n = (n * 567.0 / 9.0 + 7492.0) * 235.0 / 47.0 - 498.0;
    result = (int)(n + 0.5);
    result = abs(result / 10 % 10);
    printf("%d\n", result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    120a <main+0xda>
lea    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  0xeb1(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe9c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe88(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe74(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe60(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe4c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe33(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <abs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf08(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    121a <main+0xfa>
lea    0xee6(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xed6(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xe75(%rip),%xmm0
divsd  0xe75(%rip),%xmm0
addsd  0xe75(%rip),%xmm0
mulsd  0xe75(%rip),%xmm0
divsd  0xe75(%rip),%xmm0
addsd  0xe75(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  0xe6f(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,%esi
neg    %esi
cmovs  %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jg     1170 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %3)
%12 = load double, double* %3
%13 = fmul double %12, 5.670000e+02
%14 = fdiv double %13, 9.000000e+00
%15 = fadd double %14, 7.492000e+03
%16 = fmul double %15, 2.350000e+02
%17 = fdiv double %16, 4.700000e+01
%18 = fsub double %17, 4.980000e+02
store double %18, double* %3
%19 = load double, double* %3
%20 = fadd double %19, 5.000000e-01
%21 = fptosi double %20 to i32
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = sdiv i32 %22, 10
%24 = srem i32 %23, 10
%25 = call i32 @abs(i32 %24)
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %6
28: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %27
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = load double, double* %2
%12 = fmul double %11, 5.670000e+02
%13 = fdiv double %12, 9.000000e+00
%14 = fadd double %13, 7.492000e+03
%15 = fmul double %14, 2.350000e+02
%16 = fdiv double %15, 4.700000e+01
%17 = fadd double %16, -4.980000e+02
store double %17, double* %2
%18 = fadd double %17, 5.000000e-01
%19 = fptosi double %18 to i32
%20 = sdiv i32 %19, 10
%21 = srem i32 %20, 10
%22 = call i32 @llvm.abs.i32(i32 %21, i1 true)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %1
%25 = add nsw i32 %24, -1
store i32 %25, i32* %1
%26 = icmp sgt i32 %24, 0
br i1 %26, label %9, label %27
27: ; preds = %9, %0
ret i32 0
}