// File: /workspace/github_c_makefile_star2_O2/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, 0x18(%rsp)
testq %rsi, %rsi
je 0xc1159
cmpw $0x0, 0x2(%r14)
je 0xc1159
movq 0x8(%r14), %rax
movq %rax, 0x18(%rsp)
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0xc1161
movl $0x0, 0x14(%rsp)
cmpb $0x0, (%rbx)
je 0xc117a
leaq 0x42eb2(%rip), %rsi     # 0x10401f
movq %rbx, %rdi
callq 0x5a1d0
movq %rax, %r12
jmp 0xc1184
movq 0xa06af(%rip), %rax     # 0x161830
movq (%rax), %r12
testq %r12, %r12
je 0xc144b
movq 0xa069c(%rip), %rax     # 0x161830
cmpq (%rax), %r12
leaq 0x42ea4(%rip), %rdx     # 0x104042
movq %rbx, 0x28(%rsp)
cmovneq %rbx, %rdx
leaq 0x42e74(%rip), %rsi     # 0x104022
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0xc34c6
leaq 0x42e8a(%rip), %rsi     # 0x104049
leaq 0x42d5e(%rip), %rdx     # 0x103f24
movq %r12, %rdi
xorl %eax, %eax
callq 0x56930
movl 0x14(%rsp), %eax
xorb $0x1, %al
movb %al, 0x13(%rsp)
leaq 0x42f17(%rip), %r15     # 0x1040f8
leaq 0x42eed(%rip), %r13     # 0x1040d5
leaq 0x42ec1(%rip), %rbp     # 0x1040b0
xorl %eax, %eax
xorl %ecx, %ecx
movq %r14, 0x30(%rsp)
testb $0x1, %al
jne 0xc1435
movl %ecx, 0x24(%rsp)
cmpb $0x0, 0x14(%rsp)
je 0xc1246
movzwl 0x24(%rsp), %ebx
pushq $0x2
popq %rdi
leaq 0x42e3b(%rip), %rsi     # 0x104055
movl %ebx, %edx
xorl %eax, %eax
callq 0xc34c6
movq %r12, %rdi
leaq 0x42e4d(%rip), %rsi     # 0x10407a
movl %ebx, %edx
xorl %eax, %eax
callq 0x56930
imulq $0x580, %rbx, %rax      # imm = 0x580
addq 0x8(%r14), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
leaq 0xc(%rax), %r14
xorl %ebx, %ebx
cmpq $0x20, %rbx
je 0xc1281
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 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc1251
movq 0x18(%rsp), %rax
leaq 0x20c(%rax), %r14
xorl %ebx, %ebx
cmpq $0x20, %rbx
je 0xc12bf
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 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc128f
movq 0x18(%rsp), %rax
leaq 0x40c(%rax), %r14
xorl %ebx, %ebx
cmpq $0x8, %rbx
je 0xc12fd
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 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc12cd
movq 0x18(%rsp), %rax
leaq 0x48c(%rax), %r14
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0xc133f
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
leaq 0x42dee(%rip), %rsi     # 0x10411b
movl %ebx, %edx
xorl %eax, %eax
callq 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc130b
movq 0x18(%rsp), %rax
leaq 0x4cc(%rax), %r14
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0xc1381
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
leaq 0x42dd0(%rip), %rsi     # 0x10413f
movl %ebx, %edx
xorl %eax, %eax
callq 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc134d
movq 0x18(%rsp), %rax
leaq 0x50c(%rax), %r14
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0xc13c3
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
leaq 0x42db3(%rip), %rsi     # 0x104164
movl %ebx, %edx
xorl %eax, %eax
callq 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc138f
movq 0x18(%rsp), %rax
leaq 0x54c(%rax), %r14
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0xc1405
movl -0xc(%r14), %ecx
movl -0x8(%r14), %r8d
movl -0x4(%r14), %r9d
movl (%r14), %eax
movl %eax, (%rsp)
movq %r12, %rdi
leaq 0x42d96(%rip), %rsi     # 0x104189
movl %ebx, %edx
xorl %eax, %eax
callq 0x56930
incq %rbx
addq $0x10, %r14
jmp 0xc13d1
movl 0x24(%rsp), %ecx
incl %ecx
movb 0x13(%rsp), %al
cmpb $0x0, 0x14(%rsp)
movq 0x30(%rsp), %r14
je 0xc11f8
movb $0x1, %al
cmpw 0x2(%r14), %cx
jae 0xc11f8
movb 0x13(%rsp), %al
jmp 0xc11f8
xorl %ebx, %ebx
movq 0x28(%rsp), %rax
cmpb $0x0, (%rax)
je 0xc144e
movq %r12, %rdi
callq 0x575b0
jmp 0xc144e
pushq $-0x4
popq %rbx
leaq 0x9fedb(%rip), %rdi     # 0x161330
callq 0x57820
movl %ebx, 0x30(%rax)
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq