// File: /workspace/github_c_makefile_star2_O3/nerves-project[P]nerves_initramfs/src/rootdisk.c
// Function: create_rootdisk_symlinks
void create_rootdisk_symlinks(const char *rootfs_devname)
{
    struct block_device_info *infos = scan_for_block_devices();

    dev_t rootfs_dev = rootfs_device(rootfs_devname);
    if (rootfs_dev == 0)
        return;

    struct block_device_info *rootfs_info = NULL;
    for (struct block_device_info *i = infos; i != NULL; i = i->next) {
        if (i->dev == rootfs_dev) {
            rootfs_info = i;
            break;
        }
    }

    if (!rootfs_info || !rootfs_info->parent) {
        info("Root disk is supposed to be %s, but it wasn't found or wasn't a partition.", rootfs_devname);
        return;
    }

    struct block_device_info *rootdisk_info = rootfs_info->parent;

    // Create the main disk's symlink.
    create_dev_symlink("0", rootdisk_info->name);

    // Create all of the partition symlinks (of which one will be the rootfs).
    for (struct block_device_info *i = infos; i != NULL; i = i->next) {
        if (i->parent == rootdisk_info) {
            char partition_suffix[8];
            snprintf(partition_suffix, sizeof(partition_suffix), "0p%d", i->partition_number);
            create_dev_symlink(partition_suffix, i->name);
        }
    }

    free_block_device_info(infos);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %r14
leaq 0x262e(%rip), %rdi      # 0xa999
leaq 0x3e4(%rip), %rdx       # 0x8756
movq 0x5c57(%rip), %rcx      # 0xdfd0
leaq 0x10(%rsp), %rsi
callq 0x2260
movl %eax, %ebx
testl %eax, %eax
jle 0x85a1
movq %r14, 0x20(%rsp)
movl %ebx, %r14d
xorl %ebx, %ebx
xorl %r13d, %r13d
movq %r14, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq (%rax,%rbx,8), %rsi
addq $0x13, %rsi
leaq 0x25e6(%rip), %rdi      # 0xa999
callq 0x8760
testq %rax, %rax
je 0x8576
movq %rax, %rbp
movl $0x28, %edi
callq 0x2380
movq %rax, %r14
movq %r13, (%rax)
movq 0x10(%rsp), %rax
movq %rbx, 0x30(%rsp)
movq (%rax,%rbx,8), %rdi
addq $0x13, %rdi
callq 0x24d0
movq %rax, 0x8(%r14)
movq %rbp, 0x10(%r14)
movl $0x0, 0x18(%r14)
movq $0x0, 0x20(%r14)
movl $0x100, %esi            # imm = 0x100
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
leaq 0x26f3(%rip), %rdx      # 0xab0d
movq %rax, %rcx
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
movq %rsp, %rsi
leaq 0x3bb(%rip), %rdx       # 0x87ec
movq 0x5b98(%rip), %rcx      # 0xdfd0
callq 0x2260
movl %eax, %r15d
movl %eax, 0x1c(%rsp)
testl %eax, %eax
jle 0x8540
movq %r14, 0x38(%rsp)
movq %r14, %r13
xorl %r14d, %r14d
movq (%rsp), %rax
movq (%rax,%r14,8), %rsi
addq $0x13, %rsi
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
callq 0x8760
movq %rax, %rbp
movq (%rsp), %rax
movq (%rax,%r14,8), %r8
addq $0x13, %r8
movl $0x100, %esi            # imm = 0x100
leaq 0x40(%rsp), %r12
movq %r12, %rdi
leaq 0x2685(%rip), %rdx      # 0xab1b
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2210
movq %r12, %rdi
leaq 0xc68(%rip), %rsi       # 0x9112
callq 0x2430
testq %rax, %rax
je 0x8532
movq %rax, %r12
movq %rax, %rdi
leaq 0x2649(%rip), %rsi      # 0xab0a
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x20c0
cmpl $0x1, %eax
je 0x84da
movl $0x0, 0xc(%rsp)
movq %r12, %rdi
callq 0x2170
movl 0xc(%rsp), %ebx
testq %rbp, %rbp
sete %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
jne 0x8532
movl $0x28, %edi
callq 0x2380
movq %rax, %r12
movq %r13, (%rax)
movq (%rsp), %rax
movq (%rax,%r14,8), %rdi
addq $0x13, %rdi
callq 0x24d0
movq %rax, 0x8(%r12)
movq %rbp, 0x10(%r12)
movl %ebx, 0x18(%r12)
movq 0x38(%rsp), %rax
movq %rax, 0x20(%r12)
movq %r12, %r13
incq %r14
cmpq %r14, %r15
jne 0x8457
jmp 0x8543
movq %r14, %r13
cmpl $0x0, 0x1c(%rsp)
movq 0x28(%rsp), %r14
js 0x8571
je 0x8568
xorl %ebx, %ebx
movq (%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2040
incq %rbx
cmpq %rbx, %r15
jne 0x8553
movq (%rsp), %rdi
callq 0x2040
movq 0x30(%rsp), %rbx
incq %rbx
cmpq %r14, %rbx
jne 0x839f
xorl %ebx, %ebx
movq 0x10(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2040
incq %rbx
cmpq %rbx, %r14
jne 0x8584
movq 0x20(%rsp), %r14
jmp 0x85b6
leaq 0x250d(%rip), %rdi      # 0xaab5
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3204
testl %ebx, %ebx
js 0x85c0
movq 0x10(%rsp), %rdi
callq 0x2040
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x2340
testl %eax, %eax
js 0x8601
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x86b4
testq %r13, %r13
je 0x86a3
movq %r13, %rbp
movq %r13, %rcx
cmpq %rax, 0x10(%rcx)
je 0x8626
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x85ee
jmp 0x86a3
callq 0x2070
movl (%rax), %edi
callq 0x24e0
leaq 0x251d(%rip), %rdi      # 0xab31
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3204
jmp 0x86b4
movq 0x20(%rcx), %r15
testq %r15, %r15
je 0x86a3
movq 0x8(%r15), %rsi
leaq 0xcf3(%rip), %rdi       # 0x932d
callq 0x86c6
leaq 0x246a(%rip), %rbx      # 0xaab0
leaq 0x40(%rsp), %r14
movq %rbp, %r12
cmpq %r15, 0x20(%r12)
jne 0x8679
movl 0x18(%r12), %ecx
movl $0x8, %esi
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2210
movq 0x8(%r12), %rsi
movq %r14, %rdi
callq 0x86c6
movq (%r12), %r12
testq %r12, %r12
jne 0x864e
movq %rbp, %r14
movq (%r14), %rbx
movq 0x8(%r14), %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movq %rbx, %r14
testq %rbx, %rbx
jne 0x8685
jmp 0x86b4
leaq 0x23bb(%rip), %rdi      # 0xaa65
movq %r14, %rsi
xorl %eax, %eax
callq 0x3204
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq