#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*/ FILE;

/* Variables and functions */
int convert(int, char **, char **);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int main() {
  FILE *fin = fopen("transform.in", "r");
  FILE *fout = fopen("transform.out", "w");
  int n;
  fscanf(fin, "%d ", &n);
  char before[n + 1][n + 1];
  for (int i = 0; i < n; i++) {
    fscanf(fin, "%s ", before[i]);
  }
  char after[n + 1][n + 1];
  for (int i = 0; i < n; i++) {
    fscanf(fin, "%s ", after[i]);
  }
  int result = convert(n, before, after);
  fprintf(fout, "%d\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xead(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
xor    %eax,%eax
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rax,-0x68(%rbp)
mov    %rax,%rcx
mov    %rsp,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rax,%rsi
imul   %rsi,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x60(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1214 <main+0xd4>
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x10(%rbp),%rdi
movslq -0x3c(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d5 <main+0x95>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rax,-0x78(%rbp)
mov    %rax,%rcx
mov    %rax,%rsi
imul   %rsi,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x70(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x48(%rbp)
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    128b <main+0x14b>
mov    -0x70(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    -0x10(%rbp),%rdi
movslq -0x54(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rdx
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    124c <main+0x10c>
mov    -0x70(%rbp),%rdx
mov    -0x60(%rbp),%rsi
mov    -0x1c(%rbp),%edi
call   1030 <convert@plt>
mov    %eax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x58(%rbp),%edx
lea    0xd7b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%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    0xea8(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xea1(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xe9b(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %rsp,%rbx
mov    -0x2c(%rbp),%r13d
add    $0x1,%r13d
mov    %r13,%rax
imul   %r13,%rax
mov    %rsp,%rsi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rsi
mov    %rsi,%rsp
mov    -0x2c(%rbp),%edi
test   %edi,%edi
jle    1272 <main+0x132>
mov    %rbx,-0x40(%rbp)
mov    %r15,-0x48(%rbp)
lea    0xe54(%rip),%r12
mov    %rsi,-0x38(%rbp)
mov    %rsi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rdi
add    %r13,%r15
cmp    %rdi,%rbx
jl     11e0 <main+0xa0>
lea    0x1(%rdi),%r15d
mov    %r15,%rax
imul   %r15,%rax
mov    %rsp,%rdx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
test   %edi,%edi
jle    128c <main+0x14c>
lea    0xdfc(%rip),%r13
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rbx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rdi
add    %r15,%rbx
cmp    %rdi,%r12
jl     1240 <main+0x100>
mov    -0x48(%rbp),%r15
mov    -0x40(%rbp),%rbx
mov    -0x38(%rbp),%rsi
mov    -0x50(%rbp),%rdx
jmp    1298 <main+0x158>
lea    0x1(%rdi),%eax
imul   %rax,%rax
mov    %rsp,%rdx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
jmp    1298 <main+0x158>
mov    -0x48(%rbp),%r15
mov    -0x40(%rbp),%rbx
mov    -0x38(%rbp),%rsi
call   1030 <convert@plt>
lea    0xd83(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    %rbx,%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 = [13 x i8] c"transform.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"transform.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [4 x i8] c"%s \00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
%13 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %2
%14 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %14, i32** %3
%15 = load i32*, i32** %2
%16 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
%19 = zext i32 %18 to i64
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %5
%24 = mul nuw i64 %19, %22
%25 = alloca i8, i64 %24
store i64 %19, i64* %6
store i64 %22, i64* %7
store i32 0, i32* %8
br label %26
26: ; preds = %37, %0
%27 = load i32, i32* %8
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i32*, i32** %2
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = mul nsw i64 %33, %22
%35 = getelementptr inbounds i8, i8* %25, i64 %34
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %26
40: ; preds = %26
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
%43 = zext i32 %42 to i64
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
%46 = zext i32 %45 to i64
%47 = mul nuw i64 %43, %46
%48 = alloca i8, i64 %47
store i64 %43, i64* %9
store i64 %46, i64* %10
store i32 0, i32* %11
br label %49
49: ; preds = %60, %40
%50 = load i32, i32* %11
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i32*, i32** %2
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = mul nsw i64 %56, %46
%58 = getelementptr inbounds i8, i8* %48, i64 %57
%59 = call i32 (i32*, i8*, ...) @fscanf(i32* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %53
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
store i32 %62, i32* %11
br label %49
63: ; preds = %49
%64 = load i32, i32* %4
%65 = bitcast i8* %25 to i8**
%66 = bitcast i8* %48 to i8**
%67 = call i32 @convert(i32 %64, i8** %65, i8** %66)
store i32 %67, i32* %12
%68 = load i32*, i32** %3
%69 = load i32, i32* %12
%70 = call i32 @fprintf(i32* %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %69)
store i32 0, i32* %1
%71 = load i8*, i8** %5
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str = [13 x i8] c"transform.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"transform.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [4 x i8] c"%s \00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, 1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = mul nuw i64 %8, %8
%11 = alloca i8, i64 %10
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %0
%15 = add nsw i32 %12, 1
%16 = zext i32 %15 to i64
%17 = mul nuw i64 %16, %16
%18 = alloca i8, i64 %17
br label %34
19: ; preds = %25
%20 = add nsw i32 %31, 1
%21 = zext i32 %20 to i64
%22 = mul nuw i64 %21, %21
%23 = alloca i8, i64 %22
%24 = icmp sgt i32 %31, 0
br i1 %24, label %41, label %34
25: ; preds = %0, %25
%26 = phi i64 [ %30, %25 ], [ 0, %0 ]
%27 = mul nuw nsw i64 %26, %8
%28 = getelementptr inbounds i8, i8* %11, i64 %27
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = add nuw nsw i64 %26, 1
%31 = load i32, i32* %1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %25, label %19
34: ; preds = %41, %14, %19
%35 = phi i8* [ %23, %19 ], [ %18, %14 ], [ %23, %41 ]
%36 = phi i32 [ %31, %19 ], [ %12, %14 ], [ %47, %41 ]
%37 = bitcast i8* %11 to i8**
%38 = bitcast i8* %35 to i8**
%39 = call i32 @convert(i32 %36, i8** %37, i8** %38)
%40 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %39)
ret i32 0
41: ; preds = %19, %41
%42 = phi i64 [ %46, %41 ], [ 0, %19 ]
%43 = mul nuw nsw i64 %42, %21
%44 = getelementptr inbounds i8, i8* %23, i64 %43
%45 = call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = add nuw nsw i64 %42, 1
%47 = load i32, i32* %1
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %41, label %34
}