// File: /workspace/github_c_makefile_star2_O0/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_list_snapshots
int zfs_list_snapshots(char *dataset, char *snapshot, char **output) {
	int status;
	char *snaps = NULL;
	char *cmdline[] = { ZFS_CMD, "list", "-Ho", "name", "-tsnapshot", "-r", dataset, NULL };
	char *suffix;
	char *tok;

	status = executeZfs(1, &snaps, cmdline);
	if (status != 0) {
		fprintf(stderr, "zfs returned %d\n", status);
		return status;
	}
	// Filter
	suffix = malloc((strlen(snapshot) + 2) * sizeof(char));
	strcpy(suffix, "@");
	strcat(suffix, snapshot);

	*output = malloc(sizeof(char));
	strcpy(*output, "");

	tok = strtok(snaps, "\n");
	while (tok != NULL) {
		if (strlen(tok) < strlen(suffix)) {
			continue;
		}
		if (strncmp(tok + strlen(tok) - strlen(suffix), suffix, strlen(suffix)) == 0) {
			*output = realloc(*output, strlen(*output) + strlen(tok) + 2);
			strcat(*output, tok);
			strcat(*output, "\n");
		}
		tok = strtok(NULL, "\n");
	}
	free(suffix);
	free(snaps);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
leaq 0xa1924(%rip), %rax     # 0x4a420a
movq %rax, -0x70(%rbp)
leaq 0xa44a8(%rip), %rax     # 0x4a6d99
movq %rax, -0x68(%rbp)
leaq 0xa1991(%rip), %rax     # 0x4a428d
movq %rax, -0x60(%rbp)
leaq 0xa1939(%rip), %rax     # 0x4a4240
movq %rax, -0x58(%rbp)
leaq 0xa19c4(%rip), %rax     # 0x4a42d6
movq %rax, -0x50(%rbp)
leaq 0xa1992(%rip), %rax     # 0x4a42af
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x70(%rbp), %rdx
movl $0x1, %edi
leaq -0x30(%rbp), %rsi
callq 0x402330
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x402972
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
movl -0x24(%rbp), %edx
leaq 0xa1965(%rip), %rsi     # 0x4a42c5
movb $0x0, %al
callq 0x40cd50
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x402b38
movq -0x18(%rbp), %rdi
callq 0x4010e0
movq %rax, %rdi
addq $0x2, %rdi
shlq $0x0, %rdi
callq 0x421210
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
leaq 0xa16b2(%rip), %rsi     # 0x4a404c
callq 0x401020
movq -0x78(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x401058
movl $0x1, %edi
callq 0x421210
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0xb90ef(%rip), %rsi     # 0x4bbabd
callq 0x401020
movq -0x30(%rbp), %rdi
leaq 0xa1ecc(%rip), %rsi     # 0x4a48aa
callq 0x424430
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x402b1f
movq -0x80(%rbp), %rdi
callq 0x4010e0
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4010e0
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x402a1c
jmp 0x4029e7
movq -0x80(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x80(%rbp), %rdi
callq 0x4010e0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4010e0
movq %rax, %rdx
movq -0xa0(%rbp), %rax
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4010e0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq %rax, %rdx
callq 0x401080
cmpl $0x0, %eax
jne 0x402b06
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x4010e0
movq %rax, -0xb8(%rbp)
movq -0x80(%rbp), %rdi
callq 0x4010e0
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdi
addq %rax, %rsi
addq $0x2, %rsi
callq 0x4218a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x80(%rbp), %rsi
callq 0x401058
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0xa1da9(%rip), %rsi     # 0x4a48aa
callq 0x401058
xorl %eax, %eax
movl %eax, %edi
leaq 0xa1d99(%rip), %rsi     # 0x4a48aa
callq 0x424430
movq %rax, -0x80(%rbp)
jmp 0x4029e7
movq -0x78(%rbp), %rdi
callq 0x421550
movq -0x30(%rbp), %rdi
callq 0x421550
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)