#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int loop;
  scanf("%d", &loop);
  while (loop--) {
    int num, tot = 0;
    scanf("%d", &num);
    while (num) {
      if (num % 2 == 1)
        tot++;
      num /= 2;
    }
    printf("%d\n", tot);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11b8 <main+0x98>
movl   $0x0,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11a4 <main+0x84>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1191 <main+0x71>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    116a <main+0x4a>
mov    -0x10(%rbp),%esi
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    114d <main+0x2d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xeac(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xea3(%rip),%rbx
jmp    117f <main+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1141 <main+0x21>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
xor    %esi,%esi
test   %eax,%eax
je     1170 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
mov    %eax,%edx
and    $0xfffffffe,%edx
mov    %ecx,%edi
sub    %edx,%edi
xor    %edx,%edx
cmp    $0x1,%edi
sete   %dl
add    %edx,%esi
sar    %eax
add    $0x1,%ecx
cmp    $0x2,%ecx
ja     11a0 <main+0x80>
mov    %eax,0x8(%rsp)
jmp    1170 <main+0x50>

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

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