// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/common/type.c
// Function: subtilis_type_rec_add_field
void subtilis_type_rec_add_field(subtilis_type_t *dst, const char *name,
				 const subtilis_type_t *field,
				 uint32_t alignment, uint32_t size,
				 int32_t vec_dim, subtilis_error_t *err)
{
	size_t new_max;
	subtilis_type_t *new_field_types;
	subtilis_type_field_t *new_fields;
	subtilis_type_rec_t *rec = &dst->params.rec;

	/*
	 * Alignment must be a power of 2.
	 */

	if ((alignment == 0) || (alignment & (alignment - 1))) {
		subtilis_error_set_assertion_failed(err);
		return;
	}

	if (subtilis_type_rec_find_field(rec, name) != SIZE_MAX) {
		subtilis_error_set_type_already_defined(err);
		return;
	}

	if (rec->max_fields == rec->num_fields) {
		new_max = rec->max_fields + SUBTILIS_FIELD_GRANULARITY;
		new_field_types = realloc(rec->field_types,
					  new_max * sizeof(*new_field_types));
		if (!new_field_types) {
			subtilis_error_set_oom(err);
			return;
		}
		new_fields =
		    realloc(rec->fields, new_max * sizeof(*new_fields));
		if (!new_fields) {
			free(new_fields);
			subtilis_error_set_oom(err);
			return;
		}
		rec->field_types = new_field_types;
		rec->fields = new_fields;
		rec->max_fields = new_max;
	}
	rec->fields[rec->num_fields].name = malloc(strlen(name) + 1);
	if (!rec->fields[rec->num_fields].name) {
		subtilis_error_set_oom(err);
		return;
	}
	strcpy(rec->fields[rec->num_fields].name, name);
	rec->fields[rec->num_fields].alignment = alignment;
	rec->fields[rec->num_fields].size = size;
	rec->fields[rec->num_fields].vec_dim = vec_dim;
	if (rec->alignment < alignment)
		rec->alignment = alignment;

	subtilis_type_init_copy(&rec->field_types[rec->num_fields], field, err);
	if (err->type != SUBTILIS_ERROR_OK) {
		free(rec->fields[rec->num_fields].name);
		return;
	}
	rec->num_fields++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r12d
movq 0x60(%rsp), %rbx
leal -0x1(%r12), %eax
xorl %eax, %ecx
cmpl %eax, %ecx
jbe 0x2ff98
movl %r9d, %r13d
movq %rsi, %r15
movq %rdi, %r14
movq %rdx, 0x20(%rsp)
movl %r8d, 0xc(%rsp)
leaq 0x8(%rdi), %rbp
movq %rbp, %rdi
callq 0x2feeb
cmpq $-0x1, %rax
je 0x2ffbf
leaq 0x4511f(%rip), %rdx     # 0x750a8
movq %rbx, %rdi
movl $0x68, %esi
movl $0x2b1, %ecx            # imm = 0x2B1
jmp 0x2ffac
leaq 0x45109(%rip), %rdx     # 0x750a8
movq %rbx, %rdi
movl $0xf, %esi
movl $0x2ac, %ecx            # imm = 0x2AC
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145f4
movq %rbp, 0x18(%rsp)
movl %r13d, 0x8(%rsp)
movq 0x30(%r14), %r13
cmpq 0x28(%r14), %r13
jne 0x3001d
addq $0x10, %r13
movq 0x18(%r14), %rdi
imulq $0x148, %r13, %rsi      # imm = 0x148
callq 0x12210
testq %rax, %rax
je 0x300d3
movq %rax, %rbp
movq 0x20(%r14), %rdi
leaq (,%r13,8), %rax
leaq (%rax,%rax,2), %rsi
callq 0x12210
testq %rax, %rax
je 0x300ff
movq %rbp, 0x18(%r14)
movq %rax, 0x20(%r14)
movq %r13, 0x30(%r14)
movq %r15, %rdi
callq 0x120f0
leaq 0x1(%rax), %rdi
callq 0x121d0
movq 0x20(%r14), %r13
movq 0x28(%r14), %rcx
leaq (%rcx,%rcx,2), %rbp
movq %rax, (%r13,%rbp,8)
testq %rax, %rax
je 0x300ba
movq %rcx, 0x10(%rsp)
movq %rax, %rdi
movq %r15, %rsi
callq 0x12070
movl %r12d, 0x8(%r13,%rbp,8)
movl 0xc(%rsp), %eax
movl %eax, 0xc(%r13,%rbp,8)
movl 0x8(%rsp), %eax
movl %eax, 0x10(%r13,%rbp,8)
movq 0x18(%rsp), %rax
cmpl %r12d, (%rax)
jae 0x30078
movl %r12d, (%rax)
imulq $0x148, 0x10(%rsp), %rdi # imm = 0x148
addq 0x18(%r14), %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x2f72e
cmpl $0x0, (%rbx)
je 0x300ec
movq 0x20(%r14), %rax
movq 0x28(%r14), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x122c0
leaq 0x44fe7(%rip), %rdx     # 0x750a8
movq %rbx, %rdi
movl $0x1, %esi
movl $0x2ca, %ecx            # imm = 0x2CA
jmp 0x2ffac
leaq 0x44fce(%rip), %rdx     # 0x750a8
movq %rbx, %rdi
movl $0x1, %esi
movl $0x2ba, %ecx            # imm = 0x2BA
jmp 0x2ffac
incq 0x28(%r14)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x44fa2(%rip), %rdx     # 0x750a8
movq %rbx, %rdi
movl $0x1, %esi
movl $0x2c1, %ecx            # imm = 0x2C1
jmp 0x2ffac