// File: /workspace/github_c_makefile_star2_O3/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 0xc76ae
cmpw $0x0, 0x2(%r14)
je 0xc76ae
movq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
movb $0x1, %al
movl %eax, 0x1c(%rsp)
jmp 0xc76b6
movl $0x0, 0x1c(%rsp)
cmpb $0x0, (%rbx)
je 0xc76cf
leaq 0x4cacd(%rip), %rsi     # 0x11418f
movq %rbx, %rdi
callq 0x58e70
movq %rax, %r12
jmp 0xc76d9
movq 0xa415a(%rip), %rax     # 0x16b830
movq (%rax), %r12
testq %r12, %r12
je 0xc797c
movq 0xa4147(%rip), %rax     # 0x16b830
cmpq (%rax), %r12
leaq 0x4cabf(%rip), %rdx     # 0x1141b2
movq %rbx, 0x20(%rsp)
cmovneq %rbx, %rdx
leaq 0x4ca8f(%rip), %rsi     # 0x114192
movl $0x1, %edi
xorl %eax, %eax
callq 0xc9c3a
leaq 0x4caa3(%rip), %rsi     # 0x1141b9
leaq 0x4c977(%rip), %rdx     # 0x114094
movq %r12, %rdi
xorl %eax, %eax
callq 0x558d0
leaq 0x4cba6(%rip), %r13     # 0x1142d4
leaq 0x4cbc4(%rip), %rbp     # 0x1142f9
xorl %ebx, %ebx
movq %r14, 0x28(%rsp)
cmpb $0x0, 0x1c(%rsp)
je 0xc777b
movl $0x2, %edi
leaq 0x4ca76(%rip), %rsi     # 0x1141c5
movl %ebx, %edx
xorl %eax, %eax
callq 0xc9c3a
movq %r12, %rdi
leaq 0x4ca88(%rip), %rsi     # 0x1141ea
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 0x4ca8e(%rip), %r15     # 0x114220
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 0xc7792
movq 0x10(%rsp), %rax
leaq 0x20c(%rax), %r14
xorl %ebx, %ebx
leaq 0x4ca70(%rip), %r15     # 0x114245
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 0xc77d5
movq 0x10(%rsp), %rax
leaq 0x40c(%rax), %r14
xorl %ebx, %ebx
leaq 0x4ca50(%rip), %r15     # 0x114268
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 0xc7818
movq 0x10(%rsp), %rax
leaq 0x48c(%rax), %r14
xorl %ebx, %ebx
leaq 0x4ca30(%rip), %r15     # 0x11428b
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 0xc785b
movq 0x10(%rsp), %rax
leaq 0x4cc(%rax), %r14
xorl %ebx, %ebx
leaq 0x4ca11(%rip), %r15     # 0x1142af
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 0xc789e
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 0xc78da
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 0xc7916
cmpb $0x0, 0x1c(%rsp)
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %rbx
je 0xc7966
incq %rbx
movzwl 0x2(%r14), %eax
cmpq %rax, %rbx
jb 0xc773c
xorl %ebx, %ebx
movq 0x20(%rsp), %rax
cmpb $0x0, (%rax)
je 0xc7981
movq %r12, %rdi
callq 0x564b0
jmp 0xc7981
movl $0xfffffffc, %ebx       # imm = 0xFFFFFFFC
leaq 0xa39a8(%rip), %rdi     # 0x16b330
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