#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 */
char getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, s, l[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  char d;
  scanf("%d", &n);
  getchar();
  while (n--) {
    s = 0;
    while ((d = getchar()) != '\n') {
      s += l[d - '0'];
    }
    printf("%d leds\n", s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11d8 <main+0x98>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x41(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11c4 <main+0x84>
movsbl -0x41(%rbp),%eax
sub    $0x30,%eax
cltq
mov    -0x40(%rbp,%rax,4),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x56>
mov    -0xc(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    117b <main+0x3b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xee9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
subl   $0x1,0xc(%rsp)
jae    1162 <main+0x32>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xec2(%rip),%r14
lea    0xe90(%rip),%rbx
jmp    1191 <main+0x61>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1157 <main+0x27>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x0,%ebp
cmp    $0xa,%al
je     1180 <main+0x50>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbq %al,%rax
add    -0xc0(%rbx,%rax,4),%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <main+0x80>
jmp    1180 <main+0x50>

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

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