// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
leaq 0x1fa5c(%rip), %rax     # 0x29ee4
cmpl $0x0, (%rax)
je 0xa5a3
leaq 0x1fa50(%rip), %rax     # 0x29ee8
movq (%rax), %rdi
leaq 0x474c(%rip), %rsi      # 0xebee
xorl %r15d, %r15d
xorl %edx, %edx
xorl %eax, %eax
callq 0x4680
movq %rax, %rbx
leaq 0x3ff4(%rip), %rsi      # 0xe4ac
movq %rax, %rdi
callq 0x4260
movq %rax, %r14
testq %rax, %rax
je 0xa5a8
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x10(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, %rdx
callq 0x4630
cmpq $-0x1, %rax
je 0xa5d2
movabsq $0x6c6c696b5f6d6f6f, %rbp # imm = 0x6C6C696B5F6D6F6F
leaq 0x8(%rsp), %r15
leaq 0x10(%rsp), %r12
cmpq $0xb, %rax
jl 0xa520
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
xorq %rbp, %rdx
movzbl 0x8(%rcx), %ecx
xorq $0x20, %rcx
orq %rdx, %rcx
je 0xa53a
cmpq $0x6, %rax
jl 0xa57c
movq 0x8(%rsp), %rax
cmpl $0x206d6f6f, (%rax)     # imm = 0x206D6F6F
jne 0xa57c
movl $0x4, %edi
jmp 0xa53f
movl $0x9, %edi
movq %rdi, 0x10(%rsp)
addq 0x8(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x44c0
testq %rax, %rax
je 0xa57c
movq %rax, %r13
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, %r13
jne 0xa603
leaq 0xaf1d(%rip), %rax      # 0x15494
cmpl $0x0, (%rax)
jne 0xa596
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x4630
cmpq $-0x1, %rax
jne 0xa502
jmp 0xa5cf
movq %r15, %rdi
movq %r12, %rsi
callq 0x64b4
jmp 0xa57c
xorl %r15d, %r15d
jmp 0xa5f1
leaq 0xaee5(%rip), %rax      # 0x15494
movl $0x1, %r15d
cmpl $0x0, (%rax)
je 0xa5dc
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6511
movl (%r15), %r15d
jmp 0xa5dc
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
callq 0x48e8
testq %r14, %r14
je 0xa5e9
movq %r14, %rdi
callq 0x46b0
movq %rbx, %rdi
callq 0x48e8
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r15d
cmpq 0x1f9d8(%rip), %r13     # 0x29fe8
je 0xa5d2
callq 0xaa9a
testl %eax, %eax
jne 0xa5d2
movq %r13, 0x1f9c6(%rip)     # 0x29fe8
jmp 0xa5d2