#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 getarraymin(int *);
int min(int, int /*<<< orphan*/);
int /*<<< orphan*/ multiply(char, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int iterations = 0;
  scanf("%d", &iterations);
  int candles[10] = {0};
  int result = 1000000000;
  int array_min = 0;
  for (int i = 0; i < iterations; ++i) {
    result = 1000000000;
    for (int j = 0; j < 10; ++j) {
      scanf("%d", &candles[j]);
    }
    array_min = getarraymin(candles);
    for (int k = 0; k < 10; ++k) {
      if (candles[k] == array_min) {
        if (k == 0) {
          result = min(result, multiply('0', array_min + 1));
        } else {
          result = min(result, multiply((char)(((int)'0') + k), array_min + 1));
        }
      }
    }
    printf("%d\n", result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe7c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
movl   $0x3b9aca00,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12bb <main+0x15b>
movl   $0x3b9aca00,-0x44(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0xa,-0x50(%rbp)
jge    11ff <main+0x9f>
movslq -0x50(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe14(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11cc <main+0x6c>
lea    -0x40(%rbp),%rdi
call   1080 <getarraymin@plt>
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0xa,-0x54(%rbp)
jge    129e <main+0x13e>
movslq -0x54(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
cmp    -0x48(%rbp),%eax
jne    128b <main+0x12b>
cmpl   $0x0,-0x54(%rbp)
jne    125f <main+0xff>
mov    -0x44(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x48(%rbp),%esi
add    $0x1,%esi
mov    $0x30,%edi
call   1030 <multiply@plt>
mov    -0x58(%rbp),%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,-0x44(%rbp)
jmp    1286 <main+0x126>
mov    -0x44(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x54(%rbp),%eax
add    $0x30,%eax
mov    -0x48(%rbp),%esi
add    $0x1,%esi
movsbl %al,%edi
call   1030 <multiply@plt>
mov    -0x5c(%rbp),%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,-0x44(%rbp)
jmp    128b <main+0x12b>
jmp    1290 <main+0x130>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1212 <main+0xb2>
mov    -0x44(%rbp),%esi
lea    0xd5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11b2 <main+0x52>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe93(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    143e <main+0x2ee>
xor    %ebp,%ebp
lea    0xe5f(%rip),%r13
lea    0x10(%rsp),%rbx
jmp    11cc <main+0x7c>
nopl   0x0(%rax,%rax,1)
lea    0xe4c(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    143e <main+0x2ee>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x18(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x1c(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x24(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x28(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x2c(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x30(%rsp),%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
lea    0x34(%rsp),%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1070 <getarraymin@plt>
mov    %eax,%r15d
lea    0x1(%r15),%r14d
mov    $0x3b9aca00,%r12d
cmp    %eax,0x10(%rsp)
je     12d0 <main+0x180>
cmp    %r15d,0x14(%rsp)
je     12f7 <main+0x1a7>
cmp    %r15d,0x18(%rsp)
je     131c <main+0x1cc>
cmp    %r15d,0x1c(%rsp)
je     1341 <main+0x1f1>
cmp    %r15d,0x20(%rsp)
je     1366 <main+0x216>
cmp    %r15d,0x24(%rsp)
je     138b <main+0x23b>
cmp    %r15d,0x28(%rsp)
je     13b0 <main+0x260>
cmp    %r15d,0x2c(%rsp)
je     13d5 <main+0x285>
cmp    %r15d,0x30(%rsp)
je     13fa <main+0x2aa>
cmp    %r15d,0x34(%rsp)
jne    11b0 <main+0x60>
jmp    141f <main+0x2cf>
nop
mov    $0x30,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    $0x3b9aca00,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x14(%rsp)
jne    1272 <main+0x122>
mov    $0x31,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x18(%rsp)
jne    127d <main+0x12d>
mov    $0x32,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x1c(%rsp)
jne    1288 <main+0x138>
mov    $0x33,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x20(%rsp)
jne    1293 <main+0x143>
mov    $0x34,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x24(%rsp)
jne    129e <main+0x14e>
mov    $0x35,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x28(%rsp)
jne    12a9 <main+0x159>
mov    $0x36,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x2c(%rsp)
jne    12b4 <main+0x164>
mov    $0x37,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x30(%rsp)
jne    12bf <main+0x16f>
mov    $0x38,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
cmp    %r15d,0x34(%rsp)
jne    11b0 <main+0x60>
mov    $0x39,%edi
mov    %r14d,%esi
call   1030 <multiply@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r12d
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x38,%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 [10 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%14 = bitcast [10 x i32]* %7 to i8*
store i32 1000000000, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %15
15: ; preds = %70, %2
%16 = load i32, i32* %10
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %73
19: ; preds = %15
store i32 1000000000, i32* %8
store i32 0, i32* %11
br label %20
20: ; preds = %28, %19
%21 = load i32, i32* %11
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %23
%29 = load i32, i32* %11
%30 = add nsw i32 %29, 1
store i32 %30, i32* %11
br label %20
31: ; preds = %20
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%33 = call i32 @getarraymin(i32* %32)
store i32 %33, i32* %9
store i32 0, i32* %12
br label %34
34: ; preds = %64, %31
%35 = load i32, i32* %12
%36 = icmp slt i32 %35, 10
br i1 %36, label %37, label %67
37: ; preds = %34
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = load i32, i32* %9
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %63
44: ; preds = %37
%45 = load i32, i32* %12
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
%51 = call i32 @multiply(i8 signext 48, i32 %50)
%52 = call i32 @min(i32 %48, i32 %51)
store i32 %52, i32* %8
br label %62
53: ; preds = %44
%54 = load i32, i32* %8
%55 = load i32, i32* %12
%56 = add nsw i32 48, %55
%57 = trunc i32 %56 to i8
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
%60 = call i32 @multiply(i8 signext %57, i32 %59)
%61 = call i32 @min(i32 %54, i32 %60)
store i32 %61, i32* %8
br label %62
62: ; preds = %53, %47
br label %63
63: ; preds = %62, %37
br label %64
64: ; preds = %63
%65 = load i32, i32* %12
%66 = add nsw i32 %65, 1
store i32 %66, i32* %12
br label %34
67: ; preds = %34
%68 = load i32, i32* %8
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %67
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %15
73: ; preds = %15
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 [10 x i32]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = bitcast [10 x i32]* %4 to i8*
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %46
10: ; preds = %2
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 1
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 2
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 3
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 4
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 5
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 6
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 7
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 8
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 9
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 1
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 2
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 3
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 4
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 5
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 6
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 7
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 8
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 9
br label %30
30: ; preds = %10, %113
%31 = phi i32 [ 0, %10 ], [ %116, %113 ]
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %20)
%42 = call i32 @getarraymin(i32* %11)
%43 = add nsw i32 %42, 1
%44 = load i32, i32* %11
%45 = icmp eq i32 %44, %42
br i1 %45, label %47, label %50
46: ; preds = %113, %2
ret i32 0
47: ; preds = %30
%48 = call i32 @multiply(i8 signext 48, i32 %43)
%49 = call i32 @min(i32 1000000000, i32 %48)
br label %50
50: ; preds = %47, %30
%51 = phi i32 [ %49, %47 ], [ 1000000000, %30 ]
%52 = load i32, i32* %21
%53 = icmp eq i32 %52, %42
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 @multiply(i8 signext 49, i32 %43)
%56 = call i32 @min(i32 %51, i32 %55)
br label %57
57: ; preds = %50, %54
%58 = phi i32 [ %56, %54 ], [ %51, %50 ]
%59 = load i32, i32* %22
%60 = icmp eq i32 %59, %42
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = call i32 @multiply(i8 signext 50, i32 %43)
%63 = call i32 @min(i32 %58, i32 %62)
br label %64
64: ; preds = %61, %57
%65 = phi i32 [ %63, %61 ], [ %58, %57 ]
%66 = load i32, i32* %23
%67 = icmp eq i32 %66, %42
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = call i32 @multiply(i8 signext 51, i32 %43)
%70 = call i32 @min(i32 %65, i32 %69)
br label %71
71: ; preds = %68, %64
%72 = phi i32 [ %70, %68 ], [ %65, %64 ]
%73 = load i32, i32* %24
%74 = icmp eq i32 %73, %42
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = call i32 @multiply(i8 signext 52, i32 %43)
%77 = call i32 @min(i32 %72, i32 %76)
br label %78
78: ; preds = %75, %71
%79 = phi i32 [ %77, %75 ], [ %72, %71 ]
%80 = load i32, i32* %25
%81 = icmp eq i32 %80, %42
br i1 %81, label %82, label %85
82: ; preds = %78
%83 = call i32 @multiply(i8 signext 53, i32 %43)
%84 = call i32 @min(i32 %79, i32 %83)
br label %85
85: ; preds = %82, %78
%86 = phi i32 [ %84, %82 ], [ %79, %78 ]
%87 = load i32, i32* %26
%88 = icmp eq i32 %87, %42
br i1 %88, label %89, label %92
89: ; preds = %85
%90 = call i32 @multiply(i8 signext 54, i32 %43)
%91 = call i32 @min(i32 %86, i32 %90)
br label %92
92: ; preds = %89, %85
%93 = phi i32 [ %91, %89 ], [ %86, %85 ]
%94 = load i32, i32* %27
%95 = icmp eq i32 %94, %42
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = call i32 @multiply(i8 signext 55, i32 %43)
%98 = call i32 @min(i32 %93, i32 %97)
br label %99
99: ; preds = %96, %92
%100 = phi i32 [ %98, %96 ], [ %93, %92 ]
%101 = load i32, i32* %28
%102 = icmp eq i32 %101, %42
br i1 %102, label %103, label %106
103: ; preds = %99
%104 = call i32 @multiply(i8 signext 56, i32 %43)
%105 = call i32 @min(i32 %100, i32 %104)
br label %106
106: ; preds = %103, %99
%107 = phi i32 [ %105, %103 ], [ %100, %99 ]
%108 = load i32, i32* %29
%109 = icmp eq i32 %108, %42
br i1 %109, label %110, label %113
110: ; preds = %106
%111 = call i32 @multiply(i8 signext 57, i32 %43)
%112 = call i32 @min(i32 %107, i32 %111)
br label %113
113: ; preds = %110, %106
%114 = phi i32 [ %112, %110 ], [ %107, %106 ]
%115 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %114)
%116 = add nuw nsw i32 %31, 1
%117 = load i32, i32* %3
%118 = icmp slt i32 %116, %117
br i1 %118, label %30, label %46
}