// File: /workspace/github_c_makefile_star2_O0/containers[P]conmon/src/cgroup.c
// Function: process_cgroup_subsystem_path
static char *process_cgroup_subsystem_path(int pid, bool cgroup2, const char *subsystem)
{
	_cleanup_free_ char *cgroups_file_path = g_strdup_printf("/proc/%d/cgroup", pid);
	_cleanup_fclose_ FILE *fp = fopen(cgroups_file_path, "re");
	if (fp == NULL) {
		nwarnf("Failed to open cgroups file: %s", cgroups_file_path);
		return NULL;
	}

	_cleanup_free_ char *line = NULL;
	ssize_t read;
	size_t len = 0;
	char *ptr, *path;
	while ((read = getline(&line, &len, fp)) != -1) {
		_cleanup_strv_ char **subsystems = NULL;
		ptr = strchr(line, ':');
		if (ptr == NULL) {
			nwarnf("Error parsing cgroup, ':' not found: %s", line);
			return NULL;
		}
		ptr++;
		path = strchr(ptr, ':');
		if (path == NULL) {
			nwarnf("Error parsing cgroup, second ':' not found: %s", line);
			return NULL;
		}
		*path = 0;
		path++;
		if (cgroup2) {
			char *subsystem_path = g_strdup_printf("%s%s", CGROUP_ROOT, path);
			subsystem_path[strlen(subsystem_path) - 1] = '\0';
			return subsystem_path;
		}
		subsystems = g_strsplit(ptr, ",", -1);
		for (int i = 0; subsystems[i] != NULL; i++) {
			if (strcmp(subsystems[i], subsystem) == 0) {
				char *subpath = strchr(subsystems[i], '=');
				if (subpath == NULL) {
					subpath = ptr;
				} else {
					*subpath = 0;
				}

				char *subsystem_path = g_strdup_printf("%s/%s%s", CGROUP_ROOT, subpath, path);
				subsystem_path[strlen(subsystem_path) - 1] = '\0';
				return subsystem_path;
			}
		}
	}

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %sil, %al
movl %edi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %esi
leaq 0x73d6(%rip), %rdi      # 0x110fa
movb $0x0, %al
callq 0x4380
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x6ab2(%rip), %rsi      # 0x107ec
callq 0x4260
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9dbb
leaq 0xc753(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x9da7
jmp 0x9d58
movq 0xc291(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x71cf(%rip), %rsi      # 0x10f3c
movb $0x0, %al
callq 0x4830
leaq 0x211cd(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9da1
leaq 0x211b9(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
movl $0x6, %edi
leaq 0x71cf(%rip), %rsi      # 0x10f69
movb $0x0, %al
callq 0x4120
jmp 0x9da3
jmp 0x9da5
jmp 0x9da7
movq $0x0, -0x8(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0xa0a3
movq $0x0, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rdx
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x4640
movq %rax, -0x40(%rbp)
cmpq $-0x1, %rax
je 0xa08b
movq $0x0, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movl $0x3a, %esi
callq 0x4560
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x9e7c
leaq 0xc692(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x9e68
jmp 0x9e19
movq 0xc1d0(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x72dc(%rip), %rsi      # 0x1110a
movb $0x0, %al
callq 0x4830
leaq 0x2110c(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9e62
leaq 0x210f8(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x6, %edi
leaq 0x72e4(%rip), %rsi      # 0x1113f
movb $0x0, %al
callq 0x4120
jmp 0x9e64
jmp 0x9e66
jmp 0x9e68
movq $0x0, -0x8(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0xa074
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movl $0x3a, %esi
callq 0x4560
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x9f12
leaq 0xc5fc(%rip), %rax      # 0x164a4
cmpl $0x1, (%rax)
jb 0x9efe
jmp 0x9eaf
movq 0xc13a(%rip), %rax      # 0x15ff0
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x72bb(%rip), %rsi      # 0x1117f
movb $0x0, %al
callq 0x4830
leaq 0x21076(%rip), %rax     # 0x2af48
cmpl $0x0, (%rax)
je 0x9ef8
leaq 0x21062(%rip), %rax     # 0x2af40
movq (%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x6, %edi
leaq 0x72ca(%rip), %rsi      # 0x111bb
movb $0x0, %al
callq 0x4120
jmp 0x9efa
jmp 0x9efc
jmp 0x9efe
movq $0x0, -0x8(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0xa074
movq -0x58(%rbp), %rax
movb $0x0, (%rax)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
testb $0x1, -0xd(%rbp)
je 0x9f82
movq -0x58(%rbp), %rdx
leaq 0x72d1(%rip), %rdi      # 0x11207
leaq 0x6fe2(%rip), %rsi      # 0x10f1f
movb $0x0, %al
callq 0x4380
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4360
movq %rax, %rcx
movq -0x88(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0xa074
movq -0x50(%rbp), %rdi
leaq 0x7275(%rip), %rsi      # 0x11202
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4660
movq %rax, -0x60(%rbp)
movl $0x0, -0x6c(%rbp)
movq -0x60(%rbp), %rax
movslq -0x6c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0xa06d
movq -0x60(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
callq 0x4620
cmpl $0x0, %eax
jne 0xa05d
movq -0x60(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl $0x3d, %esi
callq 0x4560
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x9ffe
movq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0xa005
movq -0x78(%rbp), %rax
movb $0x0, (%rax)
movq -0x78(%rbp), %rdx
movq -0x58(%rbp), %rcx
leaq 0x71f0(%rip), %rdi      # 0x11204
leaq 0x6f04(%rip), %rsi      # 0x10f1f
movb $0x0, %al
callq 0x4380
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rdi
callq 0x4360
movq %rax, %rcx
movq -0x90(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0xa074
jmp 0xa05f
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x9fa2
movl $0x0, -0x2c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xa210
movl -0x2c(%rbp), %eax
testl %eax, %eax
jne 0xa09a
jmp 0xa086
jmp 0x9dcb
movq $0x0, -0x8(%rbp)
movl $0x1, -0x2c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9ca0
leaq -0x28(%rbp), %rdi
callq 0x9cc0
leaq -0x20(%rbp), %rdi
callq 0x9ca0
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)