#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 */
size_t _index(int, int);
int _pow(int, int);
int *calloc(int, int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ printf(char *, int, char, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int ncolors, niterations;
  scanf("%d %d", &ncolors, &niterations);
  int rules[ncolors][9];
  for (int i = 0; i < ncolors; i++)
    for (int j = 0; j < 9; j++)
      scanf("%d", &rules[i][j]);
  int *canvas = calloc(sizeof(int), _pow(_pow(3, niterations), 2));
  for (int i = 1; i <= niterations; i++) {
    int new[_pow(_pow(3, i), 2)];
    for (int j = 0; j < _pow(_pow(3, i - 1), 2); j++)
      for (int k = 0; k < 9; k++)
        new[j * 9 + k] = rules[canvas[j]][k];
    memcpy(canvas, new, sizeof(int) * _pow(_pow(3, i), 2));
  }
  printf("P2\n%d %d\n%d\n", _pow(3, niterations), _pow(3, niterations),
         ncolors - 1);
  for (int i = 0; i < _pow(_pow(3, niterations), 2); i++)
    printf("%d%c", canvas[_index(i, niterations)],
           i % _pow(3, niterations) == 0 && i > 0 ? '\n' : ' ');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    (%rax,%rax,8),%rcx
lea    0xf(,%rcx,4),%rdx
movabs $0x7ffffffff0,%rcx
and    %rcx,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1229 <main+0xc9>
movl   $0x0,-0x28(%rbp)
cmpl   $0x9,-0x28(%rbp)
jge    1216 <main+0xb6>
mov    -0x60(%rbp),%rsi
movslq -0x24(%rbp),%rax
imul   $0x24,%rax,%rax
add    %rax,%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d6 <main+0x76>
jmp    121b <main+0xbb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c3 <main+0x63>
mov    -0xc(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    %eax,%esi
mov    $0x4,%edi
call   1050 <calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1386 <main+0x226>
mov    -0x34(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x34(%rbp),%esi
sub    $0x1,%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    133b <main+0x1db>
movl   $0x0,-0x50(%rbp)
cmpl   $0x9,-0x50(%rbp)
jge    1328 <main+0x1c8>
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movslq -0x4c(%rbp),%rsi
movslq (%rdx,%rsi,4),%rdx
imul   $0x24,%rdx,%rdx
add    %rdx,%rcx
movslq -0x50(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
imul   $0x9,-0x4c(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12e1 <main+0x181>
jmp    132d <main+0x1cd>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12ab <main+0x14b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x34(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    -0x78(%rbp),%rdi
mov    -0x68(%rbp),%rsi
cltq
shl    $0x2,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1259 <main+0xf9>
mov    -0xc(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,-0x7c(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    -0x7c(%rbp),%esi
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
lea    0xc53(%rip),%rdi
movsbl %al,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
cmp    %ecx,%eax
jge    1493 <main+0x333>
mov    -0x30(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x54(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <_index@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%eax
cltd
idiv   %ecx
xor    %eax,%eax
cmp    $0x0,%edx
mov    %al,-0x81(%rbp)
jne    1458 <main+0x2f8>
cmpl   $0x0,-0x54(%rbp)
setg   %al
mov    %al,-0x81(%rbp)
mov    -0x8c(%rbp),%esi
mov    -0x81(%rbp),%dl
mov    $0x20,%eax
mov    $0xa,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
lea    0xb98(%rip),%rdi
movsbl %al,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13c4 <main+0x264>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe88(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x30(%rbp),%eax
lea    (%rax,%rax,8),%rax
lea    0xf(,%rax,4),%rax
movabs $0x7ffffffff0,%rcx
and    %rax,%rcx
mov    %rsp,%r13
sub    %rcx,%r13
mov    %r13,%rsp
cmpl   $0x0,-0x30(%rbp)
jle    1262 <main+0x102>
lea    0xe42(%rip),%r14
mov    %r13,%rbx
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x4(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x8(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xc(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x10(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x14(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x18(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x1c(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0x20(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%r15
movslq -0x30(%rbp),%rax
add    $0x24,%rbx
cmp    %rax,%r15
jl     11d0 <main+0x70>
mov    -0x2c(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    $0x4,%edi
mov    %eax,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    13a2 <main+0x242>
mov    $0x1,%ebx
jmp    12e3 <main+0x183>
nopl   0x0(%rax)
mov    $0x3,%edi
mov    -0x50(%rbp),%rbx
mov    %ebx,%esi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
lea    0x0(,%rax,4),%edx
mov    %r12,%rdi
mov    -0x38(%rbp),%rsi
call   1060 <memcpy@plt>
mov    -0x48(%rbp),%rsp
lea    0x1(%rbx),%eax
mov    -0x2c(%rbp),%esi
cmp    %esi,%ebx
mov    %eax,%ebx
jge    13a2 <main+0x242>
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
mov    %rsp,-0x48(%rbp)
mov    %eax,%eax
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rbx,-0x50(%rbp)
add    $0xffffffff,%ebx
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
test   %eax,%eax
jle    12a0 <main+0x140>
mov    -0x38(%rbp),%r15
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movslq (%r12,%r14,4),%rax
lea    (%rax,%rax,8),%rax
mov    0x20(%r13,%rax,4),%ecx
mov    %ecx,0x20(%r15)
movups 0x0(%r13,%rax,4),%xmm0
movups 0x10(%r13,%rax,4),%xmm1
movups %xmm1,0x10(%r15)
movups %xmm0,(%r15)
add    $0x1,%r14
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
cltq
add    $0x24,%r15
cmp    %rax,%r14
jl     1350 <main+0x1f0>
jmp    12a0 <main+0x140>
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%ebx
mov    -0x2c(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    -0x30(%rbp),%ecx
add    $0xffffffff,%ecx
movsbl %al,%edx
lea    0xc3b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
test   %eax,%eax
jle    146b <main+0x30b>
lea    0xc1b(%rip),%r14
xor    %ebx,%ebx
jmp    1432 <main+0x2d2>
nopl   0x0(%rax)
test   %ebx,%ebx
cmovne %ecx,%edx
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
mov    -0x2c(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <_pow@plt>
cmp    %eax,%ebx
jge    146b <main+0x30b>
mov    -0x2c(%rbp),%esi
mov    %ebx,%edi
call   1080 <_index@plt>
mov    (%r12,%rax,4),%r15d
mov    -0x2c(%rbp),%esi
mov    $0x3,%edi
call   1030 <_pow@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
mov    $0x20,%edx
test   %eax,%eax
je     1400 <main+0x2a0>
mov    $0x20,%ecx
jmp    1400 <main+0x2a0>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"P2\0A%d %d\0A%d\0A\00"
@.str.3 = [5 x i8] c"%d%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca [9 x i32], i64 %7
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %36
12: ; preds = %0, %12
%13 = phi i64 [ %32, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 0
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 1
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 2
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 3
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 4
%23 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 5
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 6
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 7
%29 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [9 x i32], [9 x i32]* %9, i64 %13, i64 8
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
%32 = add nuw nsw i64 %13, 1
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %12, label %36
36: ; preds = %12, %0
%37 = load i32, i32* %2
%38 = call i32 @_pow(i32 3, i32 %37)
%39 = call i32 @_pow(i32 %38, i32 2)
%40 = call i32* @calloc(i32 4, i32 %39)
%41 = load i32, i32* %2
%42 = icmp slt i32 %41, 1
br i1 %42, label %43, label %56
43: ; preds = %82, %36
%44 = phi i32 [ %41, %36 ], [ %88, %82 ]
%45 = call i32 @_pow(i32 3, i32 %44)
%46 = load i32, i32* %2
%47 = call i32 @_pow(i32 3, i32 %46)
%48 = trunc i32 %47 to i8
%49 = load i32, i32* %1
%50 = add nsw i32 %49, -1
%51 = call i32 (i8*, i32, i8, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %45, i8 signext %48, i32 %50)
%52 = load i32, i32* %2
%53 = call i32 @_pow(i32 3, i32 %52)
%54 = call i32 @_pow(i32 %53, i32 2)
%55 = icmp sgt i32 %54, 0
br i1 %55, label %91, label %90
56: ; preds = %36, %82
%57 = phi i32 [ %87, %82 ], [ 1, %36 ]
%58 = call i32 @_pow(i32 3, i32 %57)
%59 = call i32 @_pow(i32 %58, i32 2)
%60 = zext i32 %59 to i64
%61 = call i8* @llvm.stacksave()
%62 = alloca i32, i64 %60
%63 = add nsw i32 %57, -1
%64 = call i32 @_pow(i32 3, i32 %63)
%65 = call i32 @_pow(i32 %64, i32 2)
%66 = icmp sgt i32 %65, 0
br i1 %66, label %67, label %82
67: ; preds = %56, %67
%68 = phi i64 [ %77, %67 ], [ 0, %56 ]
%69 = mul nuw nsw i64 %68, 9
%70 = getelementptr i32, i32* %62, i64 %69
%71 = bitcast i32* %70 to i8*
%72 = getelementptr inbounds i32, i32* %40, i64 %68
%73 = load i32, i32* %72
%74 = sext i32 %73 to i64
%75 = getelementptr [9 x i32], [9 x i32]* %9, i64 %74, i64 0
%76 = bitcast i32* %75 to i8*
%77 = add nuw nsw i64 %68, 1
%78 = call i32 @_pow(i32 3, i32 %63)
%79 = call i32 @_pow(i32 %78, i32 2)
%80 = sext i32 %79 to i64
%81 = icmp slt i64 %77, %80
br i1 %81, label %67, label %82
82: ; preds = %67, %56
%83 = call i32 @_pow(i32 3, i32 %57)
%84 = call i32 @_pow(i32 %83, i32 2)
%85 = shl i32 %84, 2
%86 = call i32 @memcpy(i32* %40, i32* %62, i32 %85)
%87 = add nuw nsw i32 %57, 1
%88 = load i32, i32* %2
%89 = icmp slt i32 %57, %88
br i1 %89, label %56, label %43
90: ; preds = %91, %43
ret i32 0
91: ; preds = %43, %91
%92 = phi i32 [ %105, %91 ], [ 0, %43 ]
%93 = load i32, i32* %2
%94 = call i64 @_index(i32 %92, i32 %93)
%95 = getelementptr inbounds i32, i32* %40, i64 %94
%96 = load i32, i32* %95
%97 = load i32, i32* %2
%98 = call i32 @_pow(i32 3, i32 %97)
%99 = srem i32 %92, %98
%100 = icmp eq i32 %99, 0
%101 = icmp ne i32 %92, 0
%102 = and i1 %101, %100
%103 = select i1 %102, i8 10, i8 32
%104 = call i32 (i8*, i32, i8, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %96, i8 signext %103)
%105 = add nuw nsw i32 %92, 1
%106 = load i32, i32* %2
%107 = call i32 @_pow(i32 3, i32 %106)
%108 = call i32 @_pow(i32 %107, i32 2)
%109 = icmp slt i32 %105, %108
br i1 %109, label %91, label %90
}