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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1206 <main+0xc6>
movl   $0x0,-0x24(%rbp)
lea    0xe72(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     11e9 <main+0xa9>
lea    0xe47(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x20(%rbp),%edi
call   1040 <Isprime@plt>
cmp    $0x0,%rax
je     11e4 <main+0xa4>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    119e <main+0x5e>
mov    -0x24(%rbp),%esi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <main+0x34>
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    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <getchar@plt>
cmpl   $0x0,0x14(%rsp)
jle    1204 <main+0xc4>
lea    0xe85(%rip),%rbx
lea    0x10(%rsp),%r14
lea    0xe7c(%rip),%r15
lea    0xc(%rsp),%r12
jmp    11a5 <main+0x65>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r13d
cmp    0x14(%rsp),%r13d
jge    1204 <main+0xc4>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
subl   $0x1,0x10(%rsp)
jb     1190 <main+0x50>
xor    %ebp,%ebp
jmp    11d9 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ecx,%ebp
subl   $0x1,0x10(%rsp)
jb     1190 <main+0x50>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0xc(%rsp),%edi
call   1040 <Isprime@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     11d0 <main+0x90>
mov    0xc(%rsp),%ecx
jmp    11d0 <main+0x90>
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"%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
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%12 = call i32 (...) @getchar()
store i32 0, i32* %7
br label %13
13: ; preds = %38, %2
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %41
17: ; preds = %13
store i32 0, i32* %10
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%19 = call i32 (...) @getchar()
br label %20
20: ; preds = %34, %17
%21 = load i32, i32* %8
%22 = add nsw i32 %21, -1
store i32 %22, i32* %8
%23 = icmp ne i32 %21, 0
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%26 = call i32 (...) @getchar()
%27 = load i32, i32* %9
%28 = call i64 @Isprime(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = load i32, i32* %9
%32 = load i32, i32* %10
%33 = add nsw i32 %32, %31
store i32 %33, i32* %10
br label %34
34: ; preds = %30, %24
br label %20
35: ; preds = %20
%36 = load i32, i32* %10
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %13
41: ; preds = %13
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 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = call i32 (...) @getchar()
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %40
12: ; preds = %2
%13 = bitcast i32* %5 to i8*
br label %14
14: ; preds = %12, %34
%15 = phi i32 [ 0, %12 ], [ %37, %34 ]
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%17 = call i32 (...) @getchar()
%18 = load i32, i32* %4
%19 = add nsw i32 %18, -1
store i32 %19, i32* %4
%20 = icmp eq i32 %18, 0
br i1 %20, label %34, label %21
21: ; preds = %14, %21
%22 = phi i32 [ %30, %21 ], [ 0, %14 ]
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%24 = call i32 (...) @getchar()
%25 = load i32, i32* %5
%26 = call i64 @Isprime(i32 %25)
%27 = icmp eq i64 %26, 0
%28 = load i32, i32* %5
%29 = select i1 %27, i32 0, i32 %28
%30 = add nsw i32 %29, %22
%31 = load i32, i32* %4
%32 = add nsw i32 %31, -1
store i32 %32, i32* %4
%33 = icmp eq i32 %31, 0
br i1 %33, label %34, label %21
34: ; preds = %21, %14
%35 = phi i32 [ 0, %14 ], [ %30, %21 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i32 %15, 1
%38 = load i32, i32* %3
%39 = icmp slt i32 %37, %38
br i1 %39, label %14, label %40
40: ; preds = %34, %2
ret i32 0
}