// File: /workspace/github_c_makefile_star2_O2/containers[P]conmon/src/cgroup.c
// Function: oom_cb_cgroup_v1
static gboolean oom_cb_cgroup_v1(int fd, GIOCondition condition, gpointer user_data)
{
	char *cgroup_event_control_path = (char *)user_data;
	if ((condition & G_IO_IN) == 0) {
		/* End of input */
		close(fd);
		oom_event_fd = -1;
		g_free(cgroup_event_control_path);
		return G_SOURCE_REMOVE;
	}

	/* Attempt to read the container's cgroup path.
	 * if the cgroup.memory_control file does not exist,
	 * we know one of the events on this fd was a cgroup removal
	 */
	gboolean cgroup_removed = FALSE;
	if (access(cgroup_event_control_path, F_OK) < 0) {
		ndebugf("Memory cgroup removal event received");
		cgroup_removed = TRUE;
	}

	/* there are three cases we need to worry about:
	 * oom kill happened (1 event)
	 * cgroup was removed (1 event)
	 * oom kill happened and cgroup was removed (2 events)
	 */
	uint64_t event_count;
	ssize_t num_read = read(fd, &event_count, sizeof(uint64_t));
	if (num_read < 0) {
		nwarn("Failed to read oom event from eventfd");
		return G_SOURCE_CONTINUE;
	}

	if (num_read == 0) {
		close(fd);
		oom_event_fd = -1;
		g_free(cgroup_event_control_path);
		return G_SOURCE_REMOVE;
	}

	if (num_read != sizeof(uint64_t)) {
		nwarn("Failed to read full oom event from eventfd");
		return G_SOURCE_CONTINUE;
	}

	ndebugf("Memory cgroup event count: %ld", (long)event_count);
	if (event_count == 0) {
		nwarn("Unexpected event count (zero) when reading for oom event");
		return G_SOURCE_CONTINUE;
	}

	/* if there's only one event, and the cgroup was removed
	 * we know the event was for a cgroup removal, not an OOM kill
	 */
	if (event_count == 1 && cgroup_removed)
		return G_SOURCE_CONTINUE;

	/* we catch the two other cases here, both of which are OOM kill events */
	ninfo("OOM event received");
	create_oom_files();

	return G_SOURCE_CONTINUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %edi, %ebp
testb $0x1, %sil
jne 0x889d
movl %ebp, %edi
callq 0x4100
orl $-0x1, 0xc4ee(%rip)     # 0x14d7c
movq %r14, %rdi
callq 0x48f0
xorl %ebx, %ebx
jmp 0x8939
movq %r14, %rdi
xorl %esi, %esi
callq 0x4760
movl %eax, %ebx
leaq 0xbbf4(%rip), %r15      # 0x144a4
testl %eax, %eax
jns 0x88be
cmpl $0x3, (%r15)
jae 0x89ce
movq %rsp, %rsi
pushq $0x8
popq %rdx
movl %ebp, %edi
callq 0x4230
testq %rax, %rax
js 0x892c
cmpq $0x8, %rax
je 0x8946
testq %rax, %rax
je 0x8880
pushq $0x1
popq %rbx
cmpl $0x0, (%r15)
je 0x8939
movq 0xb705(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x48a2(%rip), %rsi      # 0xd197
leaq 0x6802(%rip), %rdx      # 0xf0fe
xorl %eax, %eax
callq 0x4830
leaq 0x205ce(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x8939
leaq 0x205ba(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x48b2(%rip), %rsi      # 0xd1d2
leaq 0x67d7(%rip), %rcx      # 0xf0fe
jmp 0x8a61
pushq $0x1
popq %rbx
cmpl $0x0, (%r15)
jne 0x8a1a
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, (%r15)
movq (%rsp), %r14
jae 0x8a70
testq %r14, %r14
je 0x897d
testl %ebx, %ebx
sets %al
cmpq $0x1, %r14
sete %cl
pushq $0x1
popq %rbx
testb %cl, %al
jne 0x8939
cmpl $0x2, (%r15)
jae 0x8abe
callq 0x8b14
jmp 0x8939
pushq $0x1
popq %rbx
cmpl $0x0, (%r15)
je 0x8939
movq 0xb663(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x4800(%rip), %rsi      # 0xd197
leaq 0x67ef(%rip), %rdx      # 0xf18d
xorl %eax, %eax
callq 0x4830
leaq 0x2052c(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x8939
leaq 0x20518(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x4810(%rip), %rsi      # 0xd1d2
leaq 0x67c4(%rip), %rcx      # 0xf18d
jmp 0x8a61
movq 0xb61b(%rip), %rax      # 0x13ff0
movq (%rax), %rcx
leaq 0x6689(%rip), %rdi      # 0xf068
pushq $0x31
popq %rsi
pushq $0x1
popq %rdx
callq 0x4800
leaq 0x204e7(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x88be
leaq 0x204cf(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x668f(%rip), %rsi      # 0xf09a
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x4120
jmp 0x88be
movq 0xb5cf(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x476c(%rip), %rsi      # 0xd197
leaq 0x66a6(%rip), %rdx      # 0xf0d8
xorl %eax, %eax
callq 0x4830
leaq 0x20498(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x8939
leaq 0x20480(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x4778(%rip), %rsi      # 0xd1d2
leaq 0x6677(%rip), %rcx      # 0xf0d8
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x4120
jmp 0x8939
movq 0xb579(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x66a8(%rip), %rsi      # 0xf129
movq %r14, %rdx
xorl %eax, %eax
callq 0x4830
leaq 0x20446(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x8954
leaq 0x2042e(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x66a9(%rip), %rsi      # 0xf155
pushq $0x6
popq %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x4120
jmp 0x8954
movq 0xb52b(%rip), %rax      # 0x13ff0
movq (%rax), %rdi
leaq 0x66f7(%rip), %rsi      # 0xf1c6
leaq 0x6700(%rip), %rdx      # 0xf1d6
xorl %eax, %eax
callq 0x4830
leaq 0x203f4(%rip), %rax     # 0x28ed8
cmpl $0x0, (%rax)
je 0x8976
leaq 0x203dc(%rip), %rax     # 0x28ed0
movq (%rax), %rdx
leaq 0x66eb(%rip), %rsi      # 0xf1e9
leaq 0x66d1(%rip), %rcx      # 0xf1d6
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x4120
jmp 0x8976