#include "InitializeComponents.cuh"


/**
  *	Sets up a neural network with a specified amount of input and output 
  *	neurons with the same number of hidden nodes per layer and the same 
  *	activations for each neuron
  *	Parameter layers: the amount of layers in the neural net
  *	Parameter inputNeurons: the number of neurons for the input layer
  *	Parameter hiddenNeurons: the number of neurons in each hidden layer
  *	Parameter outputNeurons: the number of neurons for the output layer
  *	Parameter fullActivations: the activations for the entire neural 
  *	network - this is the same for every neuron
  *	Returns: a neural network with the specified attributes
  */

NeuralNet* setupMonotonicNeuralNet(int layers, int inputNeurons, 
	int hiddenNeurons, int outputNeurons, activation fullActivations){

	int* neurons=(int*)calloc(layers, sizeof(int));
	activation** activations=(activation**)calloc(layers-1, 
		sizeof(activation*));

	// Assigns the parameters for the neural net
	for(int layer=0; layer<layers; layer++){

		// The input layer
		if(layer==0){
			neurons[layer]=inputNeurons;
		}

		// The output layer
		else if(layer==layers-1){
			neurons[layer]=outputNeurons;
			activations[layer-1]=(activation*)calloc(outputNeurons, 
				sizeof(activation));

			for(int neuron=0; neuron<outputNeurons; neuron++){
				activations[layer-1][neuron]=fullActivations;
			}
		}

		// The hidden layer
		else{
			neurons[layer]=hiddenNeurons;
			activations[layer-1]=(activation*)calloc(hiddenNeurons, 
				sizeof(activation));

			for(int neuron=0; neuron<hiddenNeurons; neuron++){
				activations[layer-1][neuron]=fullActivations;
			}
		}
	}

	return createNeuralNet(layers, neurons, activations);
}

void setupGame(int layers, int inputNeurons, int hiddenNeurons, 
	int outputNeurons, activation activations, int playerColor, 
	char* file1, char* file2){

	NeuralNet* nn1=setupMonotonicNeuralNet(layers, 
		inputNeurons, hiddenNeurons, 
		outputNeurons, activations);
	NeuralNet* nn2=setupMonotonicNeuralNet(layers, 
		inputNeurons, hiddenNeurons, 
		outputNeurons, activations);

	train(nn1, nn2, playerColor, file1, file2);
}

void setupPausedGame(int playerColor, char* file1, char* file2){
	printf("Deserializing the neural networks\n");
	
	char* buffer=(char*)calloc(8, sizeof(char));
	
	NeuralNet* nn1=deserializeNeuralNet(file1);
	NeuralNet* nn2=deserializeNeuralNet(file2);
	
	train(nn1, nn2, playerColor, file1, file2);
}

void getSetup(int layers, int inputNeurons, int hiddenNeurons, 
	int outputNeurons, activation activations, char* file1, char* file2){
	
	int resume=0;
	int playerColor=-1;

	char* buffer=(char*)calloc(80, sizeof(char));
	
	do{
		printf("Do you want to resume a game?[y/n]\n");
		fgets(buffer, 78, stdin);
	} while(strcmp(buffer, "y\n\0")!=0 && strcmp(buffer, "n\n\0")!=0);

	if(strcmp(buffer, "y\n\0")==0){
		resume=1;
	}

	do{
		printf("Do you want to play?[y/n]\n");
		fgets(buffer, 78, stdin);
	} while(strcmp(buffer, "y\n\0")!=0 && strcmp(buffer, "n\n\0"));
	
	if(strcmp(buffer, "y\n\0")==0){
		do{
			printf("What color do you want to play as? [w/b]\n");
			fgets(buffer, 78, stdin);
		}while(strcmp(buffer, "w\n\0")!=0 && strcmp(buffer, "b\n\0")!=0);

		if(strcmp(buffer, "w\n\0")==0){
			playerColor=0;
		}
		else{
			playerColor=1;
		}
	}

	free(buffer);

	if(resume){
		setupPausedGame(playerColor, file1, file2);
	}
	else{
		setupGame(layers, inputNeurons, hiddenNeurons, outputNeurons, activations, 
			playerColor, file1, file2);
	}
}

	.file	"tmpxft_0034382a_00000000-6_InitializeComponents.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z23setupMonotonicNeuralNetiiii10activation
	.type	_Z23setupMonotonicNeuralNetiiii10activation, @function
_Z23setupMonotonicNeuralNetiiii10activation:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r8d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%ecx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	%esi, 20(%rsp)
	movl	$4, %esi
	movl	%edx, 12(%rsp)
	call	calloc@PLT
	movl	$8, %esi
	movq	%rax, %rbp
	leal	-1(%rbx), %eax
	movslq	%eax, %rdi
	movl	%eax, 16(%rsp)
	call	calloc@PLT
	movq	%rax, %r15
	movslq	12(%rsp), %rax
	movq	%rax, 24(%rsp)
.L3:
	movl	%r12d, %eax
	cmpl	%ebx, %r12d
	jge	.L15
	testq	%r12, %r12
	jne	.L4
	movl	20(%rsp), %eax
	movl	%eax, 0(%rbp)
	jmp	.L5
.L4:
	cmpl	%eax, 16(%rsp)
	jne	.L6
	movl	%r13d, 0(%rbp,%r12,4)
	movl	$4, %esi
	movslq	%r13d, %rdi
	call	calloc@PLT
	xorl	%esi, %esi
	movq	%rax, -8(%r15,%r12,8)
.L7:
	cmpl	%esi, %r13d
	jle	.L5
	movl	%r14d, (%rax,%rsi,4)
	incq	%rsi
	jmp	.L7
.L6:
	movl	12(%rsp), %eax
	movq	24(%rsp), %rdi
	movl	$4, %esi
	movl	%eax, 0(%rbp,%r12,4)
	call	calloc@PLT
	xorl	%esi, %esi
	movq	%rax, -8(%r15,%r12,8)
.L9:
	cmpl	%esi, 12(%rsp)
	jle	.L5
	movl	%r14d, (%rax,%rsi,4)
	incq	%rsi
	jmp	.L9
.L5:
	incq	%r12
	jmp	.L3
.L15:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	movq	%r15, %rdx
	movq	%rbp, %rsi
	movl	%ebx, %edi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z15createNeuralNetiPiPP10activation@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z23setupMonotonicNeuralNetiiii10activation, .-_Z23setupMonotonicNeuralNetiiii10activation
	.globl	_Z9setupGameiiii10activationiPcS0_
	.type	_Z9setupGameiiii10activationiPcS0_, @function
_Z9setupGameiiii10activationiPcS0_:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%r9d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	80(%rsp), %r14
	movq	88(%rsp), %r15
	movl	%r8d, 28(%rsp)
	movl	%ecx, 24(%rsp)
	movl	%edx, 20(%rsp)
	movl	%esi, 16(%rsp)
	movl	%edi, 12(%rsp)
	call	_Z23setupMonotonicNeuralNetiiii10activation
	movl	28(%rsp), %r8d
	movl	24(%rsp), %ecx
	movl	20(%rsp), %edx
	movl	16(%rsp), %esi
	movq	%rax, %rbx
	movl	12(%rsp), %edi
	call	_Z23setupMonotonicNeuralNetiiii10activation
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	movq	%r15, %r8
	movq	%r14, %rcx
	movl	%ebp, %edx
	movq	%rbx, %rdi
	movq	%rax, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z5trainP2nnS0_iPcS1_@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z9setupGameiiii10activationiPcS0_, .-_Z9setupGameiiii10activationiPcS0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Deserializing the neural networks\n"
	.text
	.globl	_Z15setupPausedGameiPcS_
	.type	_Z15setupPausedGameiPcS_, @function
_Z15setupPausedGameiPcS_:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edi, %r13d
	movl	$2, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rsi, %rbx
	leaq	.LC0(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	call	_Z20deserializeNeuralNetPc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Z20deserializeNeuralNetPc@PLT
	popq	%r9
	.cfi_def_cfa_offset 40
	movq	%rbp, %r8
	movq	%rbx, %rcx
	movl	%r13d, %edx
	popq	%rbx
	.cfi_def_cfa_offset 32
	movq	%r12, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 24
	movq	%rax, %rsi
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	_Z5trainP2nnS0_iPcS1_@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z15setupPausedGameiPcS_, .-_Z15setupPausedGameiPcS_
	.section	.rodata.str1.1
.LC1:
	.string	"Do you want to resume a game?[y/n]\n"
	.section	.rodata
.LC2:
	.string	"y\n"
	.string	""
.LC3:
	.string	"n\n"
	.string	""
	.section	.rodata.str1.1
.LC4:
	.string	"Do you want to play?[y/n]\n"
.LC5:
	.string	"What color do you want to play as? [w/b]\n"
	.section	.rodata
.LC6:
	.string	"w\n"
	.string	""
.LC7:
	.string	"b\n"
	.string	""
	.text
	.globl	_Z8getSetupiiii10activationPcS0_
	.type	_Z8getSetupiiii10activationPcS0_, @function
_Z8getSetupiiii10activationPcS0_:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r9, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	%edi, 8(%rsp)
	movl	$80, %edi
	movq	96(%rsp), %r13
	movl	%esi, 12(%rsp)
	movl	$1, %esi
	movl	%edx, 16(%rsp)
	movl	%ecx, 20(%rsp)
	movl	%r8d, 24(%rsp)
	call	calloc@PLT
	movq	%rax, %rbx
.L22:
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdin(%rip), %rcx
	movl	$78, %edx
	movq	%rbx, %rdi
	movl	$80, %esi
	leaq	.LC2(%rip), %r14
	call	__fgets_chk@PLT
	movq	%r14, %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.L21
	leaq	.LC3(%rip), %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L22
.L21:
	leaq	.LC4(%rip), %r15
.L24:
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdin(%rip), %rcx
	movl	$80, %esi
	movq	%rbx, %rdi
	movl	$78, %edx
	call	__fgets_chk@PLT
	movq	%r14, %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L38
	leaq	.LC5(%rip), %r14
	jmp	.L23
.L38:
	leaq	.LC3(%rip), %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L24
	orl	$-1, %r9d
	jmp	.L25
.L40:
	leaq	.LC7(%rip), %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	je	.L26
.L23:
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdin(%rip), %rcx
	movl	$78, %edx
	movq	%rbx, %rdi
	movl	$80, %esi
	call	__fgets_chk@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rbx, %rdi
	call	strcmp@PLT
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	.L40
.L26:
	xorl	%r9d, %r9d
	testl	%r15d, %r15d
	setne	%r9b
.L25:
	movq	%rbx, %rdi
	movl	%r9d, 28(%rsp)
	call	free@PLT
	testl	%r12d, %r12d
	movl	28(%rsp), %r9d
	jne	.L27
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movl	%r9d, %edi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z15setupPausedGameiPcS_
.L27:
	.cfi_restore_state
	pushq	%r13
	.cfi_def_cfa_offset 104
	pushq	%rbp
	.cfi_def_cfa_offset 112
	movl	40(%rsp), %r8d
	movl	36(%rsp), %ecx
	movl	32(%rsp), %edx
	movl	28(%rsp), %esi
	movl	24(%rsp), %edi
	call	_Z9setupGameiiii10activationiPcS0_
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z8getSetupiiii10activationPcS0_, .-_Z8getSetupiiii10activationPcS0_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include "InitializeComponents.cuh"


/**
  *	Sets up a neural network with a specified amount of input and output 
  *	neurons with the same number of hidden nodes per layer and the same 
  *	activations for each neuron
  *	Parameter layers: the amount of layers in the neural net
  *	Parameter inputNeurons: the number of neurons for the input layer
  *	Parameter hiddenNeurons: the number of neurons in each hidden layer
  *	Parameter outputNeurons: the number of neurons for the output layer
  *	Parameter fullActivations: the activations for the entire neural 
  *	network - this is the same for every neuron
  *	Returns: a neural network with the specified attributes
  */

NeuralNet* setupMonotonicNeuralNet(int layers, int inputNeurons, 
	int hiddenNeurons, int outputNeurons, activation fullActivations){

	int* neurons=(int*)calloc(layers, sizeof(int));
	activation** activations=(activation**)calloc(layers-1, 
		sizeof(activation*));

	// Assigns the parameters for the neural net
	for(int layer=0; layer<layers; layer++){

		// The input layer
		if(layer==0){
			neurons[layer]=inputNeurons;
		}

		// The output layer
		else if(layer==layers-1){
			neurons[layer]=outputNeurons;
			activations[layer-1]=(activation*)calloc(outputNeurons, 
				sizeof(activation));

			for(int neuron=0; neuron<outputNeurons; neuron++){
				activations[layer-1][neuron]=fullActivations;
			}
		}

		// The hidden layer
		else{
			neurons[layer]=hiddenNeurons;
			activations[layer-1]=(activation*)calloc(hiddenNeurons, 
				sizeof(activation));

			for(int neuron=0; neuron<hiddenNeurons; neuron++){
				activations[layer-1][neuron]=fullActivations;
			}
		}
	}

	return createNeuralNet(layers, neurons, activations);
}

void setupGame(int layers, int inputNeurons, int hiddenNeurons, 
	int outputNeurons, activation activations, int playerColor, 
	char* file1, char* file2){

	NeuralNet* nn1=setupMonotonicNeuralNet(layers, 
		inputNeurons, hiddenNeurons, 
		outputNeurons, activations);
	NeuralNet* nn2=setupMonotonicNeuralNet(layers, 
		inputNeurons, hiddenNeurons, 
		outputNeurons, activations);

	train(nn1, nn2, playerColor, file1, file2);
}

void setupPausedGame(int playerColor, char* file1, char* file2){
	printf("Deserializing the neural networks\n");
	
	char* buffer=(char*)calloc(8, sizeof(char));
	
	NeuralNet* nn1=deserializeNeuralNet(file1);
	NeuralNet* nn2=deserializeNeuralNet(file2);
	
	train(nn1, nn2, playerColor, file1, file2);
}

void getSetup(int layers, int inputNeurons, int hiddenNeurons, 
	int outputNeurons, activation activations, char* file1, char* file2){
	
	int resume=0;
	int playerColor=-1;

	char* buffer=(char*)calloc(80, sizeof(char));
	
	do{
		printf("Do you want to resume a game?[y/n]\n");
		fgets(buffer, 78, stdin);
	} while(strcmp(buffer, "y\n\0")!=0 && strcmp(buffer, "n\n\0")!=0);

	if(strcmp(buffer, "y\n\0")==0){
		resume=1;
	}

	do{
		printf("Do you want to play?[y/n]\n");
		fgets(buffer, 78, stdin);
	} while(strcmp(buffer, "y\n\0")!=0 && strcmp(buffer, "n\n\0"));
	
	if(strcmp(buffer, "y\n\0")==0){
		do{
			printf("What color do you want to play as? [w/b]\n");
			fgets(buffer, 78, stdin);
		}while(strcmp(buffer, "w\n\0")!=0 && strcmp(buffer, "b\n\0")!=0);

		if(strcmp(buffer, "w\n\0")==0){
			playerColor=0;
		}
		else{
			playerColor=1;
		}
	}

	free(buffer);

	if(resume){
		setupPausedGame(playerColor, file1, file2);
	}
	else{
		setupGame(layers, inputNeurons, hiddenNeurons, outputNeurons, activations, 
			playerColor, file1, file2);
	}
}

	.text
	.file	"InitializeComponents.hip"
	.globl	_Z23setupMonotonicNeuralNetiiii10activation # -- Begin function _Z23setupMonotonicNeuralNetiiii10activation
	.type	_Z23setupMonotonicNeuralNetiiii10activation,@function
_Z23setupMonotonicNeuralNetiiii10activation: # @_Z23setupMonotonicNeuralNetiiii10activation
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r8d, %ebx
	movl	%ecx, %r15d
	movl	%edx, %r13d
	movl	%esi, 28(%rsp)                  # 4-byte Spill
	movl	%edi, 4(%rsp)                   # 4-byte Spill
	movslq	%edi, %rbp
	movl	$4, %esi
	movq	%rbp, %rdi
	callq	calloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	leal	-1(%rbp), %r14d
	movslq	%r14d, %rdi
	movl	$8, %esi
	callq	calloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testl	%ebp, %ebp
	jle	.LBB0_12
# %bb.1:                                # %.lr.ph49
	movslq	%r13d, %rax
	movslq	%r15d, %rcx
	movl	%r14d, %r14d
	movl	4(%rsp), %edx                   # 4-byte Reload
	movq	%rdx, 48(%rsp)                  # 8-byte Spill
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	%eax, %r15d
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	movl	%ecx, %r13d
	xorl	%ebp, %ebp
.LBB0_2:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_10 Depth 2
                                        #     Child Loop BB0_7 Depth 2
	testq	%rbp, %rbp
	je	.LBB0_3
# %bb.4:                                #   in Loop: Header=BB0_2 Depth=1
	cmpq	%r14, %rbp
	jne	.LBB0_8
# %bb.5:                                #   in Loop: Header=BB0_2 Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	32(%rsp), %r12                  # 8-byte Reload
	movl	%r12d, (%rax,%r14,4)
	movl	$4, %esi
	movq	%r12, %rdi
	callq	calloc
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, -8(%rcx,%r14,8)
	testl	%r12d, %r12d
	jle	.LBB0_11
# %bb.6:                                # %.lr.ph45.preheader
                                        #   in Loop: Header=BB0_2 Depth=1
	xorl	%ecx, %ecx
.LBB0_7:                                # %.lr.ph45
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebx, (%rax,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %r13
	jne	.LBB0_7
	jmp	.LBB0_11
.LBB0_3:                                #   in Loop: Header=BB0_2 Depth=1
	movl	28(%rsp), %eax                  # 4-byte Reload
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movl	%eax, (%rcx)
	jmp	.LBB0_11
.LBB0_8:                                #   in Loop: Header=BB0_2 Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	40(%rsp), %r12                  # 8-byte Reload
	movl	%r12d, (%rax,%rbp,4)
	movl	$4, %esi
	movq	%r12, %rdi
	callq	calloc
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, -8(%rcx,%rbp,8)
	testl	%r12d, %r12d
	jle	.LBB0_11
# %bb.9:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB0_2 Depth=1
	xorl	%ecx, %ecx
.LBB0_10:                               # %.lr.ph
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebx, (%rax,%rcx,4)
	incq	%rcx
	cmpq	%rcx, %r15
	jne	.LBB0_10
.LBB0_11:                               # %.loopexit
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%rbp
	cmpq	48(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB0_2
.LBB0_12:                               # %._crit_edge
	movl	4(%rsp), %edi                   # 4-byte Reload
	movq	8(%rsp), %rsi                   # 8-byte Reload
	movq	16(%rsp), %rdx                  # 8-byte Reload
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z15createNeuralNetiPiPP10activation # TAILCALL
.Lfunc_end0:
	.size	_Z23setupMonotonicNeuralNetiiii10activation, .Lfunc_end0-_Z23setupMonotonicNeuralNetiiii10activation
	.cfi_endproc
                                        # -- End function
	.globl	_Z9setupGameiiii10activationiPcS0_ # -- Begin function _Z9setupGameiiii10activationiPcS0_
	.type	_Z9setupGameiiii10activationiPcS0_,@function
_Z9setupGameiiii10activationiPcS0_:     # @_Z9setupGameiiii10activationiPcS0_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, 4(%rsp)                   # 4-byte Spill
	movl	%r8d, %ebp
	movl	%ecx, %r14d
	movl	%edx, %r15d
	movl	%esi, %r12d
	movl	%edi, %r13d
	movq	80(%rsp), %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movq	88(%rsp), %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	callq	_Z23setupMonotonicNeuralNetiiii10activation
	movq	%rax, %rbx
	movl	%r13d, %edi
	movl	%r12d, %esi
	movl	%r15d, %edx
	movl	%r14d, %ecx
	movl	%ebp, %r8d
	callq	_Z23setupMonotonicNeuralNetiiii10activation
	movq	%rbx, %rdi
	movq	%rax, %rsi
	movl	4(%rsp), %edx                   # 4-byte Reload
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movq	8(%rsp), %r8                    # 8-byte Reload
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z5trainP2nnS0_iPcS1_           # TAILCALL
.Lfunc_end1:
	.size	_Z9setupGameiiii10activationiPcS0_, .Lfunc_end1-_Z9setupGameiiii10activationiPcS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z15setupPausedGameiPcS_        # -- Begin function _Z15setupPausedGameiPcS_
	.type	_Z15setupPausedGameiPcS_,@function
_Z15setupPausedGameiPcS_:               # @_Z15setupPausedGameiPcS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movl	%edi, %ebp
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	%r14, %rdi
	callq	_Z20deserializeNeuralNetPc
	movq	%rax, %r15
	movq	%rbx, %rdi
	callq	_Z20deserializeNeuralNetPc
	movq	%r15, %rdi
	movq	%rax, %rsi
	movl	%ebp, %edx
	movq	%r14, %rcx
	movq	%rbx, %r8
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z5trainP2nnS0_iPcS1_           # TAILCALL
.Lfunc_end2:
	.size	_Z15setupPausedGameiPcS_, .Lfunc_end2-_Z15setupPausedGameiPcS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z8getSetupiiii10activationPcS0_ # -- Begin function _Z8getSetupiiii10activationPcS0_
	.type	_Z8getSetupiiii10activationPcS0_,@function
_Z8getSetupiiii10activationPcS0_:       # @_Z8getSetupiiii10activationPcS0_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, %rbx
	movl	%r8d, %ebp
	movl	%ecx, 12(%rsp)                  # 4-byte Spill
	movl	%edx, 8(%rsp)                   # 4-byte Spill
	movl	%esi, 4(%rsp)                   # 4-byte Spill
	movl	%edi, (%rsp)                    # 4-byte Spill
	movq	80(%rsp), %r14
	movl	$80, %edi
	movl	$1, %esi
	callq	calloc
	movq	%rax, %r15
.LBB3_1:                                # =>This Inner Loop Header: Depth=1
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	stdin(%rip), %rdx
	movq	%r15, %rdi
	movl	$78, %esi
	callq	fgets
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	callq	strcmp
	movl	%eax, %r12d
	testl	%eax, %eax
	je	.LBB3_3
# %bb.2:                                #   in Loop: Header=BB3_1 Depth=1
	movl	$.L.str.3, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB3_1
	jmp	.LBB3_3
.LBB3_8:                                #   in Loop: Header=BB3_3 Depth=1
	movl	$.L.str.3, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB3_9
.LBB3_3:                                # %.critedge
                                        # =>This Inner Loop Header: Depth=1
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movq	stdin(%rip), %rdx
	movq	%r15, %rdi
	movl	$78, %esi
	callq	fgets
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB3_8
# %bb.4:
	movq	%r14, 16(%rsp)                  # 8-byte Spill
	movq	%rbx, %r14
	movl	%ebp, %ebx
.LBB3_5:                                # %.critedge2
                                        # =>This Inner Loop Header: Depth=1
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	stdin(%rip), %rdx
	movq	%r15, %rdi
	movl	$78, %esi
	callq	fgets
	movl	$.L.str.6, %esi
	movq	%r15, %rdi
	callq	strcmp
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.LBB3_7
# %bb.6:                                #   in Loop: Header=BB3_5 Depth=1
	movl	$.L.str.7, %esi
	movq	%r15, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB3_5
.LBB3_7:                                # %.critedge4
	xorl	%r13d, %r13d
	testl	%ebp, %ebp
	setne	%r13b
	movl	%ebx, %ebp
	movq	%r14, %rbx
	movq	16(%rsp), %r14                  # 8-byte Reload
	jmp	.LBB3_10
.LBB3_9:
	movl	$-1, %r13d
.LBB3_10:                               # %.critedge2.thread
	movq	%r15, %rdi
	callq	free
	testl	%r12d, %r12d
	je	.LBB3_12
# %bb.11:
	movl	(%rsp), %edi                    # 4-byte Reload
	movl	4(%rsp), %esi                   # 4-byte Reload
	movl	8(%rsp), %edx                   # 4-byte Reload
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ebp, %r8d
	movl	%r13d, %r9d
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	callq	_Z9setupGameiiii10activationiPcS0_
	addq	$40, %rsp
	.cfi_adjust_cfa_offset -40
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB3_12:
	.cfi_def_cfa_offset 80
	movl	%r13d, %edi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z15setupPausedGameiPcS_        # TAILCALL
.Lfunc_end3:
	.size	_Z8getSetupiiii10activationPcS0_, .Lfunc_end3-_Z8getSetupiiii10activationPcS0_
	.cfi_endproc
                                        # -- End function
	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.cst4,"aM",@progbits,4
.L.str.2:
	.asciz	"y\n\000"
	.size	.L.str.2, 4

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"n\n\000"
	.size	.L.str.3, 4

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"w\n\000"
	.size	.L.str.6, 4

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"b\n\000"
	.size	.L.str.7, 4

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Deserializing the neural networks"
	.size	.Lstr, 34

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Do you want to resume a game?[y/n]"
	.size	.Lstr.1, 35

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Do you want to play?[y/n]"
	.size	.Lstr.2, 26

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"What color do you want to play as? [w/b]"
	.size	.Lstr.3, 41

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
