// File: /workspace/github_c_makefile_star2_O3/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 0x1fc47(%rip), %rax     # 0x29ee4
cmpl $0x0, (%rax)
je 0xa3b6
leaq 0x1fc3b(%rip), %rax     # 0x29ee8
movq (%rax), %rdi
leaq 0x4917(%rip), %rsi      # 0xebce
xorl %r15d, %r15d
xorl %edx, %edx
xorl %eax, %eax
callq 0x4680
movq %rax, %rbx
leaq 0x41bf(%rip), %rsi      # 0xe48c
movq %rax, %rdi
callq 0x4260
testq %rax, %rax
je 0xa3bb
movq %rax, %r14
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x10(%rsp), %rsi
movq %r15, (%rsi)
movq %rax, %rdx
callq 0x4630
cmpq $-0x1, %rax
je 0xa3e5
movabsq $0x6c6c696b5f6d6f6f, %rbp # imm = 0x6C6C696B5F6D6F6F
leaq 0x8(%rsp), %r15
leaq 0x10(%rsp), %r12
cmpq $0xb, %rax
jl 0xa33c
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
xorq %rbp, %rax
movzbl 0x8(%rdi), %ecx
xorq $0x20, %rcx
orq %rax, %rcx
jne 0xa347
movl $0x9, %eax
jmp 0xa354
cmpq $0x6, %rax
jl 0xa38f
movq 0x8(%rsp), %rdi
cmpl $0x206d6f6f, (%rdi)     # imm = 0x206D6F6F
jne 0xa38f
movl $0x4, %eax
movq %rax, 0x10(%rsp)
addq %rax, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x44c0
testq %rax, %rax
je 0xa38f
movq %rax, %r13
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, %r13
jne 0xa411
leaq 0xb10a(%rip), %rax      # 0x15494
cmpl $0x0, (%rax)
jne 0xa3a9
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x4630
cmpq $-0x1, %rax
jne 0xa317
jmp 0xa3e2
movq %r15, %rdi
movq %r12, %rsi
callq 0x644b
jmp 0xa38f
xorl %r15d, %r15d
jmp 0xa3ff
leaq 0xb0d2(%rip), %rax      # 0x15494
movl $0x1, %r15d
cmpl $0x0, (%rax)
je 0xa3f7
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x64a8
movl (%r14), %r15d
jmp 0xa3f7
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
callq 0x48e8
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 0x1fbca(%rip), %r13     # 0x29fe8
je 0xa3e5
callq 0xa8af
testl %eax, %eax
jne 0xa3e5
movq %r13, 0x1fbb8(%rip)     # 0x29fe8
jmp 0xa3e5