// File: establishment[P]sandman/src/rules.hpp
// Function: Rules::DiskQuota::findDevice(char const*)
static char* findDevice(const char* path) {
            FILE* f = setmntent("/proc/mounts", "r");
            if (!f)
                Die("Cannot open /proc/mounts: %m");

            struct mntent* me;
            int best_len = 0;
            char* best_dev = NULL;
            while ((me = getmntent(f))) {
                if (!Base::PathBeginsWith(me->mnt_fsname, "/dev"))
                    continue;

                if (Base::PathBeginsWith(path, me->mnt_dir)) {
                    int len = strlen(me->mnt_dir);
                    if (len > best_len) {
                        best_len = len;
                        free(best_dev);
                        best_dev = strdup(me->mnt_fsname);
                    }
                }
            }
            endmntent(f);
            return best_dev;
        }

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
leaq 0x2dd28(%rip), %rdi     # 0xf68ee
leaq 0x2c5eb(%rip), %rsi     # 0xf51b8
callq 0x8c580
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x118(%rsp)
jne 0xc8bf3
leaq 0x2dd0f(%rip), %rdi     # 0xf68fb
movb $0x0, %al
callq 0x94bf0
movl $0x0, 0x10c(%rsp)
movq $0x0, 0x100(%rsp)
movq 0x118(%rsp), %rdi
callq 0x8c6f0
movq %rax, 0x110(%rsp)
cmpq $0x0, %rax
je 0xc8eff
movq 0x110(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
leaq 0xdf(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x8ca50
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0xe0(%rsp), %rdi
callq 0xa0a90
jmp 0xc8c64
leaq 0xa7(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x8ca50
movq 0x38(%rsp), %rdx
leaq 0x2dc96(%rip), %rsi     # 0xf6918
leaq 0xa8(%rsp), %rdi
callq 0xa0a90
jmp 0xc8c91
leaq 0xe0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x94f90
movl %eax, 0x34(%rsp)
jmp 0xc8cac
movl 0x34(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, 0x33(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x8cbd8
leaq 0xa7(%rsp), %rdi
callq 0x8c630
leaq 0xe0(%rsp), %rdi
callq 0x8cbd8
leaq 0xdf(%rsp), %rdi
callq 0x8c630
movb 0x33(%rsp), %al
testb $0x1, %al
jne 0xc8cfa
jmp 0xc8d78
jmp 0xc8c0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xc8d66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xc8d4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x8cbd8
leaq 0xa7(%rsp), %rdi
callq 0x8c630
leaq 0xe0(%rsp), %rdi
callq 0x8cbd8
leaq 0xdf(%rsp), %rdi
callq 0x8c630
jmp 0xc8f1c
movq 0x120(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x8ca50
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x80(%rsp), %rdi
callq 0xa0a90
jmp 0xc8dad
movq 0x110(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x57(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x8ca50
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x58(%rsp), %rdi
callq 0xa0a90
jmp 0xc8de3
leaq 0x80(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x94f90
movl %eax, 0xc(%rsp)
jmp 0xc8dfb
leaq 0x58(%rsp), %rdi
callq 0x8cbd8
leaq 0x57(%rsp), %rdi
callq 0x8c630
leaq 0x80(%rsp), %rdi
callq 0x8cbd8
leaq 0x7f(%rsp), %rdi
callq 0x8c630
movl 0xc(%rsp), %eax
cmpl $0x0, %eax
je 0xc8efa
movq 0x110(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x8c230
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jle 0xc8ef8
movl 0x50(%rsp), %eax
movl %eax, 0x10c(%rsp)
movq 0x100(%rsp), %rdi
callq 0x8c6e0
movq 0x110(%rsp), %rax
movq (%rax), %rdi
callq 0x8cab0
movq %rax, 0x100(%rsp)
jmp 0xc8ef8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xc8eec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xc8ed5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x8cbd8
leaq 0x57(%rsp), %rdi
callq 0x8c630
leaq 0x80(%rsp), %rdi
callq 0x8cbd8
leaq 0x7f(%rsp), %rdi
callq 0x8c630
jmp 0xc8f1c
jmp 0xc8efa
jmp 0xc8c0a
movq 0x118(%rsp), %rdi
callq 0x8c080
movq 0x100(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
retq
movq 0xd0(%rsp), %rdi
callq 0x8ca40
nopl (%rax)