#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 n, d, sum;
  char c;
  scanf("%d", &n);
  while (n--) {
    sum = 0;
    while (1) {
      scanf("%d%c", &d, &c);
      sum = sum + d;
      if (c == '\n') {
        printf("%d\n", sum);
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11a6 <main+0x86>
movl   $0x0,-0x10(%rbp)
lea    0xea0(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x11(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    119c <main+0x7c>
mov    -0x10(%rbp),%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <main+0x81>
jmp    115c <main+0x3c>
jmp    1141 <main+0x21>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x8(%rsp)
jb     1191 <main+0x71>
lea    0xeb6(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x7(%rsp),%rbx
lea    0xeaa(%rip),%r12
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    0xc(%rsp),%ebp
cmpb   $0xa,0x7(%rsp)
jne    1160 <main+0x40>
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
mov    $0x0,%ebp
jae    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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