// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/common/type.c
// Function: subtilis_type_section_new
subtilis_type_section_t *
subtilis_type_section_new(const subtilis_type_t *rtype, size_t num_parameters,
			  const subtilis_type_t *parameters,
			  subtilis_check_args_t *check_args,
			  subtilis_error_t *err)

{
	size_t i;
	subtilis_type_t *ftype;
	subtilis_type_section_t *stype = malloc(sizeof(*stype));

	if (!stype) {
		subtilis_error_set_oom(err);
		return NULL;
	}

	stype->ref_count = 1;

	ftype = &stype->type;
	ftype->type = SUBTILIS_TYPE_FN;
	ftype->params.fn.ret_val = calloc(1, sizeof(*ftype->params.fn.ret_val));
	if (!ftype->params.fn.ret_val) {
		subtilis_error_set_oom(err);
		goto on_error;
	}
	ftype->params.fn.ret_val->type = SUBTILIS_TYPE_VOID;
	subtilis_type_init_copy(ftype->params.fn.ret_val, rtype, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	ftype->params.fn.num_params = num_parameters;
	for (i = 0; i < num_parameters; i++) {
		ftype->params.fn.params[i] =
		    calloc(1, sizeof(*ftype->params.fn.params[i]));
		if (!ftype->params.fn.params[i]) {
			subtilis_error_set_oom(err);
			goto on_error;
		}
		ftype->params.fn.params[i]->type = SUBTILIS_TYPE_VOID;

		subtilis_type_init_copy(ftype->params.fn.params[i],
					&parameters[i], err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	}
	stype->check_args = check_args;
	stype->int_regs = 0;
	stype->fp_regs = 0;

	for (i = 0; i < ftype->params.fn.num_params; i++) {
		switch (ftype->params.fn.params[i]->type) {
		case SUBTILIS_TYPE_INTEGER:
		case SUBTILIS_TYPE_BYTE:
		case SUBTILIS_TYPE_STRING:
		case SUBTILIS_TYPE_ARRAY_REAL:
		case SUBTILIS_TYPE_ARRAY_INTEGER:
		case SUBTILIS_TYPE_ARRAY_STRING:
		case SUBTILIS_TYPE_ARRAY_BYTE:
		case SUBTILIS_TYPE_ARRAY_FN:
		case SUBTILIS_TYPE_ARRAY_REC:
		case SUBTILIS_TYPE_VECTOR_REAL:
		case SUBTILIS_TYPE_VECTOR_INTEGER:
		case SUBTILIS_TYPE_VECTOR_STRING:
		case SUBTILIS_TYPE_VECTOR_BYTE:
		case SUBTILIS_TYPE_VECTOR_FN:
		case SUBTILIS_TYPE_VECTOR_REC:
		case SUBTILIS_TYPE_FN:
		case SUBTILIS_TYPE_REC:
			stype->int_regs++;
			break;
		case SUBTILIS_TYPE_REAL:
			stype->fp_regs++;
			break;
		default:
			subtilis_error_set_assertion_failed(err);
			goto on_error;
		}
	}

	return stype;

on_error:

	free(stype);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x168, %edi            # imm = 0x168
callq 0x121b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x3dc58
movq -0x30(%rbp), %rdi
movl $0x1, %esi
leaq 0x6e43f(%rip), %rdx     # 0xac080
movl $0xca, %ecx
callq 0x158e0
movq $0x0, -0x8(%rbp)
jmp 0x3deab
movq -0x48(%rbp), %rax
movq $0x1, 0x150(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl $0x9, (%rax)
movl $0x1, %edi
movl $0x148, %esi            # imm = 0x148
callq 0x12130
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3dcbd
movq -0x30(%rbp), %rdi
movl $0x1, %esi
leaq 0x6e3d2(%rip), %rdx     # 0xac080
movl $0xd4, %ecx
callq 0x158e0
jmp 0x3de9a
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movl $0x8, (%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x3dec0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3dcee
jmp 0x3de9a
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x3ddb7
movl $0x1, %edi
movl $0x148, %esi            # imm = 0x148
callq 0x12130
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rdx, 0x18(%rax,%rcx,8)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq $0x0, 0x18(%rax,%rcx,8)
jne 0x3dd5e
movq -0x30(%rbp), %rdi
movl $0x1, %esi
leaq 0x6e331(%rip), %rdx     # 0xac080
movl $0xe0, %ecx
callq 0x158e0
jmp 0x3de9a
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movl $0x8, (%rax)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rdi
movq -0x20(%rbp), %rsi
imulq $0x148, -0x38(%rbp), %rax # imm = 0x148
addq %rax, %rsi
movq -0x30(%rbp), %rdx
callq 0x3dec0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3dda4
jmp 0x3de9a
jmp 0x3dda6
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x3dd02
movq -0x28(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x148(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x158(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x160(%rax)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x3de90
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
subl $0x4, %eax
je 0x3de49
jmp 0x3de17
movl -0x4c(%rbp), %eax
addl $-0x5, %eax
subl $0x3, %eax
jb 0x3de31
jmp 0x3de24
movl -0x4c(%rbp), %eax
addl $-0x9, %eax
subl $0xd, %eax
ja 0x3de61
jmp 0x3de31
movq -0x48(%rbp), %rax
movq 0x158(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x158(%rax)
jmp 0x3de7d
movq -0x48(%rbp), %rax
movq 0x160(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x160(%rax)
jmp 0x3de7d
movq -0x30(%rbp), %rdi
movl $0xf, %esi
leaq 0x6e20f(%rip), %rdx     # 0xac080
movl $0x107, %ecx            # imm = 0x107
callq 0x158e0
jmp 0x3de9a
jmp 0x3de7f
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x3ddec
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3deab
movq -0x48(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)