#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 count1(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int main() {
  int n, m, k, i;
  int b1, b2;
  char buff[11] = "0x";
  buff[10] = 0;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &m);
    b1 = count1(m);
    sprintf(buff + 2, "%d", m);
    sscanf(buff, "%x", &b2);
    b2 = count1(b2);
    printf("%d %d\n", b1, b2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x27(%rbp)
mov    0xe97(%rip),%ax
mov    %ax,-0x1f(%rbp)
mov    0xe8f(%rip),%al
mov    %al,-0x1d(%rbp)
movb   $0x0,-0x1d(%rbp)
lea    0xe82(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     120e <main+0xbe>
lea    0xe5e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1030 <count1@plt>
mov    %eax,-0x18(%rbp)
lea    -0x27(%rbp),%rdi
add    $0x2,%rdi
mov    -0xc(%rbp),%edx
lea    0xe38(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x27(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x1c(%rbp),%edi
call   1030 <count1@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
jmp    1192 <main+0x42>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movw   $0x0,0x20(%rsp)
movq   $0x7830,0x18(%rsp)
movb   $0x0,0x22(%rsp)
lea    0xe91(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
subl   $0x1,0x14(%rsp)
jb     1209 <main+0xb9>
lea    0xe79(%rip),%rbx
lea    0xe75(%rip),%r12
lea    0x18(%rsp),%r13
lea    0xc(%rsp),%rbp
lea    0xe67(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x10(%rsp),%edi
call   1030 <count1@plt>
mov    %eax,%r15d
mov    0x10(%rsp),%edx
lea    0x1a(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <sprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%edi
call   1030 <count1@plt>
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   1040 <printf@plt>
subl   $0x1,0x14(%rsp)
jae    11b0 <main+0x60>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.buff = [11 x i8] c"0x\00\00\00\00\00\00\00\00\00"
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 10
store i8 0, i8* %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
%13 = icmp eq i32 %11, 0
br i1 %13, label %29, label %14
14: ; preds = %0
%15 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 2
br label %16
16: ; preds = %14, %16
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %2
%19 = call i32 @count1(i32 %18)
%20 = load i32, i32* %2
%21 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = call i32 @count1(i32 %23)
store i32 %24, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %24)
%26 = load i32, i32* %1
%27 = add nsw i32 %26, -1
store i32 %27, i32* %1
%28 = icmp eq i32 %26, 0
br i1 %28, label %29, label %16
29: ; preds = %16, %0
ret i32 0
}