// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xa28c
movl -0x8(%rbp), %edi
callq 0x4100
movl $0xffffffff, 0xcb05(%rip) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rdi
callq 0x48f0
movl $0x0, -0x4(%rbp)
jmp 0xa57a
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x4770
cmpl $0x0, %eax
jge 0xa2fd
leaq 0xc1fa(%rip), %rax      # 0x164a4
cmpl $0x3, (%rax)
jb 0xa2f6
jmp 0xa2b1
movq 0xbd38(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x7106(%rip), %rsi      # 0x113c8
movb $0x0, %al
callq 0x4830
leaq 0x20c78(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa2f2
leaq 0x20c64(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x710f(%rip), %rsi      # 0x113fa
movb $0x0, %al
callq 0x4120
jmp 0xa2f4
jmp 0xa2f6
movl $0x1, -0x24(%rbp)
movl -0x8(%rbp), %edi
leaq -0x30(%rbp), %rsi
movl $0x8, %edx
callq 0x4230
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jge 0xa386
leaq 0xc184(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0xa37a
jmp 0xa327
movq 0xbcc2(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x4e5f(%rip), %rsi      # 0xf197
leaq 0x70f9(%rip), %rdx      # 0x11438
movb $0x0, %al
callq 0x4830
leaq 0x20bfb(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa376
leaq 0x20be7(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x4e6a(%rip), %rsi      # 0xf1d2
leaq 0x70c9(%rip), %rcx      # 0x11438
movb $0x0, %al
callq 0x4120
jmp 0xa378
jmp 0xa37a
movl $0x1, -0x4(%rbp)
jmp 0xa57a
cmpq $0x0, -0x38(%rbp)
jne 0xa3b4
movl -0x8(%rbp), %edi
callq 0x4100
movl $0xffffffff, 0xc9dd(%rip) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rdi
callq 0x48f0
movl $0x0, -0x4(%rbp)
jmp 0xa57a
cmpq $0x8, -0x38(%rbp)
je 0xa428
leaq 0xc0e2(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0xa41c
jmp 0xa3c9
movq 0xbc20(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x4dbd(%rip), %rsi      # 0xf197
leaq 0x707d(%rip), %rdx      # 0x1145e
movb $0x0, %al
callq 0x4830
leaq 0x20b59(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa418
leaq 0x20b45(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x4dc8(%rip), %rsi      # 0xf1d2
leaq 0x704d(%rip), %rcx      # 0x1145e
movb $0x0, %al
callq 0x4120
jmp 0xa41a
jmp 0xa41c
movl $0x1, -0x4(%rbp)
jmp 0xa57a
leaq 0xc075(%rip), %rax      # 0x164a4
cmpl $0x3, (%rax)
jb 0xa483
jmp 0xa436
movq 0xbbb3(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
leaq 0x703e(%rip), %rsi      # 0x11489
movb $0x0, %al
callq 0x4830
leaq 0x20aef(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa47f
leaq 0x20adb(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
movl $0x6, %edi
leaq 0x703d(%rip), %rsi      # 0x114b5
movb $0x0, %al
callq 0x4120
jmp 0xa481
jmp 0xa483
cmpq $0x0, -0x30(%rbp)
jne 0xa4f7
leaq 0xc013(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0xa4eb
jmp 0xa498
movq 0xbb51(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x4cee(%rip), %rsi      # 0xf197
leaq 0x703d(%rip), %rdx      # 0x114ed
movb $0x0, %al
callq 0x4830
leaq 0x20a8a(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa4e7
leaq 0x20a76(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x4cf9(%rip), %rsi      # 0xf1d2
leaq 0x700d(%rip), %rcx      # 0x114ed
movb $0x0, %al
callq 0x4120
jmp 0xa4e9
jmp 0xa4eb
movl $0x1, -0x4(%rbp)
jmp 0xa57a
cmpq $0x1, -0x30(%rbp)
jne 0xa50d
cmpl $0x0, -0x24(%rbp)
je 0xa50d
movl $0x1, -0x4(%rbp)
jmp 0xa57a
leaq 0xbf90(%rip), %rax      # 0x164a4
cmpl $0x2, (%rax)
jb 0xa56e
jmp 0xa51b
movq 0xbace(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x6ffa(%rip), %rsi      # 0x11526
leaq 0x7003(%rip), %rdx      # 0x11536
movb $0x0, %al
callq 0x4830
leaq 0x20a07(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0xa56a
leaq 0x209f3(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x6fed(%rip), %rsi      # 0x11549
leaq 0x6fd3(%rip), %rcx      # 0x11536
movb $0x0, %al
callq 0x4120
jmp 0xa56c
jmp 0xa56e
callq 0xa590
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)