#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 INT_MAX;
int calc_print_cost(int, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int cost_table[64];
  int num_cases, num_integers;
  int cost_record[64], min_cost, num;
  int count, i;
  count = 0;
  scanf("%d\n", &num_cases);
  while (num_cases-- > 0) {
    printf("Case %d:\n", ++count);
    for (i = 0; i < 36; i++) {
      scanf("%d", &cost_table[i]);
    }
    scanf("%d\n", &num_integers);
    while (num_integers-- > 0) {
      scanf("%d\n", &num);
      min_cost = INT_MAX;
      for (i = 2; i <= 36; i++) {
        cost_record[i] = calc_print_cost(num, i, cost_table);
        if (cost_record[i] < min_cost) {
          min_cost = cost_record[i];
        }
      }
      printf("Cheapest base(s) for number %d:", num);
      for (i = 2; i <= 36; i++) {
        if (cost_record[i] == min_cost) {
          printf(" %d", i);
        }
      }
      printf("\n");
    }
    if (num_cases != 0) {
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x22c(%rbp)
lea    0xead(%rip),%rdi
lea    -0x114(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x114(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x114(%rbp)
cmp    $0x0,%eax
jle    135c <main+0x22c>
mov    -0x22c(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x22c(%rbp)
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x230(%rbp)
cmpl   $0x24,-0x230(%rbp)
jge    11e2 <main+0xb2>
movslq -0x230(%rbp),%rax
lea    -0x110(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe66(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x230(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x230(%rbp)
jmp    11a0 <main+0x70>
lea    0xe17(%rip),%rdi
lea    -0x118(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x118(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x118(%rbp)
cmp    $0x0,%eax
jle    133c <main+0x20c>
lea    0xdea(%rip),%rdi
lea    -0x228(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x224(%rbp)
movl   $0x2,-0x230(%rbp)
cmpl   $0x24,-0x230(%rbp)
jg     12b7 <main+0x187>
mov    -0x228(%rbp),%edi
mov    -0x230(%rbp),%esi
lea    -0x110(%rbp),%rdx
call   1050 <calc_print_cost@plt>
mov    %eax,%ecx
movslq -0x230(%rbp),%rax
mov    %ecx,-0x220(%rbp,%rax,4)
movslq -0x230(%rbp),%rax
mov    -0x220(%rbp,%rax,4),%eax
cmp    -0x224(%rbp),%eax
jge    129e <main+0x16e>
movslq -0x230(%rbp),%rax
mov    -0x220(%rbp,%rax,4),%eax
mov    %eax,-0x224(%rbp)
jmp    12a3 <main+0x173>
mov    -0x230(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x230(%rbp)
jmp    123b <main+0x10b>
mov    -0x228(%rbp),%esi
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x230(%rbp)
cmpl   $0x24,-0x230(%rbp)
jg     1329 <main+0x1f9>
movslq -0x230(%rbp),%rax
mov    -0x220(%rbp,%rax,4),%eax
cmp    -0x224(%rbp),%eax
jne    1310 <main+0x1e0>
mov    -0x230(%rbp),%esi
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1315 <main+0x1e5>
mov    -0x230(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x230(%rbp)
jmp    12d5 <main+0x1a5>
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <main+0xc5>
cmpl   $0x0,-0x114(%rbp)
je     1357 <main+0x227>
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
lea    0xea8(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,(%rsp)
test   %eax,%eax
jle    1475 <main+0x335>
lea    0xeb7(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe7c(%rip),%r12
lea    0xea3(%rip),%r13
xor    %ebx,%ebx
nopl   (%rax)
add    $0x1,%ebx
lea    0xe6a(%rip),%rdi
mov    %ebx,0xc(%rsp)
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x18(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x1c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x20(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x24(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x28(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x2c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x30(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x34(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x38(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x3c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x40(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x44(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x48(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x4c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x50(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x54(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x58(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x5c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x60(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x64(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x68(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x6c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x70(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x74(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x78(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x7c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x80(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x84(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x88(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x8c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x90(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x94(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x98(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
lea    0x9c(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
jmp    13aa <main+0x26a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    1450 <main+0x310>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2c17(%rip),%rax
mov    (%rax),%ebp
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%edi
mov    %ebx,%esi
mov    %r15,%rdx
call   1060 <calc_print_cost@plt>
mov    %eax,0x110(%rsp,%rbx,4)
cmp    %ebp,%eax
cmovl  %eax,%ebp
add    $0x1,%rbx
cmp    $0x25,%rbx
jne    13e0 <main+0x2a0>
mov    0x8(%rsp),%esi
lea    0xbff(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebx
jmp    142e <main+0x2ee>
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x25,%rbx
je     13a0 <main+0x260>
cmp    %ebp,0x110(%rsp,%rbx,4)
jne    1420 <main+0x2e0>
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1420 <main+0x2e0>
cs nopw 0x0(%rax,%rax,1)
nop
cmpl   $0x0,(%rsp)
mov    0xc(%rsp),%ebx
je     1475 <main+0x335>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,(%rsp)
test   %eax,%eax
jg     1190 <main+0x50>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [10 x i8] c"Case %d:\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@INT_MAX = global i32 0
@.str.3 = [32 x i8] c"Cheapest base(s) for number %d:\00"
@.str.4 = [4 x i8] c" %d\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [64 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %11
11: ; preds = %92, %0
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %93
15: ; preds = %11
%16 = load i32, i32* %8
%17 = add nsw i32 %16, 1
store i32 %17, i32* %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i32 0, i32* %9
br label %19
19: ; preds = %27, %15
%20 = load i32, i32* %9
%21 = icmp slt i32 %20, 36
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %22
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %19
30: ; preds = %19
%31 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %32
32: ; preds = %85, %30
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
%35 = icmp sgt i32 %33, 0
br i1 %35, label %36, label %87
36: ; preds = %32
%37 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %7)
%38 = load i32, i32* @INT_MAX
store i32 %38, i32* %6
store i32 2, i32* %9
br label %39
39: ; preds = %62, %36
%40 = load i32, i32* %9
%41 = icmp sle i32 %40, 36
br i1 %41, label %42, label %65
42: ; preds = %39
%43 = load i32, i32* %7
%44 = load i32, i32* %9
%45 = getelementptr inbounds [64 x i32], [64 x i32]* %2, i64 0, i64 0
%46 = call i32 @calc_print_cost(i32 %43, i32 %44, i32* %45)
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %48
store i32 %46, i32* %49
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %6
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %61
56: ; preds = %42
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %58
%60 = load i32, i32* %59
store i32 %60, i32* %6
br label %61
61: ; preds = %56, %42
br label %62
62: ; preds = %61
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %39
65: ; preds = %39
%66 = load i32, i32* %7
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %66)
store i32 2, i32* %9
br label %68
68: ; preds = %82, %65
%69 = load i32, i32* %9
%70 = icmp sle i32 %69, 36
br i1 %70, label %71, label %85
71: ; preds = %68
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = load i32, i32* %6
%77 = icmp eq i32 %75, %76
br i1 %77, label %78, label %81
78: ; preds = %71
%79 = load i32, i32* %9
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %78, %71
br label %82
82: ; preds = %81
%83 = load i32, i32* %9
%84 = add nsw i32 %83, 1
store i32 %84, i32* %9
br label %68
85: ; preds = %68
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %32
87: ; preds = %32
%88 = load i32, i32* %3
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %92
92: ; preds = %90, %87
br label %11
93: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [10 x i8] c"Case %d:\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@INT_MAX = global i32 0
@.str.3 = [32 x i8] c"Cheapest base(s) for number %d:\00"
@.str.4 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca [64 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [64 x i32]
%5 = alloca i32
%6 = bitcast [64 x i32]* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast [64 x i32]* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
store i32 %13, i32* %2
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %137
15: ; preds = %0
%16 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 0
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 1
%18 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 2
%19 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 3
%20 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 4
%21 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 5
%22 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 6
%23 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 7
%24 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 8
%25 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 9
%26 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 10
%27 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 11
%28 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 12
%29 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 13
%30 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 14
%31 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 15
%32 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 16
%33 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 17
%34 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 18
%35 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 19
%36 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 20
%37 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 21
%38 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 22
%39 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 23
%40 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 24
%41 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 25
%42 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 26
%43 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 27
%44 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 28
%45 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 29
%46 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 30
%47 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 31
%48 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 32
%49 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 33
%50 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 34
%51 = getelementptr inbounds [64 x i32], [64 x i32]* %1, i64 0, i64 35
br label %52
52: ; preds = %15, %132
%53 = phi i32 [ 0, %15 ], [ %54, %132 ]
%54 = add nuw nsw i32 %53, 1
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%57 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %17)
%58 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %18)
%59 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%60 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %20)
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %21)
%62 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%63 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %23)
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %25)
%66 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %26)
%67 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %27)
%68 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %28)
%69 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %29)
%70 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %30)
%71 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %31)
%72 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %32)
%73 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %33)
%74 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %34)
%75 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %35)
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %36)
%77 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %37)
%78 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %38)
%79 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %39)
%80 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %40)
%81 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %41)
%82 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %42)
%83 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %43)
%84 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %44)
%85 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %45)
%86 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %46)
%87 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %47)
%88 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %48)
%89 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %49)
%90 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %50)
%91 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %51)
%92 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%93 = load i32, i32* %3
%94 = add nsw i32 %93, -1
store i32 %94, i32* %3
%95 = icmp sgt i32 %93, 0
br i1 %95, label %96, label %129
96: ; preds = %52, %124
%97 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %5)
%98 = load i32, i32* @INT_MAX
br label %99
99: ; preds = %96, %99
%100 = phi i64 [ 2, %96 ], [ %108, %99 ]
%101 = phi i32 [ %98, %96 ], [ %107, %99 ]
%102 = load i32, i32* %5
%103 = trunc i64 %100 to i32
%104 = call i32 @calc_print_cost(i32 %102, i32 %103, i32* %16)
%105 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 %100
store i32 %104, i32* %105
%106 = icmp slt i32 %104, %101
%107 = select i1 %106, i32 %104, i32 %101
%108 = add nuw nsw i64 %100, 1
%109 = icmp eq i64 %108, 37
br i1 %109, label %110, label %99
110: ; preds = %99
%111 = load i32, i32* %5
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %110, %121
%114 = phi i64 [ 2, %110 ], [ %122, %121 ]
%115 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 %114
%116 = load i32, i32* %115
%117 = icmp eq i32 %116, %107
br i1 %117, label %118, label %121
118: ; preds = %113
%119 = trunc i64 %114 to i32
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %119)
br label %121
121: ; preds = %113, %118
%122 = add nuw nsw i64 %114, 1
%123 = icmp eq i64 %122, 37
br i1 %123, label %124, label %113
124: ; preds = %121
%125 = call i32 @putchar(i32 10)
%126 = load i32, i32* %3
%127 = add nsw i32 %126, -1
store i32 %127, i32* %3
%128 = icmp sgt i32 %126, 0
br i1 %128, label %96, label %129
129: ; preds = %124, %52
%130 = load i32, i32* %2
%131 = icmp eq i32 %130, 0
br i1 %131, label %137, label %132
132: ; preds = %129
%133 = call i32 @putchar(i32 10)
%134 = load i32, i32* %2
%135 = add nsw i32 %134, -1
store i32 %135, i32* %2
%136 = icmp sgt i32 %134, 0
br i1 %136, label %52, label %137
137: ; preds = %132, %129, %0
ret i32 0
}