// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libcpuid/cpuid_main.c
// Function: cpuid_serialize_raw_data_internal
static int cpuid_serialize_raw_data_internal(struct cpu_raw_data_t* single_raw, struct cpu_raw_data_array_t* raw_array, const char* filename)
{
	int i;
	bool end_loop = false;
	const bool use_raw_array = (raw_array != NULL) && raw_array->num_raw > 0;
	logical_cpu_t logical_cpu = 0;
	struct cpu_raw_data_t* raw_ptr = use_raw_array ? &raw_array->raw[0] : single_raw;
	FILE *f;

	/* Open file descriptor */
	f = !strcmp(filename, "") ? stdout : fopen(filename, "wt");
	if (!f)
		return cpuid_set_error(ERR_OPEN);
	debugf(1, "Writing raw CPUID dump to '%s'\n", f == stdout ? "stdout" : filename);

	/* Write raw data to output file */
	fprintf(f, "version=%s\n", VERSION);
	while (!end_loop) {
		if (use_raw_array) {
			debugf(2, "Writing raw dump for logical CPU %i\n", logical_cpu);
			fprintf(f, "\n_________________ Logical CPU #%i _________________\n", logical_cpu);
			raw_ptr = &raw_array->raw[logical_cpu];
		}
		for (i = 0; i < MAX_CPUID_LEVEL; i++)
			fprintf(f, "basic_cpuid[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->basic_cpuid[i][EAX], raw_ptr->basic_cpuid[i][EBX],
				raw_ptr->basic_cpuid[i][ECX], raw_ptr->basic_cpuid[i][EDX]);
		for (i = 0; i < MAX_EXT_CPUID_LEVEL; i++)
			fprintf(f, "ext_cpuid[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->ext_cpuid[i][EAX], raw_ptr->ext_cpuid[i][EBX],
				raw_ptr->ext_cpuid[i][ECX], raw_ptr->ext_cpuid[i][EDX]);
		for (i = 0; i < MAX_INTELFN4_LEVEL; i++)
			fprintf(f, "intel_fn4[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->intel_fn4[i][EAX], raw_ptr->intel_fn4[i][EBX],
				raw_ptr->intel_fn4[i][ECX], raw_ptr->intel_fn4[i][EDX]);
		for (i = 0; i < MAX_INTELFN11_LEVEL; i++)
			fprintf(f, "intel_fn11[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->intel_fn11[i][EAX], raw_ptr->intel_fn11[i][EBX],
				raw_ptr->intel_fn11[i][ECX], raw_ptr->intel_fn11[i][EDX]);
		for (i = 0; i < MAX_INTELFN12H_LEVEL; i++)
			fprintf(f, "intel_fn12h[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->intel_fn12h[i][EAX], raw_ptr->intel_fn12h[i][EBX],
				raw_ptr->intel_fn12h[i][ECX], raw_ptr->intel_fn12h[i][EDX]);
		for (i = 0; i < MAX_INTELFN14H_LEVEL; i++)
			fprintf(f, "intel_fn14h[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->intel_fn14h[i][EAX], raw_ptr->intel_fn14h[i][EBX],
				raw_ptr->intel_fn14h[i][ECX], raw_ptr->intel_fn14h[i][EDX]);
		for (i = 0; i < MAX_AMDFN8000001DH_LEVEL; i++)
			fprintf(f, "amd_fn8000001dh[%d]=%08x %08x %08x %08x\n", i,
				raw_ptr->amd_fn8000001dh[i][EAX], raw_ptr->amd_fn8000001dh[i][EBX],
				raw_ptr->amd_fn8000001dh[i][ECX], raw_ptr->amd_fn8000001dh[i][EDX]);
		logical_cpu++;
		end_loop = ((use_raw_array && (logical_cpu >= raw_array->num_raw)) || !use_raw_array);
	}

	/* Close file descriptor */
	if (strcmp(filename, ""))
		fclose(f);
	return cpuid_set_error(ERR_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
testq %rsi, %rsi
je 0xc860f
cmpw $0x0, 0x2(%r14)
setne %al
jmp 0xc8611
xorl %eax, %eax
testb %al, %al
je 0xc861e
movq 0x8(%r14), %rcx
movq %rcx, 0x10(%rsp)
movl %eax, 0x1c(%rsp)
cmpb $0x0, (%rbx)
je 0xc863b
leaq 0x4c951(%rip), %rsi     # 0x114f7f
movq %rbx, %rdi
callq 0x58e70
movq %rax, %r12
jmp 0xc8645
movq 0xa41ee(%rip), %rax     # 0x16c830
movq (%rax), %r12
testq %r12, %r12
je 0xc88ef
movq 0xa41db(%rip), %rax     # 0x16c830
cmpq (%rax), %r12
leaq 0x4c943(%rip), %rdx     # 0x114fa2
movq %rbx, 0x20(%rsp)
cmovneq %rbx, %rdx
leaq 0x4c913(%rip), %rsi     # 0x114f82
movl $0x1, %edi
xorl %eax, %eax
callq 0xcaa16
leaq 0x4c927(%rip), %rsi     # 0x114fa9
leaq 0x4c7fb(%rip), %rdx     # 0x114e84
movq %r12, %rdi
xorl %eax, %eax
callq 0x558d0
leaq 0x4ca2a(%rip), %r13     # 0x1150c4
leaq 0x4ca48(%rip), %rbp     # 0x1150e9
xorl %ebx, %ebx
movl 0x1c(%rsp), %ecx
movq %r14, 0x28(%rsp)
testb %cl, %cl
je 0xc86e8
movl $0x2, %edi
leaq 0x4c8f9(%rip), %rsi     # 0x114fb5
movl %ebx, %edx
xorl %eax, %eax
callq 0xcaa16
movq %r12, %rdi
leaq 0x4c90b(%rip), %rsi     # 0x114fda
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
imulq $0x580, %rbx, %rax      # imm = 0x580
addq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
movq %rbx, 0x30(%rsp)
movq 0x10(%rsp), %rax
leaq 0xc(%rax), %r14
xorl %ebx, %ebx
leaq 0x4c911(%rip), %r15     # 0x115010
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x20, %rbx
jne 0xc86ff
movq 0x10(%rsp), %rax
leaq 0x20c(%rax), %r14
xorl %ebx, %ebx
leaq 0x4c8f3(%rip), %r15     # 0x115035
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x20, %rbx
jne 0xc8742
movq 0x10(%rsp), %rax
leaq 0x40c(%rax), %r14
xorl %ebx, %ebx
leaq 0x4c8d3(%rip), %r15     # 0x115058
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x8, %rbx
jne 0xc8785
movq 0x10(%rsp), %rax
leaq 0x48c(%rax), %r14
xorl %ebx, %ebx
leaq 0x4c8b3(%rip), %r15     # 0x11507b
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x4, %rbx
jne 0xc87c8
movq 0x10(%rsp), %rax
leaq 0x4cc(%rax), %r14
xorl %ebx, %ebx
leaq 0x4c894(%rip), %r15     # 0x11509f
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x4, %rbx
jne 0xc880b
movq 0x10(%rsp), %rax
leaq 0x50c(%rax), %r14
xorl %ebx, %ebx
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x4, %rbx
jne 0xc8847
movq 0x10(%rsp), %rax
leaq 0x54c(%rax), %r14
xorl %ebx, %ebx
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x558d0
incq %rbx
addq $0x10, %r14
cmpq $0x4, %rbx
jne 0xc8883
movl 0x1c(%rsp), %ecx
testb %cl, %cl
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %rbx
je 0xc88d9
incq %rbx
movzwl 0x2(%r14), %eax
cmpq %rax, %rbx
setb %al
testb %cl, %al
jne 0xc86ac
xorl %ebx, %ebx
movq 0x20(%rsp), %rax
cmpb $0x0, (%rax)
je 0xc88f4
movq %r12, %rdi
callq 0x564b0
jmp 0xc88f4
movl $0xfffffffc, %ebx       # imm = 0xFFFFFFFC
leaq 0xa3a35(%rip), %rdi     # 0x16c330
callq 0x566e0
movl %ebx, 0x30(%rax)
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq