// File: /workspace/github_c_makefile_star2_O2/containers[P]conmon/src/cgroup.c
// Function: check_cgroup2_oom
gboolean check_cgroup2_oom()
{
	static long int last_counter = 0;

	if (!is_cgroup_v2)
		return G_SOURCE_REMOVE;

	_cleanup_free_ char *memory_events_file_path = g_build_filename(cgroup2_path, "memory.events", NULL);

	_cleanup_fclose_ FILE *fp = fopen(memory_events_file_path, "re");
	if (fp == NULL) {
		nwarnf("Failed to open cgroups file: %s", memory_events_file_path);
		return G_SOURCE_CONTINUE;
	}

	_cleanup_free_ char *line = NULL;
	size_t len = 0;
	ssize_t read;
	while ((read = getline(&line, &len, fp)) != -1) {
		long int counter;
		const int oom_len = 4, oom_kill_len = 9;

		if (read >= oom_kill_len + 2 && memcmp(line, "oom_kill ", oom_kill_len) == 0)
			len = oom_kill_len;
		else if (read >= oom_len + 2 && memcmp(line, "oom ", oom_len) == 0)
			len = oom_len;
		else
			continue;

		counter = strtol(&line[len], NULL, 10);

		if (counter == LONG_MAX) {
			nwarnf("Failed to parse: %s", &line[len]);
			continue;
		}

		if (counter == 0)
			continue;

		if (counter != last_counter) {
			if (create_oom_files() == 0)
				last_counter = counter;
		}
		return G_SOURCE_CONTINUE;
	}
	return G_SOURCE_REMOVE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x20c8c(%rip), %rax     # 0x28ef4
cmpl $0x0, (%rax)
je 0x83be
leaq 0x20c80(%rip), %rax     # 0x28ef8
movq (%rax), %rdi
leaq 0x694c(%rip), %rsi      # 0xebce
xorl %edx, %edx
xorl %eax, %eax
callq 0x4690
movq %rax, %rbx
leaq 0x61f7(%rip), %rsi      # 0xe48c
movq %rax, %rdi
callq 0x4260
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x83d7
movq %rax, %r15
movq %rbx, 0x10(%rsp)
leaq 0x8(%rsp), %r12
andq $0x0, (%r12)
leaq 0x18(%rsp), %r13
andq $0x0, (%r13)
pushq $0x9
popq %rbx
pushq $0x4
popq %rbp
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4640
cmpq $-0x1, %rax
je 0x83c3
cmpq $0xb, %rax
jl 0x830b
movq 0x8(%rsp), %r14
movq %r14, %rdi
leaq 0x6947(%rip), %rsi      # 0xec41
movq %rbx, %rdx
callq 0x44c0
movq %rbx, %rcx
testl %eax, %eax
jne 0x8316
jmp 0x8322
cmpq $0x6, %rax
jl 0x82cd
movq 0x8(%rsp), %r14
cmpl $0x206d6f6f, (%r14)     # imm = 0x206D6F6F
movq %rbp, %rcx
jne 0x82cd
movq %rcx, 0x18(%rsp)
addq %rcx, %r14
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x44d0
testq %rax, %rax
je 0x82cd
movq %rax, %r14
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, %r14
jne 0x840b
leaq 0xc14b(%rip), %rax      # 0x144a4
cmpl $0x0, (%rax)
je 0x82cd
movq 0xbc87(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
movq 0x8(%rsp), %rdx
addq 0x18(%rsp), %rdx
leaq 0x68d3(%rip), %rsi      # 0xec50
xorl %eax, %eax
callq 0x4830
leaq 0x20b4d(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x82cd
leaq 0x20b35(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
movq 0x8(%rsp), %rcx
addq 0x18(%rsp), %rcx
pushq $0x6
popq %rdi
leaq 0x68bf(%rip), %rsi      # 0xec71
xorl %eax, %eax
callq 0x4120
jmp 0x82cd
xorl %r15d, %r15d
jmp 0x83f9
movq 0x10(%rsp), %rbx
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
callq 0x48f8
jmp 0x83e7
leaq 0xc0c6(%rip), %rax      # 0x144a4
pushq $0x1
popq %r15
cmpl $0x0, (%rax)
jne 0x8436
leaq 0x20(%rsp), %rdi
callq 0x8480
movq %rbx, %rdi
callq 0x48f8
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %r15
cmpq 0x20be2(%rip), %r14     # 0x28ff8
jne 0x841f
movq 0x10(%rsp), %rbx
jmp 0x83cb
callq 0x8b14
testl %eax, %eax
movq 0x10(%rsp), %rbx
jne 0x83cb
movq %r14, 0x20bc4(%rip)     # 0x28ff8
jmp 0x83cb
movq 0xbbb3(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x6795(%rip), %rsi      # 0xebdc
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4830
leaq 0x20a80(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x83e7
leaq 0x20a6c(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x679b(%rip), %rsi      # 0xec09
pushq $0x6
popq %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x4120
jmp 0x83e7