// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/main.c
// Function: main_opt_init_library
void main_opt_init_library(main_opt_t *opt)
{
	int i, j, k;
	int8_t matrix[25];

	// initialize scoring matrix
	for (i = k = 0; i < 4; ++i) {
		for (j = 0; j < 4; ++j) {
			matrix[k++] = i == j? opt->match_score: -opt->mismatch_score;
		}
		matrix[k++] = 0; // ambiguous base
	}
	for (j = 0; j < 5; ++j) matrix[k++] = 0;
	// overwrite if a matrix file was given
	if (opt->matrix_fn != NULL) fill_matrix(matrix, opt->matrix_fn);

	// adjust the library mode if it is set on auto
	if (opt->library == AutoLibrary) {
		switch (opt->alignment_mode) {
			case Local: 
			case Glocal: 
			case Global: opt->library = Parasail; break;
			case Extension: opt->library = Ksw2; break;
			default:
				fprintf(stderr, "Unknown alignment mode in %s: %d\n", __func__, opt->alignment_mode); 
				exit(1);
		}
	}

	switch (opt->library) {
		case Ksw2: 
			opt->_library_func = align_with_ksw2;
			opt->_library_data = (void*)ksw2_data_init(opt, matrix); 
			break;
		case Parasail: 
			opt->_library_func = align_with_parasail;
			opt->_library_data = (void*)parasail_data_init(opt, matrix); 
			break;
		default:
			fprintf(stderr, "Unknown library in %s: %d", __func__, opt->library);
			exit(1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x4, -0xc(%rbp)
jge 0x1b7f5a
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x1b7f3d
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x1b7f10
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0x1b7f1c
movq -0x8(%rbp), %rcx
xorl %eax, %eax
subl 0x4(%rcx), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movb %al, %cl
movl -0x14(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
cltq
movb %cl, -0x30(%rbp,%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1b7ef7
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
cltq
movb $0x0, -0x30(%rbp,%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1b7eea
movl $0x0, -0x10(%rbp)
cmpl $0x5, -0x10(%rbp)
jge 0x1b7f84
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
cltq
movb $0x0, -0x30(%rbp,%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x1b7f61
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1b7fa0
leaq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x1b7810
movq -0x8(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jne 0x1b801b
movq -0x8(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x38(%rbp)
subl $0x2, %eax
jb 0x1b7fcf
jmp 0x1b7fbb
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0x1b7fdc
jmp 0x1b7fc5
movl -0x38(%rbp), %eax
subl $0x3, %eax
jne 0x1b7fe9
jmp 0x1b7fcf
movq -0x8(%rbp), %rax
movl $0x2, 0x38(%rax)
jmp 0x1b8019
movq -0x8(%rbp), %rax
movl $0x1, 0x38(%rax)
jmp 0x1b8019
movq 0xc6efe8(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
leaq 0xad55a3(%rip), %rsi    # 0xc8d5a4
leaq 0xad55be(%rip), %rdx    # 0xc8d5c6
movb $0x0, %al
callq 0x19e180
movl $0x1, %edi
callq 0x19e130
jmp 0x1b801b
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x3c(%rbp)
subl $0x1, %eax
je 0x1b8036
jmp 0x1b802c
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x1b805f
jmp 0x1b8088
movq -0x8(%rbp), %rax
leaq 0x7f(%rip), %rcx        # 0x1b80c0
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1b7a10
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
jmp 0x1b80b8
movq -0x8(%rbp), %rax
leaq 0x476(%rip), %rcx       # 0x1b84e0
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1b7c90
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
jmp 0x1b80b8
movq 0xc6ef49(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
leaq 0xad553c(%rip), %rsi    # 0xc8d5dc
leaq 0xad551f(%rip), %rdx    # 0xc8d5c6
movb $0x0, %al
callq 0x19e180
movl $0x1, %edi
callq 0x19e130
addq $0x40, %rsp
popq %rbp
retq
nop