// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
leaq 0x21525(%rip), %rax     # 0x2af64
cmpl $0x0, (%rax)
jne 0x9a50
movl $0x0, -0x4(%rbp)
jmp 0x9c8e
leaq 0x21511(%rip), %rax     # 0x2af68
movq (%rax), %rdi
leaq 0x74cd(%rip), %rsi      # 0x10f2e
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x46a0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6d71(%rip), %rsi      # 0x107ec
callq 0x4260
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x9afb
leaq 0xca12(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x9ae8
jmp 0x9a99
movq 0xc550(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x748e(%rip), %rsi      # 0x10f3c
movb $0x0, %al
callq 0x4830
leaq 0x2148c(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9ae2
leaq 0x21478(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x10(%rbp), %rcx
movl $0x6, %edi
leaq 0x748e(%rip), %rsi      # 0x10f69
movb $0x0, %al
callq 0x4120
jmp 0x9ae4
jmp 0x9ae6
jmp 0x9ae8
movl $0x1, -0x4(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x9c7c
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdx
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4640
movq %rax, -0x38(%rbp)
cmpq $-0x1, %rax
je 0x9c65
movl $0x4, -0x44(%rbp)
movl $0x9, -0x48(%rbp)
cmpq $0xb, -0x38(%rbp)
jl 0x9b63
movq -0x28(%rbp), %rdi
leaq 0x7457(%rip), %rsi      # 0x10fa1
movl $0x9, %edx
callq 0x4680
cmpl $0x0, %eax
jne 0x9b63
movq $0x9, -0x30(%rbp)
jmp 0x9b91
cmpq $0x6, -0x38(%rbp)
jl 0x9b8a
movq -0x28(%rbp), %rax
movl (%rax), %eax
subl $0x206d6f6f, %eax       # imm = 0x206D6F6F
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x9b8a
movq $0x4, -0x30(%rbp)
jmp 0x9b8f
jmp 0x9b0b
jmp 0x9b91
movq -0x28(%rbp), %rdi
addq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x44d0
movq %rax, -0x40(%rbp)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, -0x40(%rbp)
jne 0x9c25
leaq 0xc8e2(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x9c20
jmp 0x9bc9
movq 0xc420(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
addq -0x30(%rbp), %rdx
leaq 0x73ce(%rip), %rsi      # 0x10fb0
movb $0x0, %al
callq 0x4830
leaq 0x21358(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9c1a
leaq 0x21344(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
addq -0x30(%rbp), %rcx
movl $0x6, %edi
leaq 0x73be(%rip), %rsi      # 0x10fd1
movb $0x0, %al
callq 0x4120
jmp 0x9c1c
jmp 0x9c1e
jmp 0x9c20
jmp 0x9b0b
cmpq $0x0, -0x40(%rbp)
jne 0x9c31
jmp 0x9b0b
movq -0x40(%rbp), %rax
cmpq 0x2142c(%rip), %rax     # 0x2b068
je 0x9c55
callq 0xa590
cmpl $0x0, %eax
jne 0x9c53
movq -0x40(%rbp), %rax
movq %rax, 0x21415(%rip)     # 0x2b068
jmp 0x9c55
movl $0x1, -0x4(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x9c73
movl $0x0, -0x4(%rbp)
movl $0x1, -0x1c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x9ca0
leaq -0x18(%rbp), %rdi
callq 0x9cc0
leaq -0x10(%rbp), %rdi
callq 0x9ca0
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)