#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 */
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ filename;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ draw(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, char);
int /*<<< orphan*/ stdin;
int main() {
  int n;
  scanf("%d\n", &n);
  for (int i = 0; i < n * n; i++) {
    char line[6];
    fgets(line, sizeof(line), stdin);
    char filename[32];
    snprintf(filename, sizeof(filename), "tile-%c.svg", 'A' + i);
    FILE *out = fopen(filename, "w");
    draw(line, out);
    fclose(out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1205 <main+0xa5>
lea    -0x12(%rbp),%rdi
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%esi
call   1060 <fgets@plt>
lea    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0x41,%eax
mov    $0x20,%esi
lea    0xe3f(%rip),%rdx
movsbl %al,%ecx
call   1050 <snprintf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x48(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1030 <draw@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1186 <main+0x26>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe8b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
imul   %eax,%eax
test   %eax,%eax
je     120b <main+0xab>
xor    %ebp,%ebp
lea    0xa(%rsp),%r15
lea    0xe68(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xe68(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    $0x6,%esi
call   1060 <fgets@plt>
lea    0x41(%rbp),%eax
movsbl %al,%ecx
mov    %r13,%rdi
mov    $0x20,%esi
mov    %r14,%rdx
call   1050 <snprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <draw@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
imul   %eax,%eax
cmp    %eax,%ebp
jb     11b0 <main+0x50>
xor    %eax,%eax
add    $0x38,%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"
@stdin = global i32 0
@.str.1 = [12 x i8] c"tile-%c.svg\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
%5 = alloca [32 x i8]
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %30, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = mul nsw i32 %10, %11
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %33
14: ; preds = %8
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 6, i32 %16)
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%19 = load i32, i32* %3
%20 = add nsw i32 65, %19
%21 = trunc i32 %20 to i8
%22 = call i32 @snprintf(i8* %18, i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8 signext %21)
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %24, i32** %6
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%26 = load i32*, i32** %6
%27 = call i32 @draw(i8* %25, i32* %26)
%28 = load i32*, i32** %6
%29 = call i32 @fclose(i32* %28)
br label %30
30: ; preds = %14
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %8
33: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@stdin = global i32 0
@.str.1 = [12 x i8] c"tile-%c.svg\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [32 x i8]
%4 = bitcast i32* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = mul nsw i32 %6, %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %13
12: ; preds = %13, %0
ret i32 0
13: ; preds = %9, %13
%14 = phi i32 [ 0, %9 ], [ %23, %13 ]
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %10, i32 6, i32 %15)
%17 = trunc i32 %14 to i8
%18 = add i8 %17, 65
%19 = call i32 @snprintf(i8* %11, i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
%20 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @draw(i8* %10, i32* %20)
%22 = call i32 @fclose(i32* %20)
%23 = add nuw nsw i32 %14, 1
%24 = load i32, i32* %1
%25 = mul nsw i32 %24, %24
%26 = icmp ult i32 %23, %25
br i1 %26, label %13, label %12
}