// File: /workspace/github_c_makefile_star2_O0/containers[P]conmon/src/cgroup.c
// Function: setup_oom_handling_cgroup_v1
static void setup_oom_handling_cgroup_v1(int pid)
{
	/* Setup OOM notification for container process */
	_cleanup_free_ char *memory_cgroup_path = process_cgroup_subsystem_path(pid, false, "memory");
	if (!memory_cgroup_path) {
		nwarn("Failed to get memory cgroup path. Container may have exited");
		return;
	}

	/* this will be cleaned up in oom_cb_cgroup_v1 */
	char *memory_cgroup_file_path = g_build_filename(memory_cgroup_path, "cgroup.event_control", NULL);
	_cleanup_close_ int cfd = open(memory_cgroup_file_path, O_WRONLY | O_CLOEXEC);
	if (cfd == -1) {
		nwarnf("Failed to open %s", memory_cgroup_file_path);
		g_free(memory_cgroup_file_path);
		return;
	}

	_cleanup_free_ char *memory_cgroup_file_oom_path = g_build_filename(memory_cgroup_path, "memory.oom_control", NULL);

	oom_cgroup_fd = open(memory_cgroup_file_oom_path, O_RDONLY | O_CLOEXEC); /* Not closed */
	if (oom_cgroup_fd == -1)
		pexitf("Failed to open %s", memory_cgroup_file_oom_path);

	if ((oom_event_fd = eventfd(0, EFD_CLOEXEC)) == -1)
		pexit("Failed to create eventfd");

	_cleanup_free_ char *data = g_strdup_printf("%d %d", oom_event_fd, oom_cgroup_fd);
	if (write_all(cfd, data, strlen(data)) < 0) {
		/* This used to be fatal, but we make it advisory and stumble on because
		 * https://github.com/torvalds/linux/commit/2343e88d238f5de973d609d861c505890f94f22e
		 * disables this interface in PREEMPT_RT kernel configs.
		 */
		nwarnf("Failed to write to cgroup.event_control");
		g_free(memory_cgroup_file_path);
		return;
	}

	g_unix_fd_add(oom_event_fd, G_IO_IN, oom_cb_cgroup_v1, memory_cgroup_file_path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %edi
xorl %esi, %esi
leaq 0x7ff0(%rip), %rdx      # 0x116f7
callq 0x9d00
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x9786
leaq 0xcd86(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x977a
jmp 0x9725
movq 0xc8c4(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x5a61(%rip), %rsi      # 0xf197
leaq 0x7afb(%rip), %rdx      # 0x11238
movb $0x0, %al
callq 0x4830
leaq 0x217fd(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9774
leaq 0x217e9(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x5a6c(%rip), %rsi      # 0xf1d2
leaq 0x7acb(%rip), %rcx      # 0x11238
movb $0x0, %al
callq 0x4120
jmp 0x9776
jmp 0x9778
jmp 0x977a
movl $0x1, -0x14(%rbp)
jmp 0x9a19
movq -0x10(%rbp), %rdi
leaq 0x7ae3(%rip), %rsi      # 0x11274
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x46a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x80001, %esi          # imm = 0x80001
movb $0x0, %al
callq 0x48d0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x982b
leaq 0xcce4(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x9816
jmp 0x97c7
movq 0xc822(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x7aad(%rip), %rsi      # 0x11289
movb $0x0, %al
callq 0x4830
leaq 0x2175e(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9810
leaq 0x2174a(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
movl $0x6, %edi
leaq 0x7a9f(%rip), %rsi      # 0x112a8
movb $0x0, %al
callq 0x4120
jmp 0x9812
jmp 0x9814
jmp 0x9816
movq -0x20(%rbp), %rdi
callq 0x48f0
movl $0x1, -0x14(%rbp)
jmp 0x9a10
movq -0x10(%rbp), %rdi
leaq 0x7a9c(%rip), %rsi      # 0x112d2
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x46a0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x80000, %esi          # imm = 0x80000
movb $0x0, %al
callq 0x48d0
movl %eax, 0xd525(%rip)      # 0x16d80
cmpl $-0x1, 0xd51e(%rip)     # 0x16d80
jne 0x98b9
jmp 0x9866
movq 0xc783(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
leaq 0x7a6a(%rip), %rsi      # 0x112e5
movb $0x0, %al
callq 0x4830
leaq 0x216bf(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x98af
leaq 0x216ab(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
movl $0x3, %edi
leaq 0x7a5f(%rip), %rsi      # 0x11307
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
xorl %edi, %edi
movl $0x80000, %esi          # imm = 0x80000
callq 0x42f0
movl %eax, 0xd4b1(%rip)      # 0x16d7c
cmpl $-0x1, %eax
jne 0x992b
jmp 0x98d2
movq 0xc717(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x5730(%rip), %rsi      # 0xf013
leaq 0x7a4a(%rip), %rdx      # 0x11334
movb $0x0, %al
callq 0x4830
leaq 0x21650(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9921
leaq 0x2163c(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x572a(%rip), %rsi      # 0xf03d
leaq 0x7a1a(%rip), %rcx      # 0x11334
movb $0x0, %al
callq 0x4120
movl $0x1, %edi
callq 0x41e0
movl 0xd44b(%rip), %esi      # 0x16d7c
movl 0xd449(%rip), %edx      # 0x16d80
leaq 0x7a0f(%rip), %rdi      # 0x1134d
movb $0x0, %al
callq 0x4380
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4360
movl -0x44(%rbp), %edi
movq -0x40(%rbp), %rsi
movq %rax, %rdx
callq 0x8c60
cmpq $0x0, %rax
jge 0x99dc
leaq 0xcb28(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x99ca
jmp 0x9983
movq 0xc666(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
leaq 0x79bf(%rip), %rsi      # 0x11353
movb $0x0, %al
callq 0x4830
leaq 0x215a6(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x99c4
leaq 0x21592(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movl $0x6, %edi
leaq 0x79cb(%rip), %rsi      # 0x11388
movb $0x0, %al
callq 0x4120
jmp 0x99c6
jmp 0x99c8
jmp 0x99ca
movq -0x20(%rbp), %rdi
callq 0x48f0
movl $0x1, -0x14(%rbp)
jmp 0x99fe
movl 0xd39a(%rip), %edi      # 0x16d7c
movq -0x20(%rbp), %rcx
movl $0x1, %esi
leaq 0x84e(%rip), %rdx       # 0xa240
callq 0x4440
movl $0x0, -0x14(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9ca0
leaq -0x30(%rbp), %rdi
callq 0x9ca0
leaq -0x24(%rbp), %rdi
callq 0xa0d0
leaq -0x10(%rbp), %rdi
callq 0x9ca0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)