// File: /workspace/github_c_makefile_star2_O0/nerves-project[P]nerves_initramfs/src/script.c
// Function: function_loadenv
static const struct term *function_loadenv(const struct term *parameters)
{
    (void)parameters;
    const char *devpathspec = get_variable_as_string("uboot_env.path");
    char devpath[BLOCK_DEVICE_PATH_LEN];

    int block = get_variable_as_number("uboot_env.start");
    int block_count = get_variable_as_number("uboot_env.count");

    working_uboot_env.env_size = block_count * 512;
    int fd = open_block_device(devpathspec, O_RDONLY, devpath);
    if (fd < 0) {
        info("Could not open '%s'", devpathspec);
        return NULL;
    }
    if (lseek(fd, block * 512, SEEK_SET) < 0) {
        info("Could not seek to block %d (byte offset %d) in '%s'", block, block * 512, devpath);
        close(fd);
        return NULL;
    }
    char *buffer = malloc(working_uboot_env.env_size);
    ssize_t amount_read = read(fd, buffer, working_uboot_env.env_size);
    close(fd);

    if (amount_read != (ssize_t) working_uboot_env.env_size) {
        free(buffer);
        info("Could not read %d blocks (%d bytes) from '%s'", block_count, working_uboot_env.env_size, devpath);
        return NULL;
    }

    set_boolean_variable("uboot_env.loaded", false);
    set_boolean_variable("uboot_env.modified", false);

    if (uboot_env_read(&working_uboot_env, buffer) < 0) {
        free(buffer);
        return NULL;
    }
    free(buffer);

    set_boolean_variable("uboot_env.loaded", true);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
leaq 0x5adf(%rip), %rdi      # 0xd702
callq 0x74e0
movq %rax, -0x18(%rbp)
leaq 0x458f(%rip), %rdi      # 0xc1c2
callq 0x7580
movl %eax, -0x44(%rbp)
leaq 0x4590(%rip), %rdi      # 0xc1d2
callq 0x7580
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
shll $0x9, %eax
movslq %eax, %rcx
leaq 0x9956(%rip), %rax      # 0x115b0
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rdx
xorl %esi, %esi
callq 0xa900
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x7c94
movq -0x18(%rbp), %rsi
leaq 0x5af7(%rip), %rdi      # 0xd777
movb $0x0, %al
callq 0x32a0
movq $0x0, -0x8(%rbp)
jmp 0x7dba
movl -0x4c(%rbp), %edi
movl -0x44(%rbp), %eax
shll $0x9, %eax
movslq %eax, %rsi
xorl %edx, %edx
callq 0x2200
cmpq $0x0, %rax
jge 0x7cdd
movl -0x44(%rbp), %esi
movl -0x44(%rbp), %edx
shll $0x9, %edx
leaq -0x40(%rbp), %rcx
leaq 0x5aca(%rip), %rdi      # 0xd78b
movb $0x0, %al
callq 0x32a0
movl -0x4c(%rbp), %edi
callq 0x2250
movq $0x0, -0x8(%rbp)
jmp 0x7dba
leaq 0x98cc(%rip), %rax      # 0x115b0
movq (%rax), %rdi
callq 0x2330
movq %rax, -0x58(%rbp)
movl -0x4c(%rbp), %edi
movq -0x58(%rbp), %rsi
leaq 0x98b2(%rip), %rax      # 0x115b0
movq (%rax), %rdx
callq 0x2280
movq %rax, -0x60(%rbp)
movl -0x4c(%rbp), %edi
callq 0x2250
movq -0x60(%rbp), %rax
leaq 0x9893(%rip), %rcx      # 0x115b0
cmpq (%rcx), %rax
je 0x7d54
movq -0x58(%rbp), %rdi
callq 0x2040
movl -0x48(%rbp), %esi
leaq 0x987b(%rip), %rax      # 0x115b0
movq (%rax), %rdx
leaq -0x40(%rbp), %rcx
leaq 0x5a7c(%rip), %rdi      # 0xd7bf
movb $0x0, %al
callq 0x32a0
movq $0x0, -0x8(%rbp)
jmp 0x7dba
leaq 0x4443(%rip), %rdi      # 0xc19e
xorl %esi, %esi
callq 0x7610
leaq 0x4446(%rip), %rdi      # 0xc1af
xorl %esi, %esi
callq 0x7610
movq -0x58(%rbp), %rsi
leaq 0x9835(%rip), %rdi      # 0x115b0
callq 0x36e0
cmpl $0x0, %eax
jge 0x7d98
movq -0x58(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
jmp 0x7dba
movq -0x58(%rbp), %rdi
callq 0x2040
leaq 0x43f6(%rip), %rdi      # 0xc19e
movl $0x1, %esi
callq 0x7610
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)