#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 check(int, char **, char **, int);
int reflection(int, char **, char **);
int rotate(int, char **, char **, int);
int convert(int length, char before[length][length + 1],
            char after[length][length + 1]) {
  if (rotate(length, before, after, 1) == 1)
    return 1;
  if (rotate(length, before, after, 2) == 2)
    return 2;
  if (rotate(length, before, after, 3) == 3)
    return 3;
  if (reflection(length, before, after) == 4) {
    return 4;
  } else if (reflection(length, before, after) == 5) {
    return 5;
  }
  if (check(length, before, after, 6) == 6) {
    return 6;
  } else {
    return 7;
  }
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%ecx
call   1030 <rotate@plt>
cmp    $0x1,%eax
jne    116d <convert+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    1241 <convert+0x111>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x2,%ecx
call   1030 <rotate@plt>
cmp    $0x2,%eax
jne    1197 <convert+0x67>
movl   $0x2,-0x4(%rbp)
jmp    1241 <convert+0x111>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x3,%ecx
call   1030 <rotate@plt>
cmp    $0x3,%eax
jne    11c1 <convert+0x91>
movl   $0x3,-0x4(%rbp)
jmp    1241 <convert+0x111>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <reflection@plt>
cmp    $0x4,%eax
jne    11e6 <convert+0xb6>
movl   $0x4,-0x4(%rbp)
jmp    1241 <convert+0x111>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <reflection@plt>
cmp    $0x5,%eax
jne    120b <convert+0xdb>
movl   $0x5,-0x4(%rbp)
jmp    1241 <convert+0x111>
jmp    1210 <convert+0xe0>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x6,%ecx
call   1040 <check@plt>
cmp    $0x6,%eax
jne    123a <convert+0x10a>
movl   $0x6,-0x4(%rbp)
jmp    1241 <convert+0x111>
movl   $0x7,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
mov    $0x1,%ebx
mov    $0x1,%ecx
call   1030 <rotate@plt>
cmp    $0x1,%eax
je     11da <convert+0xaa>
mov    $0x2,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x2,%ecx
call   1030 <rotate@plt>
cmp    $0x2,%eax
je     11da <convert+0xaa>
mov    $0x3,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x3,%ecx
call   1030 <rotate@plt>
cmp    $0x3,%eax
je     11da <convert+0xaa>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <reflection@plt>
mov    $0x4,%ebx
cmp    $0x4,%eax
je     11da <convert+0xaa>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <reflection@plt>
mov    $0x5,%ebx
cmp    $0x5,%eax
je     11da <convert+0xaa>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x6,%ecx
call   1040 <check@plt>
xor    %ebx,%ebx
cmp    $0x6,%eax
sete   %bl
xor    $0x7,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @convert(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i32, i32* %5
%9 = zext i32 %8 to i64
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = load i32, i32* %5
%19 = load i8*, i8** %6
%20 = bitcast i8* %19 to i8**
%21 = load i8*, i8** %7
%22 = bitcast i8* %21 to i8**
%23 = call i32 @rotate(i32 %18, i8** %20, i8** %22, i32 1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %26
25: ; preds = %3
store i32 1, i32* %4
br label %73
26: ; preds = %3
%27 = load i32, i32* %5
%28 = load i8*, i8** %6
%29 = bitcast i8* %28 to i8**
%30 = load i8*, i8** %7
%31 = bitcast i8* %30 to i8**
%32 = call i32 @rotate(i32 %27, i8** %29, i8** %31, i32 2)
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %35
34: ; preds = %26
store i32 2, i32* %4
br label %73
35: ; preds = %26
%36 = load i32, i32* %5
%37 = load i8*, i8** %6
%38 = bitcast i8* %37 to i8**
%39 = load i8*, i8** %7
%40 = bitcast i8* %39 to i8**
%41 = call i32 @rotate(i32 %36, i8** %38, i8** %40, i32 3)
%42 = icmp eq i32 %41, 3
br i1 %42, label %43, label %44
43: ; preds = %35
store i32 3, i32* %4
br label %73
44: ; preds = %35
%45 = load i32, i32* %5
%46 = load i8*, i8** %6
%47 = bitcast i8* %46 to i8**
%48 = load i8*, i8** %7
%49 = bitcast i8* %48 to i8**
%50 = call i32 @reflection(i32 %45, i8** %47, i8** %49)
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %53
52: ; preds = %44
store i32 4, i32* %4
br label %73
53: ; preds = %44
%54 = load i32, i32* %5
%55 = load i8*, i8** %6
%56 = bitcast i8* %55 to i8**
%57 = load i8*, i8** %7
%58 = bitcast i8* %57 to i8**
%59 = call i32 @reflection(i32 %54, i8** %56, i8** %58)
%60 = icmp eq i32 %59, 5
br i1 %60, label %61, label %62
61: ; preds = %53
store i32 5, i32* %4
br label %73
62: ; preds = %53
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = load i8*, i8** %6
%66 = bitcast i8* %65 to i8**
%67 = load i8*, i8** %7
%68 = bitcast i8* %67 to i8**
%69 = call i32 @check(i32 %64, i8** %66, i8** %68, i32 6)
%70 = icmp eq i32 %69, 6
br i1 %70, label %71, label %72
71: ; preds = %63
store i32 6, i32* %4
br label %73
72: ; preds = %63
store i32 7, i32* %4
br label %73
73: ; preds = %72, %71, %61, %52, %43, %34, %25
%74 = load i32, i32* %4
ret i32 %74
}

LLVM IR (-O2):
define i32 @convert(i32 %0, i8* %1, i8* %2) {
%4 = bitcast i8* %1 to i8**
%5 = bitcast i8* %2 to i8**
%6 = tail call i32 @rotate(i32 %0, i8** %4, i8** %5, i32 1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %24, label %8
8: ; preds = %3
%9 = tail call i32 @rotate(i32 %0, i8** %4, i8** %5, i32 2)
%10 = icmp eq i32 %9, 2
br i1 %10, label %24, label %11
11: ; preds = %8
%12 = tail call i32 @rotate(i32 %0, i8** %4, i8** %5, i32 3)
%13 = icmp eq i32 %12, 3
br i1 %13, label %24, label %14
14: ; preds = %11
%15 = tail call i32 @reflection(i32 %0, i8** %4, i8** %5)
%16 = icmp eq i32 %15, 4
br i1 %16, label %24, label %17
17: ; preds = %14
%18 = tail call i32 @reflection(i32 %0, i8** %4, i8** %5)
%19 = icmp eq i32 %18, 5
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call i32 @check(i32 %0, i8** %4, i8** %5, i32 6)
%22 = icmp eq i32 %21, 6
%23 = select i1 %22, i32 6, i32 7
br label %24
24: ; preds = %20, %17, %14, %11, %8, %3
%25 = phi i32 [ 1, %3 ], [ 2, %8 ], [ 3, %11 ], [ 4, %14 ], [ 5, %17 ], [ %23, %20 ]
ret i32 %25
}