#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*/ getchar();
scalar_t__ jiecheng(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int lines;
  scanf("%d", &lines);
  getchar();
  while (lines--) {
    int num, count = 0;
    scanf("%d", &num);
    getchar();
    while (num)
      count += jiecheng(num--);
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11df <main+0x9f>
movl   $0x0,-0x1c(%rbp)
lea    0xe71(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
cmpl   $0x0,-0x18(%rbp)
je     11cb <main+0x8b>
mov    -0x18(%rbp),%edi
mov    %edi,%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
call   1030 <jiecheng@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    119f <main+0x5f>
mov    -0x1c(%rbp),%esi
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
jmp    116d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
subl   $0x1,0x4(%rsp)
jae    1173 <main+0x33>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe86(%rip),%r14
mov    %rsp,%r15
lea    0xe7f(%rip),%rbx
jmp    11a1 <main+0x61>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1166 <main+0x26>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    (%rsp),%edi
test   %edi,%edi
je     1190 <main+0x50>
xor    %ebp,%ebp
xchg   %ax,%ax
lea    -0x1(%rdi),%eax
mov    %eax,(%rsp)
call   1030 <jiecheng@plt>
add    %eax,%ebp
mov    (%rsp),%edi
test   %edi,%edi
jne    11c0 <main+0x80>
jmp    1190 <main+0x50>

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