// File: /workspace/github_c_makefile_star2_O0/igaw[P]jitterdebugger/jd_sysinfo.c
// Function: store_system_info
void store_system_info(const char *path, struct system_info *sysinfo)
{
	char *buf;
	FILE *fd;
	unsigned int len;

	jd_cp("/proc/cmdline", path);
	jd_cp("/proc/config.gz", path);
	jd_cp("/proc/cpuinfo", path);
	jd_cp("/proc/interrupts", path);
	jd_cp("/proc/sched_debug", path);

	// cpus_online
	fd = jd_fopen(path, "cpus_online", "w");
	if (!fd)
		return;
	fprintf(fd, "%d\n", sysinfo->cpus_online);
	fclose(fd);

	// uname
	fd = jd_fopen(path, "uname", "w");
	if (!fd)
		return;
	fprintf(fd, "%s %s %s %s %s\n",
		sysinfo->sysname,
		sysinfo->nodename,
		sysinfo->release,
		sysinfo->version,
		sysinfo->machine);
	fclose(fd);

	// dmesg
	len = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
	buf = malloc(len * sizeof(char));
	if (!buf)
		err_handler(errno, "malloc()");

	if (klogctl(SYSLOG_ACTION_READ_ALL, buf, len) < 0)
		return;

	fd = jd_fopen(path, "dmesg", "w");
	if (!fd) {
		free(buf);
		return;
	}

	if (fwrite(buf, sizeof(char), len, fd) != len)
		warn_handler("writing dmesg failed\n");

	fclose(fd);
	free(buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x1610(%rip), %rdi      # 0x72cb
callq 0x5830
movq -0x8(%rbp), %rsi
leaq 0x160e(%rip), %rdi      # 0x72d9
callq 0x5830
movq -0x8(%rbp), %rsi
leaq 0x160e(%rip), %rdi      # 0x72e9
callq 0x5830
movq -0x8(%rbp), %rsi
leaq 0x160c(%rip), %rdi      # 0x72f7
callq 0x5830
movq -0x8(%rbp), %rsi
leaq 0x160d(%rip), %rdi      # 0x7308
callq 0x5830
movq -0x8(%rbp), %rdi
leaq 0x160f(%rip), %rsi      # 0x731a
leaq 0x7b8(%rip), %rdx       # 0x64ca
callq 0x5780
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5d27
jmp 0x5e9f
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x28(%rax), %edx
leaq 0x1527(%rip), %rsi      # 0x7260
movb $0x0, %al
callq 0x2220
movq -0x20(%rbp), %rdi
callq 0x2100
movq -0x8(%rbp), %rdi
leaq 0x15d2(%rip), %rsi      # 0x7326
leaq 0x76f(%rip), %rdx       # 0x64ca
callq 0x5780
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5d70
jmp 0x5e9f
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x18(%rax), %r9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
leaq 0x158a(%rip), %rsi      # 0x732c
movq %rax, (%rsp)
movb $0x0, %al
callq 0x2220
movq -0x20(%rbp), %rdi
callq 0x2100
movl $0xa, %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x22c0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x2290
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5e09
jmp 0x5de4
callq 0x2060
movl (%rax), %edi
leaq 0x66b(%rip), %rsi       # 0x645d
leaq 0x146b(%rip), %rdx      # 0x7264
leaq 0x153c(%rip), %rcx      # 0x733c
movb $0x0, %al
callq 0x4d50
jmp 0x5e09
movq -0x18(%rbp), %rsi
movl -0x24(%rbp), %edx
movl $0x3, %edi
callq 0x22c0
cmpl $0x0, %eax
jge 0x5e21
jmp 0x5e9f
movq -0x8(%rbp), %rdi
leaq 0x1522(%rip), %rsi      # 0x734e
leaq 0x697(%rip), %rdx       # 0x64ca
callq 0x5780
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5e4e
movq -0x18(%rbp), %rdi
callq 0x2040
jmp 0x5e9f
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq -0x20(%rbp), %rcx
movl $0x1, %esi
callq 0x23b0
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x5e8d
jmp 0x5e6f
leaq 0x14de(%rip), %rdi      # 0x7354
leaq 0x13e7(%rip), %rsi      # 0x7264
leaq 0x14b8(%rip), %rdx      # 0x733c
movb $0x0, %al
callq 0x4e40
jmp 0x5e8d
movq -0x20(%rbp), %rdi
callq 0x2100
movq -0x18(%rbp), %rdi
callq 0x2040
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)