#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, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t, i;
  double ara[15];
  scanf("%d", &t);
  for (i = 1; i <= t; i++) {
    int j, temp;
    double sum = 0;
    for (j = 0; j < 12; j++) {
      scanf("%lf", &ara[j]);
      sum += ara[j];
    }
    sum = sum / 12.0;
    if (sum < 1000) {
      printf("%d $%.2lf\n", i, sum);
      continue;
    }
    temp = sum / 1000;
    sum = sum - (temp * 1000);
    printf("%d $%d,%.2lf\n", i, temp, sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     128d <main+0x16d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movl   $0x0,-0x94(%rbp)
cmpl   $0xc,-0x94(%rbp)
jge    11d0 <main+0xb0>
movslq -0x94(%rbp),%rax
lea    -0x90(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x94(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
addsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    116c <main+0x4c>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xe0c(%rip),%xmm0
ucomisd -0xa0(%rbp),%xmm0
ff
jbe    1220 <main+0x100>
mov    -0xc(%rbp),%esi
cvttsd2si -0xa0(%rbp),%edx
ff
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <main+0x15f>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  0xdd0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x98(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
imul   $0x3e8,-0x98(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0xc(%rbp),%esi
mov    -0x98(%rbp),%edx
movsd  -0xa0(%rbp),%xmm0
ff
lea    0xdaa(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114b <main+0x2b>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xee0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1351 <main+0x231>
lea    0x58(%rsp),%r12
lea    0x60(%rsp),%r13
lea    0x68(%rsp),%rbx
lea    0xeb6(%rip),%rbp
lea    0x10(%rsp),%r14
xor    %r15d,%r15d
jmp    11a9 <main+0x89>
nop
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edx
imul   $0x3e8,%edx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
lea    0xe96(%rip),%rdi
mov    %r15d,%esi
mov    $0x1,%al
call   1030 <printf@plt>
cmp    0xc(%rsp),%r15d
jge    1351 <main+0x231>
add    $0x1,%r15d
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
addsd  0xe48(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x28(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x38(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x40(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x48(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x48(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
lea    0x50(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x50(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x58(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x60(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
addsd  0x68(%rsp),%xmm0
divsd  0xce1(%rip),%xmm0
movsd  0xce1(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1170 <main+0x50>
cvttsd2si %xmm0,%edx
lea    0xce3(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    0xc(%rsp),%r15d
jl     11a9 <main+0x89>
xor    %eax,%eax
add    $0x88,%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"%lf\00"
@.str.2 = [11 x i8] c"%d $%.2lf\0A\00"
@.str.3 = [14 x i8] c"%d $%d,%.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [15 x double]
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %9
9: ; preds = %54, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %57
13: ; preds = %9
store double 0.000000e+00, double* %7
store i32 0, i32* %5
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 12
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [15 x double], [15 x double]* %4, i64 0, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %20)
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [15 x double], [15 x double]* %4, i64 0, i64 %23
%25 = load double, double* %24
%26 = load double, double* %7
%27 = fadd double %26, %25
store double %27, double* %7
br label %28
28: ; preds = %17
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %14
31: ; preds = %14
%32 = load double, double* %7
%33 = fdiv double %32, 1.200000e+01
store double %33, double* %7
%34 = load double, double* %7
%35 = fcmp olt double %34, 1.000000e+03
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* %3
%38 = load double, double* %7
%39 = fptosi double %38 to i32
%40 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %39)
br label %54
41: ; preds = %31
%42 = load double, double* %7
%43 = fdiv double %42, 1.000000e+03
%44 = fptosi double %43 to i32
store i32 %44, i32* %6
%45 = load double, double* %7
%46 = load i32, i32* %6
%47 = mul nsw i32 %46, 1000
%48 = sitofp i32 %47 to double
%49 = fsub double %45, %48
store double %49, double* %7
%50 = load i32, i32* %3
%51 = load i32, i32* %6
%52 = load double, double* %7
%53 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %50, i32 %51, double %52)
br label %54
54: ; preds = %41, %36
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %9
57: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [11 x i8] c"%d $%.2lf\0A\00"
@.str.3 = [14 x i8] c"%d $%d,%.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x double]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [15 x double]* %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 slt i32 %6, 1
br i1 %7, label %75, label %8
8: ; preds = %0
%9 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 0
%10 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 1
%11 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 2
%12 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 3
%13 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 4
%14 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 5
%15 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 6
%16 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 7
%17 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 8
%18 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 9
%19 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 10
%20 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 11
br label %21
21: ; preds = %8, %71
%22 = phi i32 [ %72, %71 ], [ 1, %8 ]
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %9)
%24 = load double, double* %9
%25 = fadd double %24, 0.000000e+00
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %10)
%27 = load double, double* %10
%28 = fadd double %25, %27
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %11)
%30 = load double, double* %11
%31 = fadd double %28, %30
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %12)
%33 = load double, double* %12
%34 = fadd double %31, %33
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %13)
%36 = load double, double* %13
%37 = fadd double %34, %36
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %14)
%39 = load double, double* %14
%40 = fadd double %37, %39
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %15)
%42 = load double, double* %15
%43 = fadd double %40, %42
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %16)
%45 = load double, double* %16
%46 = fadd double %43, %45
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %17)
%48 = load double, double* %17
%49 = fadd double %46, %48
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %18)
%51 = load double, double* %18
%52 = fadd double %49, %51
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %19)
%54 = load double, double* %19
%55 = fadd double %52, %54
%56 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %20)
%57 = load double, double* %20
%58 = fadd double %55, %57
%59 = fdiv double %58, 1.200000e+01
%60 = fcmp olt double %59, 1.000000e+03
br i1 %60, label %61, label %64
61: ; preds = %21
%62 = fptosi double %59 to i32
%63 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %62)
br label %71
64: ; preds = %21
%65 = fdiv double %59, 1.000000e+03
%66 = fptosi double %65 to i32
%67 = mul nsw i32 %66, 1000
%68 = sitofp i32 %67 to double
%69 = fsub double %59, %68
%70 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %66, double %69)
br label %71
71: ; preds = %64, %61
%72 = add nuw nsw i32 %22, 1
%73 = load i32, i32* %1
%74 = icmp slt i32 %22, %73
br i1 %74, label %21, label %75
75: ; preds = %71, %0
ret i32 0
}