LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/ewnAi.cpp
// Function: EwnAI::EwnAI()
EwnAI::EwnAI()
{
    int cmd;
    cout << "Please choose an AI:" << endl;
    cout << "0)Minimax evaluating with feature" << endl;
    cout << "1)Minimax evaluating with simulation 1" << endl;
    cout << "2)Minimax evaluating with simulation 2" << endl;
    cout << "3)Minimax evaluating with simulation 3" << endl;
    cout << "4)Minimax evaluating with simulation 4" << endl;
    cout << "5)MCTS" << endl;
    cout << "6)Random" << endl;
    cout << "Choose: ";
    cin >> cmd;
    if (cmd >= 0 && cmd <=6) this->ai_mode = cmd;
    else this->ai_mode = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r13
leaq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq 0x5508
leaq 0x88(%r13), %r14
movq %r14, %rdi
movq %rbx, -0x40(%rbp)
callq 0x3f64
leaq 0x108(%r13), %r15
movq %r15, %rdi
movq %r14, -0x38(%rbp)
callq 0x3f92
leaq 0x188(%r13), %r12
movq %r12, %rdi
callq 0x3fc0
leaq 0x208(%r13), %rbx
movq %rbx, %rdi
callq 0x3fee
leaq 0x288(%r13), %r14
movq %r14, %rdi
callq 0x4a44
leaq 0x298(%r13), %rdi
callq 0x4954
movq 0x831e(%rip), %rdi      # 0xbfc8
leaq 0x4a0f(%rip), %rsi      # 0x86c0
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x8303(%rip), %rdi      # 0xbfc8
leaq 0x467f(%rip), %rsi      # 0x834b
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x82e8(%rip), %rdi      # 0xbfc8
leaq 0x4686(%rip), %rsi      # 0x836d
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x82cd(%rip), %rdi      # 0xbfc8
leaq 0x4692(%rip), %rsi      # 0x8394
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x82b2(%rip), %rdi      # 0xbfc8
leaq 0x469e(%rip), %rsi      # 0x83bb
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x8297(%rip), %rdi      # 0xbfc8
leaq 0x46aa(%rip), %rsi      # 0x83e2
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x827c(%rip), %rdi      # 0xbfc8
leaq 0x46b6(%rip), %rsi      # 0x8409
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x8261(%rip), %rdi      # 0xbfc8
leaq 0x46a2(%rip), %rsi      # 0x8410
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq 0x8246(%rip), %rdi      # 0xbfc8
leaq 0x4318(%rip), %rsi      # 0x80a1
callq 0x2150
movq 0x8243(%rip), %rdi      # 0xbfd8
leaq -0x2c(%rbp), %rsi
callq 0x20b0
movl -0x2c(%rbp), %eax
xorl %ecx, %ecx
cmpl $0x7, %eax
cmovbl %eax, %ecx
movl %ecx, (%r13)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3dd7
movq %rax, %r13
jmp 0x3de2
movq %rax, %r13
jmp 0x3dea
movq %rax, %r13
jmp 0x3df2
movq %rax, %r13
jmp 0x3dfa
movq %rax, %r13
jmp 0x3e03
movq %rax, %r13
movq %r14, %rdi
callq 0x4a88
movq %rbx, %rdi
callq 0x3b96
movq %r12, %rdi
callq 0x3b96
movq %r15, %rdi
callq 0x3b96
movq -0x38(%rbp), %rdi
callq 0x3b96
movq -0x40(%rbp), %rdi
callq 0x3b96
movq %r13, %rdi
callq 0x2220
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/ewnAi.cpp
// Function: EwnAI::AI_move(Game, int)
Movement EwnAI::AI_move(Game cur_game, int dice)
{
    switch (this->ai_mode) {
        case 0:
            return this->minimax.AI_move(cur_game, dice);
        case 1:
            return this->minimax1.AI_move(cur_game, dice);
        case 2:
            return this->minimax2.AI_move(cur_game, dice);
        case 3:
            return this->minimax3.AI_move(cur_game, dice);
        case 4:
            return this->minimax4.AI_move(cur_game, dice);
        case 5:
            return this->mcts.AI_move(cur_game, dice);
        case 6:
            return this->randomAi.AI_move(cur_game, dice);
        default:
            return this->minimax.AI_move(cur_game, dice);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl (%rdi), %eax
cmpq $0x6, %rax
ja 0x3f1c
leaq 0x4791(%rip), %rcx      # 0x86a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x8, %rdi
jmp 0x3f44
addq $0x208, %rdi            # imm = 0x208
jmp 0x3f44
addq $0x108, %rdi            # imm = 0x108
jmp 0x3f44
addq $0x188, %rdi            # imm = 0x188
jmp 0x3f44
addq $0x88, %rdi
popq %rbp
jmp 0x5618
addq $0x288, %rdi            # imm = 0x288
popq %rbp
jmp 0x4aa0
addq $0x298, %rdi            # imm = 0x298
popq %rbp
jmp 0x495a
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/randomAi.cpp
// Function: RandomAi::AI_move(Game&, int)
Movement RandomAi::AI_move(Game& cur_game, int dice)
{
    //cerr << "calculating..." ;
    //cerr.flush();
    // cout << "read to random" << endl;
    clock_t init_time = clock();
    this->ai_side = cur_game.get_is_switch();
    this->ai_symbol = this->ai_side? 'A': '1';

    Movement available_mvmt_list[6]; // random
    int available_mvmt_cnt = 0;

    int best_val = -1e9, child_val;
    int win = this->ai_side? 2: 1;
    int next_move_cnt = cur_game.count_movable_chs(dice);
    for (int i=0; i<next_move_cnt; i++) {
        int chs_index = cur_game.get_movable_chs(i).symbol - this->ai_symbol;
        for (int direct = 0; direct < 3; direct++) {
            Movement mvmt(chs_index, direct);
            if (cur_game.check_in_board(mvmt)) {
                available_mvmt_list[available_mvmt_cnt] = mvmt;
                available_mvmt_cnt ++;
            }
        }
    }

    // randomly pick a move.
    Movement next_mvmt = available_mvmt_list[rand() % available_mvmt_cnt];

    double timeCost = (double)(clock() - init_time) / CLOCKS_PER_SEC;

    return next_mvmt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x44(%rbp), %r15
movl %edx, (%r15)
callq 0x20c0
movq %rbx, %rdi
callq 0x6d72
movb %al, (%r14)
shlb $0x4, %al
addb $0x31, %al
movq %r14, -0x40(%rbp)
movb %al, 0x1(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x67b0
movl %eax, -0x30(%rbp)
xorl %eax, %eax
leaq -0x38(%rbp), %r13
xorl %r12d, %r12d
movl %eax, -0x2c(%rbp)
cmpl -0x30(%rbp), %eax
jge 0x4a19
movq %rbx, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x6d0e
movsbl %al, %r14d
movq -0x40(%rbp), %rax
movsbl 0x1(%rax), %eax
subl %eax, %r14d
xorl %r15d, %r15d
cmpl $0x3, %r15d
je 0x4a12
movl %r14d, -0x38(%rbp)
movl %r15d, -0x34(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x68b6
testb %al, %al
je 0x4a0d
movslq %r12d, %r12
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp,%r12,8)
incl %r12d
incl %r15d
jmp 0x49e1
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x49bb
callq 0x2050
cltd
idivl %r12d
movslq %edx, %rax
movq -0x80(%rbp,%rax,8), %rbx
callq 0x20c0
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/mcts.cpp
// Function: MCTS::AI_move(Game&, int)
Movement MCTS::AI_move(Game& cur_game, int dice) {
	this->max_iterations = 1000;
	this->ai_side = cur_game.get_is_switch();
	this->ai_symbol = this->ai_side? 'A': '1';

	int best_val = -1e9, child_val;
	int win = this->ai_side? 2: 1;
	int next_move_cnt = cur_game.count_movable_chs(dice);
	Movement answer;
	for (int i=0; i<next_move_cnt; i++) {
		int chs_index = cur_game.get_movable_chs(i).symbol - this->ai_symbol;
		for (int direct = 0; direct < 3; direct++) {
			Movement mvmt(chs_index, direct);
			if (cur_game.check_in_board(mvmt)) {
				Game child_game = cur_game;
				int game_status = child_game.update_game_status(mvmt);
				child_game.switch_player();

				// check if the game ends
				if (game_status == win) {
					answer = mvmt;
					break;
				}
				else if (game_status != 0)	// lose the game
					continue;
				else {
					child_val = this->run(child_game);
				}

				// update the best value and the best movement
				if (child_val >= best_val) {
					best_val = child_val;
					answer = mvmt;
				}
			}
		}
	}
	return answer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r12
movq %rdi, %r14
leaq -0x5c(%rbp), %r15
movl %edx, (%r15)
movl $0x3e8, 0x4(%rdi)       # imm = 0x3E8
movq %rsi, %rdi
callq 0x6d72
movb %al, (%r14)
movzbl %al, %ecx
shlb $0x4, %al
addb $0x31, %al
movq %r14, -0x58(%rbp)
movb %al, 0x1(%r14)
incl %ecx
movl %ecx, -0x50(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x67b0
movl %eax, -0x4c(%rbp)
movl $0xc4653600, -0x38(%rbp) # imm = 0xC4653600
movl $0x0, -0x2c(%rbp)
leaq -0x34(%rbp), %r15
movq $0x0, -0x48(%rbp)
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
cmpl -0x4c(%rbp), %eax
jge 0x4bf6
movq %r12, %rdi
leaq -0x3c(%rbp), %rsi
callq 0x6d0e
movsbl %al, %r14d
movq -0x58(%rbp), %rax
movsbl 0x1(%rax), %eax
subl %eax, %r14d
xorl %r13d, %r13d
cmpl $0x3, %r13d
je 0x4bec
movl %r14d, -0x34(%rbp)
movl %r13d, -0x30(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x68b6
testb %al, %al
je 0x4bd1
leaq -0x148(%rbp), %rdi
movq %r12, %rsi
movq %rdi, %r12
movq %rsi, %rbx
callq 0x6336
movq %r12, %rdi
movq %r15, %r12
movq %r15, %rsi
callq 0x692c
movl %eax, %r15d
leaq -0x148(%rbp), %rdi
callq 0x6a92
cmpl -0x50(%rbp), %r15d
je 0x4bd9
testl %r15d, %r15d
jne 0x4bcb
movq -0x58(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x4c16
movl -0x38(%rbp), %edx
cmpl %edx, %eax
movl -0x2c(%rbp), %ecx
cmovgel -0x34(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
movq -0x48(%rbp), %rcx
cmovgel -0x30(%rbp), %ecx
movq %rcx, -0x48(%rbp)
cmovgl %eax, %edx
movl %edx, -0x38(%rbp)
movq %r12, %r15
movq %rbx, %r12
incl %r13d
jmp 0x4b3c
movl -0x34(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
movq %rax, -0x48(%rbp)
movq %r12, %r15
movq %rbx, %r12
movl -0x3c(%rbp), %eax
incl %eax
jmp 0x4b12
movq -0x48(%rbp), %rcx
shlq $0x20, %rcx
movl -0x2c(%rbp), %eax
orq %rcx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/mcts.cpp
// Function: MCTS::run(Game const&)
int MCTS::run(const Game& cur_game) {
	// initialize root Tree_node with current state
	Tree_node* root_node_ptr = new Tree_node(cur_game);

	int iteration = 0;  // nodes
	while(iteration++ < this->max_iterations) {
		// 1. select
		// Start from the root, digging down until finding an unvistied node
		Tree_node* node_ptr = root_node_ptr;
		int best_child_index;
		// The root has been visited
		if (root_node_ptr->is_visit()) {
			while(!node_ptr->is_terminate()) {
				best_child_index = this->selection_ptr->select_children_list_index(node_ptr);
				node_ptr = node_ptr->get_child_ptr(best_child_index);
				// The next child pointer hasn't been visited
				if(!node_ptr->is_visit()) {
					break;
				}
			}
		}

		int win_reward;
		if (node_ptr->is_terminate()) {
			win_reward = node_ptr->get_game_status() == (this->ai_side? 2: 1);
		}
		else {
			// 2. expand by adding a single child (if not terminal or not fully expanded)
			node_ptr->new_child_nodes();
			
			// 3. simulate
			win_reward = this->simulation(node_ptr->game);
		}

		// 4. back propagation
		while(true) {
			node_ptr->update(win_reward);
			if(node_ptr->get_parent_ptr() == NULL) break;
			node_ptr = node_ptr->get_parent_ptr();
		}
	}

	int result = root_node_ptr->get_win_count();
	this->recursive_delete_tree_node(root_node_ptr);
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
movl $0x190, %edi            # imm = 0x190
callq 0x2160
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x50dc
xorl %r13d, %r13d
leaq -0x30(%rbp), %r15
cmpl 0x4(%r14), %r13d
jge 0x4d08
movq %rbx, %rdi
callq 0x531e
movq %rbx, %r12
testb %al, %al
je 0x4c9a
movq %rbx, %r12
movq %r12, %rdi
callq 0x5310
testb %al, %al
jne 0x4c9a
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *(%rax)
movl %eax, -0x30(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x537a
movq %rax, %r12
movq %rax, %rdi
callq 0x531e
testb %al, %al
jne 0x4c65
movq %r12, %rdi
callq 0x5310
movq %r12, %rdi
testb %al, %al
je 0x4cbf
callq 0x5362
movl %eax, %ecx
movzbl (%r14), %edx
incl %edx
xorl %eax, %eax
cmpl %edx, %ecx
sete %al
jmp 0x4cd1
callq 0x5126
leaq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x4d48
incl %r13d
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x2c(%rbp)
movq %r12, %rdi
movss -0x2c(%rbp), %xmm0
callq 0x5338
movq %r12, %rdi
callq 0x536c
testq %rax, %rax
je 0x4c49
movq %r12, %rdi
callq 0x536c
movq %rax, %r12
jmp 0x4cdd
movq %rbx, %rdi
callq 0x5350
movl %eax, %r15d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e50
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
callq 0x2170
movq %r14, %rdi
callq 0x2220
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/mcts.cpp
// Function: MCTS::simulation(Game const&)
int MCTS::simulation(const Game& cur_game) {
    Game simu_game = cur_game;
	char cur_symbol;
	int game_status = 0, ai_win = this->ai_side ? 2 : 1;
	if (simu_game.get_is_switch() == this->ai_side)
		cur_symbol = this->ai_symbol;
	else
		cur_symbol = this->ai_side? '1' : 'A';

	while (game_status == 0) {
		Movement available_mvmt_list[18];
		int available_mvmt_cnt = 0;
		// find all avaible move (6 dice indices, 3 directions)
		for(int chs_index = 0; chs_index < 6; chs_index++) {
			Chess cur_chs = simu_game.get_cur_chs_list(chs_index);
			if (cur_chs.exist) {
				for (int direct = 0; direct < 3; direct++) {
					Movement tmp_mvmt(chs_index, direct);
					if (simu_game.check_in_board(tmp_mvmt)) {
						available_mvmt_list[available_mvmt_cnt] = tmp_mvmt;
						available_mvmt_cnt ++;
					}
				}
			}
		}
		// randomly pick a move.
		Movement next_mvmt = available_mvmt_list[rand() % available_mvmt_cnt];
		game_status = simu_game.update_game_status(next_mvmt);

		// check game status => if the game keep going, switch the player.
		if(game_status == 0) simu_game.switch_player();
		else break;
	}
	return (game_status == ai_win? 1: 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdi, %r14
leaq -0x1b8(%rbp), %rbx
movq %rbx, %rdi
callq 0x6336
movb (%r14), %al
movb %al, -0x29(%rbp)
movq %rbx, %rdi
callq 0x6d72
leaq -0x30(%rbp), %r15
leaq -0x38(%rbp), %r12
xorl %r14d, %r14d
movl $0x90, %edx
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
callq 0x20a0
xorl %r13d, %r13d
movl %r14d, -0x30(%rbp)
cmpl $0x6, %r14d
jge 0x4dfa
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d24
btl $0x8, %eax
jb 0x4dc1
movl -0x30(%rbp), %r14d
incl %r14d
jmp 0x4d9d
xorl %r14d, %r14d
cmpl $0x3, %r14d
je 0x4db8
movl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
movl %r14d, -0x34(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x68b6
testb %al, %al
je 0x4df5
movslq %r13d, %r13
movq -0x38(%rbp), %rax
movq %rax, -0xd0(%rbp,%r13,8)
incl %r13d
incl %r14d
jmp 0x4dc4
callq 0x2050
cltd
idivl %r13d
movslq %edx, %rax
movq -0xd0(%rbp,%rax,8), %rax
movq %rax, -0x38(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x692c
testl %eax, %eax
jne 0x4e2e
movq %rbx, %rdi
callq 0x6a92
jmp 0x4d84
movzbl -0x29(%rbp), %edx
incl %edx
xorl %ecx, %ecx
cmpl %edx, %eax
sete %cl
movl %ecx, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/mcts.cpp
// Function: MCTS::recursive_delete_tree_node(Tree_node*)
void MCTS::recursive_delete_tree_node(Tree_node* node_ptr) {
	for (int i = 0; i < 18; i++) {
		if (node_ptr->get_child_ptr(i)) {
			recursive_delete_tree_node(node_ptr->get_child_ptr(i));
		}
	}
	delete node_ptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
leaq -0x1c(%rbp), %r15
movl %eax, -0x1c(%rbp)
cmpl $0x12, %eax
jge 0x4e9b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537a
testq %rax, %rax
je 0x4e94
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537a
movq %r14, %rdi
movq %rax, %rsi
callq 0x4e50
movl -0x1c(%rbp), %eax
incl %eax
jmp 0x4e66
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdi
callq 0x2170
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/uct.cpp
// Function: UCT::select_children_list_index(Tree_node*)
int UCT::select_children_list_index(Tree_node* cur_node)
{
	float child_value_list[18] = {0};
	float best_value = 0.0;

	// calculate every UCT value of the child nodes to find the max
	for (int i=0; i<18; i++) {
		if (cur_node->get_child_ptr(i) == NULL) break;

		Tree_node* node_ptr = cur_node->get_child_ptr(i);
		float exploitation = (float)node_ptr->get_win_count() / ((float)node_ptr->get_visit_count() + this->eps);
		float exploration = this->exploration_param * sqrt( log((float)cur_node->get_visit_count() + this->t_param) / ((float)node_ptr->get_visit_count() + this->eps));
		child_value_list[i] = exploitation + exploration;
		if (child_value_list[i] > best_value)
			best_value = child_value_list[i];
	}

	// gather the nodes whose UCT value approaches best_value
	int best_children_num = 0;
	float child_index_list[18];
	for (int i=0; i<18; i++) {
		if (cur_node->get_child_ptr(i) == NULL) break;
		if (best_value - child_value_list[i] < this->eps)
			child_index_list[ best_children_num++ ] = i;
	}
	
	// select one of best child node randomly and return its index
	return child_index_list[ rand()%best_children_num ];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
andq $0x0, -0x50(%rbp)
xorl %eax, %eax
leaq -0xe0(%rbp), %r15
xorps %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movl %eax, -0xe0(%rbp)
cmpl $0x11, %eax
jg 0x5020
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537a
testq %rax, %rax
je 0x5020
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537a
movq %rax, %r13
movq %rax, %rdi
callq 0x5350
movl %eax, %r12d
movq %r13, %rdi
callq 0x5358
cvtsi2ss %eax, %xmm0
addss 0x8(%r14), %xmm0
movss %xmm0, -0x3c(%rbp)
movss 0xc(%r14), %xmm0
movss %xmm0, -0x38(%rbp)
movq %rbx, %rdi
callq 0x5358
cvtsi2ss %eax, %xmm0
addss 0x10(%r14), %xmm0
callq 0x2240
movss %xmm0, -0x34(%rbp)
movq %r13, %rdi
callq 0x5358
cvtsi2ss %eax, %xmm0
addss 0x8(%r14), %xmm0
movss -0x34(%rbp), %xmm1
divss %xmm0, %xmm1
movaps %xmm1, %xmm0
ucomiss 0x3729(%rip), %xmm1     # 0x8704
jb 0x4fe3
sqrtss %xmm0, %xmm0
jmp 0x4fe8
callq 0x2230
cvtsi2ss %r12d, %xmm1
movss -0x38(%rbp), %xmm2
mulss %xmm0, %xmm2
divss -0x3c(%rbp), %xmm1
addss %xmm2, %xmm1
movslq -0xe0(%rbp), %rax
movss %xmm1, -0x90(%rbp,%rax,4)
maxss -0x2c(%rbp), %xmm1
incl %eax
movss %xmm1, -0x2c(%rbp)
jmp 0x4f3c
xorl %eax, %eax
leaq -0x30(%rbp), %r15
xorl %r12d, %r12d
movl %eax, -0x30(%rbp)
cmpl $0x11, %eax
jg 0x5075
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537a
testq %rax, %rax
je 0x5075
movslq -0x30(%rbp), %rax
movss -0x2c(%rbp), %xmm0
subss -0x90(%rbp,%rax,4), %xmm0
movss 0x8(%r14), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x5071
cvtsi2ss %eax, %xmm0
movslq %r12d, %rcx
incl %r12d
movss %xmm0, -0xe0(%rbp,%rcx,4)
incl %eax
jmp 0x5029
callq 0x2050
cltd
idivl %r12d
movslq %edx, %rax
cvttss2si -0xe0(%rbp,%rax,4), %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::Tree_node()
Tree_node::Tree_node() {
	this->win_count = 0;
	this->visit_count = 0;
	this->game_status = 0;
	this->parent_ptr = NULL;
	for (int i = 0; i < 18; i++)
		this->children_ptr_list[i] = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
addq $0x10, %rdi
callq 0x615a
andq $0x0, (%rbx)
andl $0x0, 0x8(%rbx)
andq $0x0, 0xf8(%rbx)
xorl %eax, %eax
cmpq $0x12, %rax
je 0x50d4
andq $0x0, 0x100(%rbx,%rax,8)
incq %rax
jmp 0x50c0
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::Tree_node(Game const&)
Tree_node::Tree_node(const Game& game_) {
	this->win_count = 0;
	this->visit_count = 0;
	this->game_status = 0;
	this->game = game_;
	this->parent_ptr = NULL;
	new_child_nodes();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rdi), %r15
movq %r15, %rdi
callq 0x615a
andq $0x0, (%r14)
andl $0x0, 0x8(%r14)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6422
andq $0x0, 0xf8(%r14)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5126
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::new_child_nodes()
void Tree_node::new_child_nodes() {
	int legal_child_num = 0;
	// new the legal nodes for children_ptr
	for (int i = 0; i < 18; i++) {
		// check if the movement is legal
		int chs_index = i / 3, direction = i % 3;
		if (!this->game.get_cur_chs_list(chs_index).exist) continue;
		Movement movement(chs_index, direction);
		if (!this->game.check_in_board(movement)) continue;

		// new legal child nodes
		this->children_ptr_list[legal_child_num] = new Tree_node();
		Tree_node* node_ptr = this->children_ptr_list[legal_child_num];
		legal_child_num++;

		// reset the values of the members
		node_ptr->game = this->game;
		node_ptr->game_status = node_ptr->game.update_game_status(movement);
		node_ptr->game.switch_player();
		node_ptr->parent_ptr = this;
	}
	// reset the rest of the children_ptr to NULL
	for (int i = legal_child_num; i < 18; i++)
		this->children_ptr_list[i] = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, -0x38(%rbp)
leaq 0x10(%rdi), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movl %r15d, %eax
xorl %edx, %edx
pushq $0x3
popq %rcx
divl %ecx
movslq %r12d, %rbx
cmpl $0x12, %r15d
je 0x5204
movl %eax, %r13d
movzbl %r15b, %eax
movb $0x3, %cl
divb %cl
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movq %r14, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x6d24
btl $0x8, %eax
jae 0x51fc
imull $-0x3, %r13d, %eax
addl %r15d, %eax
movl -0x2c(%rbp), %ecx
movl %ecx, -0x40(%rbp)
movl %eax, -0x3c(%rbp)
movq %r14, %rdi
leaq -0x40(%rbp), %rsi
callq 0x68b6
testb %al, %al
je 0x51fc
movl $0x190, %edi            # imm = 0x190
callq 0x2160
movq %rax, %r12
movq %rax, %rdi
callq 0x509c
movq -0x38(%rbp), %rax
movq %r12, 0x100(%rax,%rbx,8)
incl %ebx
movq %r12, %r13
addq $0x10, %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x6422
movq %r13, %rdi
leaq -0x40(%rbp), %rsi
callq 0x692c
movl %eax, 0x8(%r12)
movq %r13, %rdi
callq 0x6a92
movq -0x38(%rbp), %rax
movq %rax, 0xf8(%r12)
movl %ebx, %r12d
incl %r15d
jmp 0x5145
movq -0x38(%rbp), %rax
cmpq $0x12, %rbx
jge 0x521c
andq $0x0, 0x100(%rax,%rbx,8)
incq %rbx
jmp 0x5208
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x190, %esi            # imm = 0x190
movq %r12, %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x2220
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::Tree_node(Tree_node*)
Tree_node::Tree_node(Tree_node* node) {
	this->win_count = node->win_count;
	this->visit_count = node->visit_count;
	this->game_status = node->game_status;
	this->game = node->game;
	this->parent_ptr = node->parent_ptr;
	for (int i = 0; i < 18; i++) {
		this->children_ptr_list[i] = node->children_ptr_list[i];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rdi), %r15
movq %r15, %rdi
callq 0x615a
movl (%rbx), %eax
movl %eax, (%r14)
movl 0x4(%rbx), %eax
movl %eax, 0x4(%r14)
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r14)
leaq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x6422
movq 0xf8(%rbx), %rax
movq %rax, 0xf8(%r14)
xorl %eax, %eax
cmpq $0x12, %rax
je 0x52aa
movq 0x100(%rbx,%rax,8), %rcx
movq %rcx, 0x100(%r14,%rax,8)
incq %rax
jmp 0x528f
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::operator=(Tree_node const&)
void Tree_node::operator=(const Tree_node& node) {
	this->win_count = node.win_count;
	this->visit_count = node.visit_count;
	this->game_status = node.game_status;
	this->game = node.game;
	this->parent_ptr = node.parent_ptr;
	for (int i = 0; i < 18; i++) {
		this->children_ptr_list[i] = node.children_ptr_list[i];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl (%rsi), %eax
movl %eax, (%rdi)
movl 0x4(%rsi), %eax
movl %eax, 0x4(%rdi)
movl 0x8(%rsi), %eax
movl %eax, 0x8(%rdi)
addq $0x10, %rsi
addq $0x10, %rdi
callq 0x6422
movq 0xf8(%rbx), %rax
movq %rax, 0xf8(%r14)
xorl %eax, %eax
cmpq $0x12, %rax
je 0x530b
movq 0x100(%rbx,%rax,8), %rcx
movq %rcx, 0x100(%r14,%rax,8)
incq %rax
jmp 0x52f0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::node_status()
void Tree_node::node_status() {
	cout << "vvvvvvvvvvvvvvv NODE_STATUS vvvvvvvvvvvvvvv" << endl;
	cout << "node : " << this << endl;
	this->game.print_board();
	this->game.print_status();
	printf("win_count: %d, visit: %d, status: %d\n", this->win_count, this->visit_count, this->game_status);

	printf("check in board                  :");
	for(int i = 0; i < 18; i ++ )
		printf("%c ", this->game.check_in_board(Movement(i/3, i%3)) ? 'T' : 'F'); printf("\n");

	printf("is exist                        :");
	for(int i = 0; i < 18; i ++ )
		printf("%c ", this->game.get_cur_chs_list(i/3).exist ? 'T' : 'F'); printf("\n");
	cout << "^^^^^^^^^^^^^^^ NODE_STATUS ^^^^^^^^^^^^^^^" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq 0x6c21(%rip), %rbx      # 0xbfc8
leaq 0x336a(%rip), %rsi      # 0x8718
movq %rbx, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x337f(%rip), %rsi      # 0x8744
movq %rbx, %rdi
callq 0x2150
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
callq 0x2090
leaq 0x10(%r14), %rbx
movq %rbx, %rdi
callq 0x6652
movq %rbx, %rdi
callq 0x6ad0
movl (%r14), %esi
movl 0x4(%r14), %edx
movl 0x8(%r14), %ecx
leaq 0x3346(%rip), %rdi      # 0x874c
xorl %eax, %eax
callq 0x2030
leaq 0x335e(%rip), %rdi      # 0x8772
xorl %eax, %eax
callq 0x2030
leaq -0x34(%rbp), %r14
pushq $0x46
popq %r13
leaq 0x336a(%rip), %r15      # 0x8794
xorl %r12d, %r12d
movl %r12d, %eax
xorl %edx, %edx
pushq $0x3
popq %rcx
divl %ecx
cmpl $0x12, %r12d
je 0x5479
imull $-0x3, %eax, %ecx
movzbl %r12b, %eax
movb $0x3, %dl
divb %dl
movzbl %al, %eax
addl %r12d, %ecx
movl %eax, -0x34(%rbp)
movl %ecx, -0x30(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68b6
testb %al, %al
movl %r13d, %esi
pushq $0x54
popq %rax
cmovnel %eax, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2030
incl %r12d
jmp 0x542d
pushq $0xa
popq %rdi
callq 0x21b0
leaq 0x3310(%rip), %rdi      # 0x8798
xorl %eax, %eax
callq 0x2030
leaq -0x2c(%rbp), %r14
leaq 0x32fa(%rip), %r15      # 0x8794
xorl %r12d, %r12d
cmpl $0x12, %r12d
je 0x54d6
movzbl %r12b, %eax
movb $0x3, %cl
divb %cl
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6d24
btl $0x8, %eax
pushq $0x54
popq %rsi
cmovael %r13d, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2030
incl %r12d
jmp 0x549d
pushq $0xa
popq %rdi
callq 0x21b0
movq 0x6ae3(%rip), %rdi      # 0xbfc8
leaq 0x32ce(%rip), %rsi      # 0x87ba
callq 0x2150
movq %rax, %rdi
callq 0x2090
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/minimax.cpp
// Function: Minimax::Minimax()
Minimax::Minimax() {
	HEIGHT = 5;
	SIMU_TIMES = 100;

	// pos: a <int,int> , <x,y> coord;
	for (int i = 0; i < 5; i++) {
		for (int j = 0;j < 5; j++) {
			// insert to map => feature_map_A;
			// get the smaller of (x,y)
			int k = (i > j ? j : i);
			k = (k+1) * (k+1) * 3;
			Pos chs_pos;
			chs_pos.first = i;
			chs_pos.second = j;
			this->feature_map_A.insert(make_pair(chs_pos, k));

			// insert to map => feature_map_B;
			// get the bigger of (x,y)
			k = (i > j ? i : j);
			k = (5-k) * (5-k) * 3;
			chs_pos.first = i;
			chs_pos.second = j;
			this->feature_map_B.insert(make_pair(chs_pos, k));
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x6868(%rip), %rax      # 0xbd88
movq %rax, (%rdi)
leaq 0x20(%rdi), %rax
andl $0x0, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
movq %rax, 0x30(%rdi)
movq %rax, 0x38(%rdi)
andq $0x0, 0x40(%rdi)
leaq 0x50(%rdi), %rax
andl $0x0, 0x50(%rdi)
andq $0x0, 0x58(%rdi)
movq %rax, 0x60(%rdi)
movq %rax, 0x68(%rdi)
andq $0x0, 0x70(%rdi)
leaq 0x18(%rdi), %rax
movq %rax, -0x40(%rbp)
leaq 0x48(%rdi), %r14
movabsq $0x6400000005, %rax     # imm = 0x6400000005
movq %rax, 0x8(%rdi)
xorl %r13d, %r13d
leaq -0x38(%rbp), %r15
cmpq $0x5, %r13
je 0x55ea
movq %r13, %r12
xorl %ebx, %ebx
cmpq $0x5, %rbx
je 0x55e5
cmpl %ebx, %r13d
movl %ebx, %eax
cmovbl %r13d, %eax
incl %eax
imull %eax, %eax
leal (%rax,%rax,2), %eax
movq %r12, -0x38(%rbp)
movl %eax, -0x30(%rbp)
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x5d1a
cmpl %ebx, %r13d
movl %ebx, %eax
cmoval %r13d, %eax
pushq $0x5
popq %rcx
subl %eax, %ecx
imull %ecx, %ecx
leal (%rcx,%rcx,2), %eax
movq %r12, -0x38(%rbp)
movl %eax, -0x30(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x5d1a
incq %rbx
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r12
jmp 0x5583
incq %r13
jmp 0x5578
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x55fb
movq %rax, %r15
movq %r14, %rdi
callq 0x3bc8
movq -0x40(%rbp), %rdi
callq 0x3bc8
movq %r15, %rdi
callq 0x2220
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/minimax.cpp
// Function: Minimax::AI_move(Game&, int)
Movement Minimax::AI_move(Game& cur_game, int dice)
{
    //cerr << "calculating..." ;
    //cerr.flush();
	clock_t init_time = clock();
	this->ai_side = cur_game.get_is_switch();
	this->ai_symbol = this->ai_side? 'A': '1';

	Movement answer;	//the best move will return
	int best_val = -1e9, child_val;
	int win = this->ai_side? 2: 1;
	int next_move_cnt = cur_game.count_movable_chs(dice);

	for (int i=0; i<next_move_cnt; i++) {
		int chs_index = cur_game.get_movable_chs(i).symbol - this->ai_symbol;
		for (int direct = 0; direct < 3; direct++) {
			Movement mvmt(chs_index, direct);
			if (cur_game.check_in_board(mvmt)) {
				Game child_game = cur_game;
				int game_status = child_game.update_game_status(mvmt);
				// check if the game ends
				if (game_status == win)
					child_val = evaluate_feature(child_game);
				else if (game_status != 0)	// lose the game
					continue;
				else {
					child_game.switch_player();
					child_val = minimax(child_game, HEIGHT);
				}
				// update the best value and the best movement
				if (child_val >= best_val) {
					best_val = child_val;
					answer = mvmt;
				}
			}
		}
	}
	double timeCost = (double)(clock() - init_time) / CLOCKS_PER_SEC;
	//printf("\ntime cost: %.2fs\n", timeCost);
	return answer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x5c(%rbp), %r12
movl %edx, (%r12)
callq 0x20c0
movq %rbx, %rdi
callq 0x6d72
movb %al, 0x10(%r14)
movzbl %al, %ecx
shlb $0x4, %al
addb $0x31, %al
movq %r14, -0x48(%rbp)
movb %al, 0x11(%r14)
incl %ecx
movl %ecx, -0x50(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x67b0
movl %eax, -0x4c(%rbp)
movl $0xc4653600, -0x30(%rbp) # imm = 0xC4653600
movl $0x0, -0x2c(%rbp)
leaq -0x3c(%rbp), %r13
leaq -0x148(%rbp), %r12
movq $0x0, -0x58(%rbp)
xorl %eax, %eax
movl %eax, -0x34(%rbp)
cmpl -0x4c(%rbp), %eax
jge 0x5740
movq %rbx, %rdi
leaq -0x34(%rbp), %rsi
callq 0x6d0e
movsbl %al, %r14d
movq -0x48(%rbp), %rax
movsbl 0x11(%rax), %eax
subl %eax, %r14d
xorl %r15d, %r15d
cmpl $0x3, %r15d
je 0x5736
movl %r14d, -0x3c(%rbp)
movl %r15d, -0x38(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x68b6
testb %al, %al
je 0x5731
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6336
movq %r12, %rdi
movq %r13, %rsi
callq 0x692c
cmpl -0x50(%rbp), %eax
jne 0x5701
movq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0x5766
jmp 0x571c
testl %eax, %eax
jne 0x5731
movq %r12, %rdi
callq 0x6a92
movq -0x48(%rbp), %rdi
movl 0x8(%rdi), %edx
movq (%rdi), %rax
movq %r12, %rsi
callq *(%rax)
cmpl -0x30(%rbp), %eax
jl 0x5731
movl -0x3c(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
movl -0x38(%rbp), %ecx
movq %rcx, -0x58(%rbp)
movl %eax, -0x30(%rbp)
incl %r15d
jmp 0x56bb
movl -0x34(%rbp), %eax
incl %eax
jmp 0x5691
callq 0x20c0
movq -0x58(%rbp), %rcx
shlq $0x20, %rcx
movl -0x2c(%rbp), %eax
orq %rcx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/minimax.cpp
// Function: Minimax::evaluate_simulation(Game const&)
int Minimax::evaluate_simulation(const Game& cur_game) {
	float win_times = 0;
	for (int game_cnt = 0; game_cnt < SIMU_TIMES; game_cnt++) {
		win_times += simulation(cur_game);
	}
	return (int)(win_times / SIMU_TIMES * 20);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xf0, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %r12d, %r12d
xorps %xmm1, %xmm1
leaq -0x110(%rbp), %r15
movl 0xc(%r14), %eax
cmpl %eax, %r12d
jge 0x5b93
movq %r15, %rdi
movq %rbx, %rsi
movss %xmm1, -0x24(%rbp)
callq 0x6336
movq %r14, %rdi
movq %r15, %rsi
callq 0x5bb8
movss -0x24(%rbp), %xmm1
cvtsi2ss %eax, %xmm0
addss %xmm0, %xmm1
incl %r12d
jmp 0x5b5d
cvtsi2ss %eax, %xmm0
divss %xmm0, %xmm1
mulss 0x2c4d(%rip), %xmm1     # 0x87f0
cvttss2si %xmm1, %eax
addq $0xf0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/minimax.cpp
// Function: Minimax::simulation(Game)
int Minimax::simulation(Game simu_game) {
	char cur_symbol;
	int game_status = 0, ai_win = this->ai_side ? 2 : 1;
	if (simu_game.get_is_switch() == this->ai_side)
		cur_symbol = this->ai_symbol;
	else
		cur_symbol = this->ai_side? '1' : 'A';

	while (game_status == 0) {
		Movement available_mvmt_list[18];
		int available_mvmt_cnt = 0;

		// find all avaible move (6 dice indices, 3 directions)
		for(int chs_index = 0; chs_index < 6; chs_index++) {
			Chess cur_chs = simu_game.get_cur_chs_list(chs_index);
			if (cur_chs.exist) {
				for (int direct = 0; direct < 3; direct++) {
					Movement tmp_mvmt(chs_index, direct);
					if (simu_game.check_in_board(tmp_mvmt)) {
						available_mvmt_list[available_mvmt_cnt] = tmp_mvmt;
						available_mvmt_cnt ++;
					}
				}
			}
		}
		// randomly pick a move.
		Movement next_mvmt = available_mvmt_list[rand() % available_mvmt_cnt];
		game_status = simu_game.update_game_status(next_mvmt);

		// check game status => if the game keep going, switch the player.
		if(game_status == 0) simu_game.switch_player();
		else break;
	}
	// return the result of game.
	return (game_status == ai_win? 1 : 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movb 0x10(%rdi), %al
movb %al, -0x29(%rbp)
movq %rsi, %rdi
callq 0x6d72
leaq -0x30(%rbp), %r15
leaq -0x38(%rbp), %r12
xorl %r14d, %r14d
movl $0x90, %edx
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
callq 0x20a0
xorl %r13d, %r13d
movl %r14d, -0x30(%rbp)
cmpl $0x6, %r14d
jge 0x5c5b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d24
btl $0x8, %eax
jb 0x5c22
movl -0x30(%rbp), %r14d
incl %r14d
jmp 0x5bfe
xorl %r14d, %r14d
cmpl $0x3, %r14d
je 0x5c19
movl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
movl %r14d, -0x34(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x68b6
testb %al, %al
je 0x5c56
movslq %r13d, %r13
movq -0x38(%rbp), %rax
movq %rax, -0xd0(%rbp,%r13,8)
incl %r13d
incl %r14d
jmp 0x5c25
callq 0x2050
cltd
idivl %r13d
movslq %edx, %rax
movq -0xd0(%rbp,%rax,8), %rax
movq %rax, -0x38(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x692c
testl %eax, %eax
jne 0x5c8f
movq %rbx, %rdi
callq 0x6a92
jmp 0x5be5
movzbl -0x29(%rbp), %edx
incl %edx
xorl %ecx, %ecx
cmpl %edx, %eax
sete %cl
movl %ecx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/game.cpp
// Function: Game::Game(Game const&)
Game::Game(const Game& game)
{
	for(int i=0; i<5; i++) {
		for(int j=0; j<5; j++) {
			this->board[i][j] = game.board[i][j];
		}
	}
	for(int i=0; i<2; i++) {
		this->movable_chs_list[i] = game.movable_chs_list[i];
	}
	for(int i=0; i<6; i++) {
		this->chs_list_A[i] = game.chs_list_A[i];
		this->chs_list_B[i] = game.chs_list_B[i];
	}
	this->exist_bitwise_A = game.exist_bitwise_A;
	this->exist_bitwise_B = game.exist_bitwise_B;
	this->is_switch = game.is_switch;
	this->cur_chs_list_ptr = (this->is_switch == false) ? this->chs_list_A :  this->chs_list_B;
	this->cur_exist_bitwise_ptr = (this->is_switch == false) ? this->exist_bitwise_A :  this->exist_bitwise_B;
	this->exist_chs_num_A = game.exist_chs_num_A;
	this->exist_chs_num_B = game.exist_chs_num_B;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movq %rdi, %rcx
movq %rsi, %rdx
cmpq $0x5, %rax
je 0x636b
xorl %r8d, %r8d
cmpq $0x5, %r8
je 0x635e
movb (%rdx,%r8), %r9b
movb %r9b, (%rcx,%r8)
incq %r8
jmp 0x634b
incq %rax
addq $0x5, %rdx
addq $0x5, %rcx
jmp 0x6342
movl 0x24(%rsi), %eax
movl %eax, 0x24(%rdi)
movq 0x1c(%rsi), %rax
movq %rax, 0x1c(%rdi)
movq 0x28(%rsi), %rax
movq %rax, 0x28(%rdi)
movl 0x30(%rsi), %eax
movl %eax, 0x30(%rdi)
movl $0x84, %eax
leaq (%rsi,%rax), %rcx
addq %rdi, %rax
movabsq $-0x48, %rdx
testq %rdx, %rdx
je 0x63ce
movl 0x8(%rcx,%rdx), %r8d
movl %r8d, 0x8(%rax,%rdx)
movq (%rcx,%rdx), %r8
movq %r8, (%rax,%rdx)
movq 0x48(%rcx,%rdx), %r8
movq %r8, 0x48(%rax,%rdx)
movl 0x50(%rcx,%rdx), %r8d
movl %r8d, 0x50(%rax,%rdx)
addq $0xc, %rdx
jmp 0x639d
movl 0xd8(%rsi), %eax
movl %eax, 0xd8(%rdi)
movl 0xdc(%rsi), %ecx
movl %ecx, 0xdc(%rdi)
movb 0xe4(%rsi), %dl
movb %dl, 0xe4(%rdi)
leaq 0x84(%rdi), %r8
leaq 0x3c(%rdi), %r9
testb %dl, %dl
cmoveq %r9, %r8
movq %r8, 0xd0(%rdi)
cmovel %eax, %ecx
movl %ecx, 0xe0(%rdi)
movl 0x34(%rsi), %eax
movl %eax, 0x34(%rdi)
movl 0x38(%rsi), %eax
movl %eax, 0x38(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/game.cpp
// Function: Game::operator=(Game const&)
void Game::operator=(const Game& game)
{
	for(int i=0; i<5; i++) {
		for(int j=0; j<5; j++) {
			this->board[i][j] = game.board[i][j];
		}
	}
	for(int i=0; i<2; i++) {
		this->movable_chs_list[i] = game.movable_chs_list[i];
	}
	for(int i=0; i<6; i++) {
		this->chs_list_A[i] = game.chs_list_A[i];
		this->chs_list_B[i] = game.chs_list_B[i];
	}
	this->exist_bitwise_A = game.exist_bitwise_A;
	this->exist_bitwise_B = game.exist_bitwise_B;
	this->is_switch = game.is_switch;
	this->cur_chs_list_ptr = (game.is_switch) ? this->chs_list_B : this->chs_list_A;
	this->exist_chs_num_A = game.exist_chs_num_A;
	this->exist_chs_num_B = game.exist_chs_num_B;
//	cout << "calling copy : "  << this->is_switch << " " << this->cur_chs_list_ptr << "  " << this->chs_list_A << "  " << this->chs_list_B << "  " << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movq %rdi, %rcx
movq %rsi, %rdx
cmpq $0x5, %rax
je 0x6457
xorl %r8d, %r8d
cmpq $0x5, %r8
je 0x644a
movb (%rdx,%r8), %r9b
movb %r9b, (%rcx,%r8)
incq %r8
jmp 0x6437
incq %rax
addq $0x5, %rdx
addq $0x5, %rcx
jmp 0x642e
movl 0x24(%rsi), %eax
movl %eax, 0x24(%rdi)
movq 0x1c(%rsi), %rax
movq %rax, 0x1c(%rdi)
movq 0x28(%rsi), %rax
movq %rax, 0x28(%rdi)
movl 0x30(%rsi), %eax
movl %eax, 0x30(%rdi)
movl $0x84, %eax
leaq (%rsi,%rax), %rcx
addq %rdi, %rax
movabsq $-0x48, %rdx
testq %rdx, %rdx
je 0x64ba
movl 0x8(%rcx,%rdx), %r8d
movl %r8d, 0x8(%rax,%rdx)
movq (%rcx,%rdx), %r8
movq %r8, (%rax,%rdx)
movq 0x48(%rcx,%rdx), %r8
movq %r8, 0x48(%rax,%rdx)
movl 0x50(%rcx,%rdx), %r8d
movl %r8d, 0x50(%rax,%rdx)
addq $0xc, %rdx
jmp 0x6489
movl 0xd8(%rsi), %eax
movl %eax, 0xd8(%rdi)
movl 0xdc(%rsi), %eax
movl %eax, 0xdc(%rdi)
movb 0xe4(%rsi), %al
movb %al, 0xe4(%rdi)
leaq 0x3c(%rdi), %rcx
leaq 0x84(%rdi), %rdx
testb %al, %al
cmovneq %rdx, %rcx
movq %rcx, 0xd0(%rdi)
movl 0x34(%rsi), %eax
movl %eax, 0x34(%rdi)
movl 0x38(%rsi), %eax
movl %eax, 0x38(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/game.cpp
// Function: Game::set_board(char (*) [5], int)
void Game::set_board(char board_[5][5], int is_switch_)
{
	int chs_num_A_ = 0, chs_num_B_ = 0;
	int exist_bitwise_A_ = 0, exist_bitwise_B_ = 0;
	for (int i=0; i<6; i++) {
		this->chs_list_A[i].assign(0, false, 0, 0);
		this->chs_list_B[i].assign(0, false, 4, 4);
	}

	for (int i=0; i<5; i++) {
		for (int j=0; j<5; j++) {
			char c = board_[j][i];

			//Set the board
			this->board[i][j] = c;

			//Update other information
			if (c>='1' && c<='6') {
				chs_num_A_++;
				this->chs_list_A[c-'1'].assign(c, true, i, j);
				exist_bitwise_A_ |= 1 << (c-'1');
			}
			else if (c>='A' && c<='f') {
				chs_num_B_++;
				this->chs_list_B[c-'A'].assign(c, true, i, j);
				exist_bitwise_B_ |= 1 << (c-'A');
			}
		}
	}
	this->exist_chs_num_A = chs_num_A_;
	this->exist_chs_num_B = chs_num_B_;
	this->exist_bitwise_A = exist_bitwise_A_;
	this->exist_bitwise_B = exist_bitwise_B_;

	if (is_switch_) {
		this->cur_chs_list_ptr = this->chs_list_B;
		this->cur_exist_bitwise_ptr = this->exist_bitwise_B;
		this->is_switch = true;
	}
	else {
		this->cur_chs_list_ptr = this->chs_list_A;
		this->cur_exist_bitwise_ptr = this->exist_bitwise_A;
		this->is_switch = false;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, -0x2c(%rbp)
leaq 0x3c(%rdi), %rax
leaq 0x84(%rdi), %rcx
movabsq $-0x48, %rdx
movabsq $0x400000004, %r8       # imm = 0x400000004
testq %rdx, %rdx
je 0x6561
andw $0x0, 0x84(%rdi,%rdx)
andq $0x0, 0x88(%rdi,%rdx)
andw $0x0, 0xcc(%rdi,%rdx)
movq %r8, 0xd0(%rdi,%rdx)
addq $0xc, %rdx
jmp 0x6533
xorl %r10d, %r10d
movq %rdi, -0x38(%rbp)
movq %rdi, %r11
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r8d, %r8d
xorl %edi, %edi
cmpq $0x5, %r10
je 0x660d
movq %rsi, -0x40(%rbp)
movq %rsi, %r15
xorl %r12d, %r12d
cmpq $0x5, %r12
je 0x65fa
movb (%r15), %r9b
movb %r9b, (%r11,%r12)
movsbl %r9b, %r13d
leal -0x31(%r13), %edx
cmpb $0x5, %dl
ja 0x65c6
incl %ebx
addl $-0x31, %r13d
imulq $0xc, %r13, %rdx
movb %r9b, (%rax,%rdx)
movb $0x1, 0x1(%rax,%rdx)
movl %r10d, 0x4(%rax,%rdx)
movl %r12d, 0x8(%rax,%rdx)
btsl %r13d, %r8d
jmp 0x65f1
leal -0x41(%r9), %edx
cmpb $0x25, %dl
ja 0x65f1
incl %r14d
addl $-0x41, %r13d
imulq $0xc, %r13, %rdx
movb %r9b, (%rcx,%rdx)
movb $0x1, 0x1(%rcx,%rdx)
movl %r10d, 0x4(%rcx,%rdx)
movl %r12d, 0x8(%rcx,%rdx)
btsl %r13d, %edi
incq %r12
addq $0x5, %r15
jmp 0x6589
incq %r10
addq $0x5, %r11
movq -0x40(%rbp), %rsi
incq %rsi
jmp 0x6575
movq -0x38(%rbp), %rdx
movl %ebx, 0x34(%rdx)
movl %r14d, 0x38(%rdx)
movl %r8d, 0xd8(%rdx)
cmpl $0x0, -0x2c(%rbp)
cmovneq %rcx, %rax
movl %edi, 0xdc(%rdx)
cmovnel %edi, %r8d
movq %rax, 0xd0(%rdx)
movl %r8d, 0xe0(%rdx)
setne 0xe4(%rdx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/game.cpp
// Function: Game::print_board()
void Game::print_board()
{
	cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
	cout << "The current board:" << endl;
	cout << "     /-----\\" << endl;
	for (int i=0; i<5; i++) {
		cout << "     |";
		for (int j=0; j<5; j++) {
			char c = this->board[j][i];
			if (c==0) cout << " ";
			else if (c >= 'A' && c <= 'F')
				cout << ANSI_COLOR_RED << c << ANSI_COLOR_RESET;
			else
				cout << ANSI_COLOR_YELLOW << c << ANSI_COLOR_RESET;
			//else cout << c;
		}
		cout << "|" << endl;
	}
	cout << "     \\-----/" << endl;
	cout << "====================================" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x595e(%rip), %r14      # 0xbfc8
leaq 0x21bf(%rip), %rsi      # 0x8830
movq %r14, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x21ce(%rip), %rsi      # 0x8856
movq %r14, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x21ca(%rip), %rsi      # 0x8869
movq %r14, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x2090
xorl %eax, %eax
leaq 0x21cb(%rip), %r12      # 0x8883
cmpq $0x5, %rax
je 0x6758
movq %rax, -0x30(%rbp)
movq %r14, %rdi
leaq 0x21a6(%rip), %rsi      # 0x8876
callq 0x2150
xorl %r13d, %r13d
cmpq $0x19, %r13
je 0x6732
movb (%rbx,%r13), %al
testb %al, %al
je 0x66fe
leal -0x41(%rax), %ecx
movsbl %al, %r15d
movq %r14, %rdi
cmpb $0x5, %cl
ja 0x670a
leaq 0x2181(%rip), %rsi      # 0x887d
jmp 0x6711
movq %r14, %rdi
leaq 0x1e17(%rip), %rsi      # 0x851f
jmp 0x6727
leaq 0x2177(%rip), %rsi      # 0x8888
callq 0x2150
movq %rax, %rdi
movl %r15d, %esi
callq 0x2190
movq %rax, %rdi
movq %r12, %rsi
callq 0x2150
addq $0x5, %r13
jmp 0x66d8
movq %r14, %rdi
leaq 0x213f(%rip), %rsi      # 0x887b
callq 0x2150
movq %rax, %rdi
callq 0x2090
movq -0x30(%rbp), %rax
incq %rax
incq %rbx
jmp 0x66b8
movq 0x5869(%rip), %rbx      # 0xbfc8
leaq 0x2128(%rip), %rsi      # 0x888e
movq %rbx, %rdi
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x1db2(%rip), %rsi      # 0x852f
movq %rbx, %rdi
callq 0x2150
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2090
nop
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/game.cpp
// Function: Game::count_movable_chs(int const&)
int Game::count_movable_chs(const int& dice)
{
	for(int i = 0; i < 2; i++)
		this->movable_chs_list[i].assign(0, false, 0, 0);

	if (this->cur_chs_list_ptr[dice].exist == true) {
		// this piece is alive!
		for(int i = 0; i < 2; i++)
			this->movable_chs_list[i] = this->cur_chs_list_ptr[dice];
		return 1;
	}
	else {
		int movable_chs_cnt = 2;

		// search for maybe other two.
		for (int i = dice-1; i >= 0; i--) {
			if (this->cur_chs_list_ptr[i].exist){
				this->movable_chs_list[0] = this->cur_chs_list_ptr[i];
				break;
			}
		}
		for (int i = dice+1; i < 6; i++) {
			if (this->cur_chs_list_ptr[i].exist){
				this->movable_chs_list[1] = this->cur_chs_list_ptr[i];
				break;
			}
		}

		// if one of movable_chs_list doesn't value, let this Chs = the other one (with value).
		for (int i = 0; i < 2; i++) {
			if (this->movable_chs_list[i].symbol == 0) {
				this->movable_chs_list[i] = this->movable_chs_list[1-i];
				movable_chs_cnt--;
			}
		}
		return movable_chs_cnt;
	}
}

// Assembly:
leaq 0x1c(%rdi), %rcx
xorl %eax, %eax
cmpq $0x18, %rax
je 0x67cd
andw $0x0, (%rcx,%rax)
andq $0x0, 0x4(%rcx,%rax)
addq $0xc, %rax
jmp 0x67b6
pushq %rbp
movq %rsp, %rbp
movq 0xd0(%rdi), %rax
movslq (%rsi), %rdx
imulq $0xc, %rdx, %r8
cmpb $0x1, 0x1(%rax,%r8)
jne 0x681e
xorl %edx, %edx
movl $0x1, %eax
cmpq $0x18, %rdx
je 0x68b4
movq 0xd0(%rdi), %r8
movslq (%rsi), %r9
imulq $0xc, %r9, %r9
movl 0x8(%r8,%r9), %r10d
movl %r10d, 0x8(%rcx,%rdx)
movq (%r8,%r9), %r8
movq %r8, (%rcx,%rdx)
addq $0xc, %rdx
jmp 0x67ee
movl %edx, %r9d
leal 0x1(%rdx), %r8d
imulq $0xc, %r9, %r9
addq %rax, %r9
decl %r8d
testl %r8d, %r8d
jle 0x6852
leaq -0xc(%r9), %r10
cmpb $0x1, -0xb(%r9)
movq %r10, %r9
jne 0x682c
movl 0x8(%r10), %edx
movl %edx, 0x8(%rcx)
movq (%r10), %rdx
movq %rdx, (%rcx)
movslq (%rsi), %rdx
imulq $0xc, %rdx, %rsi
decq %rdx
addq %rsi, %rax
incq %rdx
cmpq $0x4, %rdx
jg 0x687f
leaq 0xc(%rax), %rsi
cmpb $0x1, 0xd(%rax)
movq %rsi, %rax
jne 0x685c
movl 0x8(%rsi), %eax
movl %eax, 0x30(%rdi)
movq (%rsi), %rax
movq %rax, 0x28(%rdi)
addq $0x28, %rdi
movl $0x2, %eax
xorl %edx, %edx
cmpq $0x18, %rdx
je 0x68b4
cmpb $0x0, (%rcx,%rdx)
jne 0x68aa
leaq (%rcx,%rdx), %rsi
movl 0x8(%rdi), %r8d
movl %r8d, 0x8(%rsi)
movq (%rdi), %r8
movq %r8, (%rsi)
decl %eax
addq $0xc, %rdx
addq $-0xc, %rdi
jmp 0x688a
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tyhsu[P]Ewn/game.cpp
// Function: Game::check_in_board(std::pair<int, int> const&)
bool Game::check_in_board(const Movement& mvmt)
{
	Chess chs = this->cur_chs_list_ptr[mvmt.first];
	int side = (this->is_switch == false) ? 1 : -1;
	int x = chs.x, y = chs.y;
	x += (mvmt.second == 1) ? 0 : side;
	y += (mvmt.second == 0) ? 0 : side;
	return ( x >= 0 && x < 5 && y >= 0 && y < 5);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0xd0(%rdi), %rax
movslq (%rsi), %rcx
imulq $0xc, %rcx, %rcx
movzbl 0xe4(%rdi), %edx
negl %edx
orl $0x1, %edx
movl 0x4(%rsi), %esi
xorl %edi, %edi
cmpl $0x1, %esi
cmovnel %edx, %edi
addl 0x4(%rax,%rcx), %edi
testl %esi, %esi
cmovel %esi, %edx
addl 0x8(%rax,%rcx), %edx
cmpl $0x5, %edi
setb %cl
cmpl $0x5, %edx
setb %al
andb %cl, %al
popq %rbp
retq