#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*/ num(long long);
long long pow(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t, i, j;
  long long n;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%Ld", &n);
    if (n == 0)
      printf("Zero\n");
    else {
      if (n >= pow(10, 9)) {
        num(n / (long long)pow(10, 9));
        printf("Billion ");
      }
      n = n % (long long)pow(10, 9);
      if (n >= pow(10, 6)) {
        num(n / (long long)pow(10, 6));
        printf("Million ");
      }
      n = n % (long long)pow(10, 6);
      if (n >= pow(10, 3)) {
        num(n / (long long)pow(10, 3));
        printf("Thousand ");
      }
      n = n % (long long)pow(10, 3);
      num(n);
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1359 <main+0x219>
lea    0xe88(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11a2 <main+0x62>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
jmp    1346 <main+0x206>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0xa,%edi
mov    $0x9,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jl     1200 <main+0xc0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0xa,%edi
mov    $0x9,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <num@plt>
lea    0xe12(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0xa,%edi
mov    $0x9,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jl     1285 <main+0x145>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <num@plt>
lea    0xd96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0xa,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jl     130a <main+0x1ca>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0xa,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <num@plt>
lea    0xd1a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    $0xa,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <num@plt>
lea    0xcca(%rip),%rdi
call   1040 <printf@plt>
jmp    134b <main+0x20b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1168 <main+0x28>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    13d1 <main+0x271>
lea    0xe70(%rip),%r14
lea    0x8(%rsp),%rbx
lea    0xe84(%rip),%r15
xor    %r13d,%r13d
jmp    11c7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1050 <puts@plt>
add    $0x1,%r13d
cmp    0x14(%rsp),%r13d
jge    13d1 <main+0x271>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     11b0 <main+0x50>
mov    $0xa,%edi
mov    $0x9,%esi
call   1080 <pow@plt>
cmp    %rax,%rbp
jl     1239 <main+0xd9>
mov    0x8(%rsp),%r12
mov    $0xa,%edi
mov    $0x9,%esi
call   1080 <pow@plt>
mov    %rax,%rcx
or     %r12,%rax
shr    $0x20,%rax
je     121f <main+0xbf>
mov    %r12,%rax
cqto
idiv   %rcx
mov    %rax,%rdi
jmp    1228 <main+0xc8>
mov    %r12d,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
call   1030 <num@plt>
lea    0xdd3(%rip),%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rbp
mov    $0xa,%edi
mov    $0x9,%esi
call   1080 <pow@plt>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     1270 <main+0x110>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rdx,%rbp
jmp    1278 <main+0x118>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%ebp
mov    %rbp,0x8(%rsp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1080 <pow@plt>
cmp    %rax,%rbp
jl     12d7 <main+0x177>
mov    0x8(%rsp),%rbp
mov    $0xa,%edi
mov    $0x6,%esi
call   1080 <pow@plt>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     12be <main+0x15e>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rax,%rdi
jmp    12c6 <main+0x166>
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
call   1030 <num@plt>
lea    0xd3e(%rip),%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rbp
mov    $0xa,%edi
mov    $0x6,%esi
call   1080 <pow@plt>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     1310 <main+0x1b0>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rdx,%rbp
jmp    1318 <main+0x1b8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%ebp
mov    %rbp,0x8(%rsp)
mov    $0xa,%edi
mov    $0x3,%esi
call   1080 <pow@plt>
cmp    %rax,%rbp
jl     1377 <main+0x217>
mov    0x8(%rsp),%rbp
mov    $0xa,%edi
mov    $0x3,%esi
call   1080 <pow@plt>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     135e <main+0x1fe>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rax,%rdi
jmp    1366 <main+0x206>
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
call   1030 <num@plt>
lea    0xca7(%rip),%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rbp
mov    $0xa,%edi
mov    $0x3,%esi
call   1080 <pow@plt>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
je     13b0 <main+0x250>
mov    %rbp,%rax
cqto
idiv   %rcx
mov    %rdx,%rdi
jmp    13b8 <main+0x258>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
mov    %rdi,0x8(%rsp)
call   1030 <num@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    11b8 <main+0x58>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%Ld\00"
@.str.2 = [6 x i8] c"Zero\0A\00"
@.str.3 = [9 x i8] c"Billion \00"
@.str.4 = [9 x i8] c"Million \00"
@.str.5 = [10 x i8] c"Thousand \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %7
7: ; preds = %61, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %64
11: ; preds = %7
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %5)
%13 = load i64, i64* %5
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %60
17: ; preds = %11
%18 = load i64, i64* %5
%19 = call i64 @pow(i32 10, i32 9)
%20 = icmp sge i64 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i64, i64* %5
%23 = call i64 @pow(i32 10, i32 9)
%24 = sdiv i64 %22, %23
%25 = call i32 @num(i64 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %21, %17
%28 = load i64, i64* %5
%29 = call i64 @pow(i32 10, i32 9)
%30 = srem i64 %28, %29
store i64 %30, i64* %5
%31 = load i64, i64* %5
%32 = call i64 @pow(i32 10, i32 6)
%33 = icmp sge i64 %31, %32
br i1 %33, label %34, label %40
34: ; preds = %27
%35 = load i64, i64* %5
%36 = call i64 @pow(i32 10, i32 6)
%37 = sdiv i64 %35, %36
%38 = call i32 @num(i64 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %34, %27
%41 = load i64, i64* %5
%42 = call i64 @pow(i32 10, i32 6)
%43 = srem i64 %41, %42
store i64 %43, i64* %5
%44 = load i64, i64* %5
%45 = call i64 @pow(i32 10, i32 3)
%46 = icmp sge i64 %44, %45
br i1 %46, label %47, label %53
47: ; preds = %40
%48 = load i64, i64* %5
%49 = call i64 @pow(i32 10, i32 3)
%50 = sdiv i64 %48, %49
%51 = call i32 @num(i64 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %47, %40
%54 = load i64, i64* %5
%55 = call i64 @pow(i32 10, i32 3)
%56 = srem i64 %54, %55
store i64 %56, i64* %5
%57 = load i64, i64* %5
%58 = call i32 @num(i64 %57)
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %53, %15
br label %61
61: ; preds = %60
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %7
64: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%Ld\00"
@.str.3 = [9 x i8] c"Billion \00"
@.str.4 = [9 x i8] c"Million \00"
@.str.5 = [10 x i8] c"Thousand \00"
@str = [5 x i8] c"Zero\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %58
8: ; preds = %0, %54
%9 = phi i32 [ %55, %54 ], [ 0, %0 ]
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %54
15: ; preds = %8
%16 = call i64 @pow(i32 10, i32 9)
%17 = icmp slt i64 %11, %16
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = load i64, i64* %2
%20 = call i64 @pow(i32 10, i32 9)
%21 = sdiv i64 %19, %20
%22 = call i32 @num(i64 %21)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %18, %15
%25 = load i64, i64* %2
%26 = call i64 @pow(i32 10, i32 9)
%27 = srem i64 %25, %26
store i64 %27, i64* %2
%28 = call i64 @pow(i32 10, i32 6)
%29 = icmp slt i64 %27, %28
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = load i64, i64* %2
%32 = call i64 @pow(i32 10, i32 6)
%33 = sdiv i64 %31, %32
%34 = call i32 @num(i64 %33)
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %30, %24
%37 = load i64, i64* %2
%38 = call i64 @pow(i32 10, i32 6)
%39 = srem i64 %37, %38
store i64 %39, i64* %2
%40 = call i64 @pow(i32 10, i32 3)
%41 = icmp slt i64 %39, %40
br i1 %41, label %48, label %42
42: ; preds = %36
%43 = load i64, i64* %2
%44 = call i64 @pow(i32 10, i32 3)
%45 = sdiv i64 %43, %44
%46 = call i32 @num(i64 %45)
%47 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %42, %36
%49 = load i64, i64* %2
%50 = call i64 @pow(i32 10, i32 3)
%51 = srem i64 %49, %50
store i64 %51, i64* %2
%52 = call i32 @num(i64 %51)
%53 = call i32 @putchar(i32 10)
br label %54
54: ; preds = %13, %48
%55 = add nuw nsw i32 %9, 1
%56 = load i32, i32* %1
%57 = icmp slt i32 %55, %56
br i1 %57, label %8, label %58
58: ; preds = %54, %0
ret i32 0
}