#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*/ nodes6;
typedef int /*<<< orphan*/ nodes5;
typedef int /*<<< orphan*/ nodes4;
typedef int /*<<< orphan*/ nodes3;
typedef int /*<<< orphan*/ nodes2;
typedef int /*<<< orphan*/ nodes1;

/* Variables and functions */
int /*<<< orphan*/ perft_test(char *, unsigned long long *, int);
void perft_tests() {
  char *fen1 = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
  unsigned long long nodes1[] = {
      1L, 20L, 400L, 8902L, 197281L, 4865609L, 119060324L,
  };
  char *fen2 =
      "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -";
  unsigned long long nodes2[] = {
      1L, 48L, 2039L, 97862L, 4085603L, 193690690L,
  };
  char *fen3 = "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -";
  unsigned long long nodes3[] = {
      1L, 14L, 191L, 2812L, 43238L, 674624L, 11030083L, 178633661L,
  };
  char *fen4 =
      "r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1";
  unsigned long long nodes4[] = {
      1L, 6L, 264L, 9467L, 422333L, 15833292L, 706045033L,
  };
  char *fen5 = "rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6";
  unsigned long long nodes5[] = {
      1L,
      42L,
      1352L,
      53392L,
  };
  char *fen6 = "r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 "
               "w - - 0 10";
  unsigned long long nodes6[] = {
      1L,         46L,         2079L,         89890L,          3894594L,
      164075551L, 6923051137L, 287188994746L, 11923589843526L, 490154852788714L,
  };
  perft_test(fen1, nodes1, sizeof(nodes1) / sizeof(unsigned long long));
  perft_test(fen2, nodes2, sizeof(nodes2) / sizeof(unsigned long long));
  perft_test(fen3, nodes3, sizeof(nodes3) / sizeof(unsigned long long));
  perft_test(fen4, nodes4, sizeof(nodes4) / sizeof(unsigned long long));
  perft_test(fen5, nodes5, sizeof(nodes5) / sizeof(unsigned long long));
  perft_test(fen6, nodes6, sizeof(nodes6) / sizeof(unsigned long long));
}


x86 assembly (clang, -O0):
<perft_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0x101f(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    0xed7(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movq   $0x1,-0x80(%rbp)
movq   $0x30,-0x78(%rbp)
movq   $0x7f7,-0x70(%rbp)
movq   $0x17e46,-0x68(%rbp)
movq   $0x3e5763,-0x60(%rbp)
movq   $0xb8b7c42,-0x58(%rbp)
0b
lea    0xecd(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0xfee(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    0xecd(%rip),%rax
mov    %rax,-0xd8(%rbp)
lea    -0x110(%rbp),%rdi
lea    0x1008(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    0xee8(%rip),%rax
mov    %rax,-0x118(%rbp)
mov    0x1079(%rip),%rax
mov    %rax,-0x140(%rbp)
mov    0x1073(%rip),%rax
mov    %rax,-0x138(%rbp)
mov    0x106d(%rip),%rax
mov    %rax,-0x130(%rbp)
mov    0x1067(%rip),%rax
mov    %rax,-0x128(%rbp)
lea    0xee0(%rip),%rax
mov    %rax,-0x148(%rbp)
lea    -0x1a0(%rbp),%rdi
lea    0xfdc(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x7,%edx
call   1050 <perft_test@plt>
mov    -0x48(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x6,%edx
call   1050 <perft_test@plt>
mov    -0x88(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
mov    $0x8,%edx
call   1050 <perft_test@plt>
mov    -0xd8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x7,%edx
call   1050 <perft_test@plt>
mov    -0x118(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    $0x4,%edx
call   1050 <perft_test@plt>
mov    -0x148(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
mov    $0xa,%edx
call   1050 <perft_test@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perft_tests>:
sub    $0x168,%rsp
mov    0x10b2(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0x1093(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0x1074(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0x1058(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0x108f(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0x1070(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0x1051(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0x1032(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
mov    0x1093(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0x1077(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x105b(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x103f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x10d3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x10b7(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0x109c(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
movaps 0x107d(%rip),%xmm0
movaps %xmm0,0x140(%rsp)
movaps 0x105e(%rip),%xmm0
movaps %xmm0,0x130(%rsp)
movaps 0x103f(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0x1020(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
lea    0xde1(%rip),%rdi
lea    0x60(%rsp),%rsi
mov    $0x7,%edx
call   1030 <perft_test@plt>
lea    0xe04(%rip),%rdi
lea    0xa0(%rsp),%rsi
mov    $0x6,%edx
call   1030 <perft_test@plt>
lea    0xe2c(%rip),%rdi
lea    0xd0(%rsp),%rsi
mov    $0x8,%edx
call   1030 <perft_test@plt>
lea    0xe39(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    $0x7,%edx
call   1030 <perft_test@plt>
lea    0xe64(%rip),%rdi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1030 <perft_test@plt>
lea    0xe8e(%rip),%rdi
lea    0x110(%rsp),%rsi
mov    $0xa,%edx
call   1030 <perft_test@plt>
add    $0x168,%rsp
ret

LLVM IR (-O0):
@.str = [57 x i8] c"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1\00"
@__const.perft_tests.nodes1 = [7 x i64] [i64 1, i64 20, i64 400, i64 8902, i64 197281, i64 4865609, i64 119060324]
@.str.1 = [65 x i8] c"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -\00"
@.str.2 = [38 x i8] c"8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -\00"
@__const.perft_tests.nodes3 = [8 x i64] [i64 1, i64 14, i64 191, i64 2812, i64 43238, i64 674624, i64 11030083, i64 178633661]
@.str.3 = [65 x i8] c"r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1\00"
@__const.perft_tests.nodes4 = [7 x i64] [i64 1, i64 6, i64 264, i64 9467, i64 422333, i64 15833292, i64 706045033]
@.str.4 = [62 x i8] c"rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6\00"
@__const.perft_tests.nodes5 = [4 x i64] [i64 1, i64 42, i64 1352, i64 53392]
@.str.5 = [73 x i8] c"r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10\00"
@__const.perft_tests.nodes6 = [10 x i64] [i64 1, i64 46, i64 2079, i64 89890, i64 3894594, i64 164075551, i64 6923051137, i64 287188994746, i64 11923589843526, i64 490154852788714]
define void @perft_tests() {
%1 = alloca i8*
%2 = alloca [7 x i64]
%3 = alloca i8*
%4 = alloca [6 x i64]
%5 = alloca i8*
%6 = alloca [8 x i64]
%7 = alloca i8*
%8 = alloca [7 x i64]
%9 = alloca i8*
%10 = alloca [4 x i64]
%11 = alloca i8*
%12 = alloca [10 x i64]
store i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8** %1
%13 = bitcast [7 x i64]* %2 to i8*
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8** %3
%14 = bitcast [6 x i64]* %4 to i8*
%15 = bitcast i8* %14 to [6 x i64]*
%16 = getelementptr inbounds [6 x i64], [6 x i64]* %15, i32 0, i32 0
store i64 1, i64* %16
%17 = getelementptr inbounds [6 x i64], [6 x i64]* %15, i32 0, i32 1
store i64 48, i64* %17
%18 = getelementptr inbounds [6 x i64], [6 x i64]* %15, i32 0, i32 2
store i64 2039, i64* %18
%19 = getelementptr inbounds [6 x i64], [6 x i64]* %15, i32 0, i32 3
store i64 97862, i64* %19
%20 = getelementptr inbounds [6 x i64], [6 x i64]* %15, i32 0, i32 4
store i64 4085603, i64* %20
%21 = getelementptr inbounds [6 x i64], [6 x i64]* %15, i32 0, i32 5
store i64 193690690, i64* %21
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8** %5
%22 = bitcast [8 x i64]* %6 to i8*
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i8** %7
%23 = bitcast [7 x i64]* %8 to i8*
store i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i8** %9
%24 = bitcast [4 x i64]* %10 to i8*
store i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0), i8** %11
%25 = bitcast [10 x i64]* %12 to i8*
%26 = load i8*, i8** %1
%27 = getelementptr inbounds [7 x i64], [7 x i64]* %2, i64 0, i64 0
%28 = call i32 @perft_test(i8* %26, i64* %27, i32 7)
%29 = load i8*, i8** %3
%30 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 0
%31 = call i32 @perft_test(i8* %29, i64* %30, i32 6)
%32 = load i8*, i8** %5
%33 = getelementptr inbounds [8 x i64], [8 x i64]* %6, i64 0, i64 0
%34 = call i32 @perft_test(i8* %32, i64* %33, i32 8)
%35 = load i8*, i8** %7
%36 = getelementptr inbounds [7 x i64], [7 x i64]* %8, i64 0, i64 0
%37 = call i32 @perft_test(i8* %35, i64* %36, i32 7)
%38 = load i8*, i8** %9
%39 = getelementptr inbounds [4 x i64], [4 x i64]* %10, i64 0, i64 0
%40 = call i32 @perft_test(i8* %38, i64* %39, i32 4)
%41 = load i8*, i8** %11
%42 = getelementptr inbounds [10 x i64], [10 x i64]* %12, i64 0, i64 0
%43 = call i32 @perft_test(i8* %41, i64* %42, i32 10)
ret void
}

LLVM IR (-O2):
@.str = [57 x i8] c"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1\00"
@__const.perft_tests.nodes1 = [7 x i64] [i64 1, i64 20, i64 400, i64 8902, i64 197281, i64 4865609, i64 119060324]
@.str.1 = [65 x i8] c"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -\00"
@.str.2 = [38 x i8] c"8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -\00"
@__const.perft_tests.nodes3 = [8 x i64] [i64 1, i64 14, i64 191, i64 2812, i64 43238, i64 674624, i64 11030083, i64 178633661]
@.str.3 = [65 x i8] c"r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1\00"
@__const.perft_tests.nodes4 = [7 x i64] [i64 1, i64 6, i64 264, i64 9467, i64 422333, i64 15833292, i64 706045033]
@.str.4 = [62 x i8] c"rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6\00"
@__const.perft_tests.nodes5 = [4 x i64] [i64 1, i64 42, i64 1352, i64 53392]
@.str.5 = [73 x i8] c"r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10\00"
@__const.perft_tests.nodes6 = [10 x i64] [i64 1, i64 46, i64 2079, i64 89890, i64 3894594, i64 164075551, i64 6923051137, i64 287188994746, i64 11923589843526, i64 490154852788714]
define void @perft_tests() {
%1 = alloca [7 x i64]
%2 = alloca [6 x i64]
%3 = alloca [8 x i64]
%4 = alloca [7 x i64]
%5 = alloca [4 x i64]
%6 = alloca [10 x i64]
%7 = bitcast [7 x i64]* %1 to i8*
%8 = bitcast [6 x i64]* %2 to i8*
%9 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 0
%10 = bitcast [6 x i64]* %2 to <2 x i64>*
store <2 x i64> <i64 1, i64 48>, <2 x i64>* %10
%11 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 2
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 2039, i64 97862>, <2 x i64>* %12
%13 = getelementptr inbounds [6 x i64], [6 x i64]* %2, i64 0, i64 4
%14 = bitcast i64* %13 to <2 x i64>*
store <2 x i64> <i64 4085603, i64 193690690>, <2 x i64>* %14
%15 = bitcast [8 x i64]* %3 to i8*
%16 = bitcast [7 x i64]* %4 to i8*
%17 = bitcast [4 x i64]* %5 to i8*
%18 = bitcast [10 x i64]* %6 to i8*
%19 = getelementptr inbounds [7 x i64], [7 x i64]* %1, i64 0, i64 0
%20 = call i32 @perft_test(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64* %19, i32 7)
%21 = call i32 @perft_test(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i64* %9, i32 6)
%22 = getelementptr inbounds [8 x i64], [8 x i64]* %3, i64 0, i64 0
%23 = call i32 @perft_test(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i64* %22, i32 8)
%24 = getelementptr inbounds [7 x i64], [7 x i64]* %4, i64 0, i64 0
%25 = call i32 @perft_test(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i64* %24, i32 7)
%26 = getelementptr inbounds [4 x i64], [4 x i64]* %5, i64 0, i64 0
%27 = call i32 @perft_test(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i64* %26, i32 4)
%28 = getelementptr inbounds [10 x i64], [10 x i64]* %6, i64 0, i64 0
%29 = call i32 @perft_test(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0), i64* %28, i32 10)
ret void
}