LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/eprom_prog.c
// Function: eprog_set_progmode
static int eprog_set_progmode(struct eprog_privdata *p_prog,
                              uint8_t progmode)
{
    uint8_t request[] = { MSGTYPE_PROGMODE_REQ, 1, progmode };

    int ret = write(p_prog->fd, request, sizeof(request));
    if (ret <= 0)
    {
        return ret;
    }

    ret = eprog_recv(p_prog->fd, MSGTYPE_PROGMODE_RSP, NULL, 0);
    if (ret < 0)
    {
        return ret;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movb $0x4, -0x14(%rbp)
movb $0x1, -0x13(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x12(%rbp)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
leaq -0x14(%rbp), %rsi
movl $0x3, %edx
callq 0x2070
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jg 0x46d6
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4705
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
movl $0x84, %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x4910
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x46fe
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4705
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/eprom_prog.c
// Function: eprog_set_address
static int eprog_set_address(struct eprog_privdata *p_prog,
                             uint32_t address)
{
    uint8_t request[] = { MSGTYPE_SETADDRESS_REQ, 3,
                          (address >> 16) & 0xFF,
                          (address >> 8) & 0xFF,
                          (address >> 0) & 0xFF };

    int ret = write(p_prog->fd, request, sizeof(request));
    if (ret <= 0)
    {
        return ret;
    }

    ret = eprog_recv(p_prog->fd, MSGTYPE_SETADDRESS_RSP, NULL, 0);
    if (ret < 0)
    {
        return ret;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb $0x5, -0x19(%rbp)
movb $0x3, -0x18(%rbp)
movl -0x14(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0x17(%rbp)
movl -0x14(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0x16(%rbp)
movl -0x14(%rbp), %eax
shrl $0x0, %eax
andl $0xff, %eax
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
leaq -0x19(%rbp), %rsi
movl $0x5, %edx
callq 0x2070
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x4ba7
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4bd6
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
movl $0x85, %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x4910
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x4bcf
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4bd6
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/eprom_prog.c
// Function: eprog_read_data
static int eprog_read_data(struct eprog_privdata *p_prog,
                           uint8_t * data,
                           uint8_t length)
{
    uint8_t request[] = { MSGTYPE_READ_REQ, 1, length };

    int ret = write(p_prog->fd, request, sizeof(request));
    if (ret <= 0)
    {
        return ret;
    }

    ret = eprog_recv(p_prog->fd, MSGTYPE_READ_RSP, data, length);
    if (ret < 0)
    {
        return ret;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movb $0x7, -0x1c(%rbp)
movb $0x1, -0x1b(%rbp)
movb -0x19(%rbp), %al
movb %al, -0x1a(%rbp)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
leaq -0x1c(%rbp), %rsi
movl $0x3, %edx
callq 0x2070
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x4c29
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4c5a
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
movq -0x18(%rbp), %rdx
movl $0x87, %esi
movzbl -0x19(%rbp), %ecx
callq 0x4910
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x4c53
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4c5a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/eprom_prog.c
// Function: eprog_write_data
static int eprog_write_data(struct eprog_privdata *p_prog,
                            const uint8_t * data,
                            uint8_t length)
{
    uint8_t request[] = { MSGTYPE_WRITE_REQ, length };

    int ret = write(p_prog->fd, request, sizeof(request));
    if (ret <= 0)
    {
        return ret;
    }

    ret = write(p_prog->fd, data, length);
    if (ret <= 0)
    {
        return ret;
    }

    ret = eprog_recv(p_prog->fd, MSGTYPE_WRITE_RSP, NULL, 0);
    if (ret < 0)
    {
        return ret;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movb $0x6, -0x1b(%rbp)
movb -0x19(%rbp), %al
movb %al, -0x1a(%rbp)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
leaq -0x1b(%rbp), %rsi
movl $0x2, %edx
callq 0x2070
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x4cb5
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4d0b
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
movq -0x18(%rbp), %rsi
movzbl -0x19(%rbp), %eax
movl %eax, %edx
callq 0x2070
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0x4cdc
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4d0b
movq -0x10(%rbp), %rax
movl 0x44(%rax), %edi
movl $0x86, %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x4910
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x4d04
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4d0b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: dbuf_alloc
struct databuf * dbuf_alloc(uint32_t size)
{
    struct databuf *dbuf = malloc(sizeof(struct databuf) + size);
    if (dbuf == NULL)
    {
        perror("dbuf_alloc");
        return NULL;
    }

    memset(dbuf->data, 0xFF, size);
    dbuf->size = size;
    dbuf->length = 0;
    return dbuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %edi
addq $0x8, %rdi
callq 0x21b0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4d5a
leaq 0x6c88(%rip), %rdi      # 0xb9d3
callq 0x2210
movq $0x0, -0x8(%rbp)
jmp 0x4d8d
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movl -0xc(%rbp), %eax
movl %eax, %edx
movl $0xff, %esi
callq 0x2100
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: file_getsize
int file_getsize(const char *filename, uint32_t *size)
{
    switch (get_filetype(filename))
    {
        case FILETYPE_BINARY:
            return binfile_getsize(filename, size);

        case FILETYPE_INTELHEX:
            return hexfile_getsize(filename, size);

        default:
            return -1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4e30
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
subl $0x1, %eax
je 0x4def
jmp 0x4de5
movl -0x1c(%rbp), %eax
subl $0x2, %eax
je 0x4e01
jmp 0x4e13
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4ed0
movl %eax, -0x4(%rbp)
jmp 0x4e1a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4f70
movl %eax, -0x4(%rbp)
jmp 0x4e1a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: get_filetype
static int get_filetype(const char *filename)
{
    const char *ext = filename + (strlen(filename) -4);

    if (ext < filename)
    {
        return FILETYPE_UNKNOWN;
    }

    if (strncmp(ext, ".bin", 4) == 0)
    {
        return FILETYPE_BINARY;
    }

    if (strncmp(ext, ".hex", 4) == 0)
    {
        return FILETYPE_INTELHEX;
    }

    return FILETYPE_UNKNOWN;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
subq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x4e72
movl $0x0, -0x4(%rbp)
jmp 0x4ebf
movq -0x18(%rbp), %rdi
leaq 0x6b63(%rip), %rsi      # 0xb9e0
movl $0x4, %edx
callq 0x2060
cmpl $0x0, %eax
jne 0x4e95
movl $0x1, -0x4(%rbp)
jmp 0x4ebf
movq -0x18(%rbp), %rdi
leaq 0x6b45(%rip), %rsi      # 0xb9e5
movl $0x4, %edx
callq 0x2060
cmpl $0x0, %eax
jne 0x4eb8
movl $0x2, -0x4(%rbp)
jmp 0x4ebf
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: binfile_getsize
static int binfile_getsize(const char *filename, uint32_t *size)
{
    int fd = open(filename, O_RDONLY);
    if (fd < 0)
    {
        perror("binfile_getsize(): open()");
        return -1;
    }

    struct stat filestat;
    if (fstat(fd, &filestat) < 0)
    {
        perror("binfile_getsize(): fstat()");
        close(fd);
        return -1;
    }

    *size = filestat.st_size;

    close(fd);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x21e0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x4f0e
leaq 0x6aea(%rip), %rdi      # 0xb9ea
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f5a
movl -0x1c(%rbp), %edi
leaq -0xb0(%rbp), %rsi
callq 0x2270
cmpl $0x0, %eax
jge 0x4f3f
leaq 0x6adb(%rip), %rdi      # 0xba04
callq 0x2210
movl -0x1c(%rbp), %edi
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f5a
movq -0x80(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x1c(%rbp), %edi
callq 0x2120
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: file_read
int file_read(const char *filename, struct databuf *dbuf)
{
    switch (get_filetype(filename))
    {
        case FILETYPE_BINARY:
            return binfile_read(filename, dbuf);

        case FILETYPE_INTELHEX:
            return hexfile_read(filename, dbuf);

        default:
            return -1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4e30
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
subl $0x1, %eax
je 0x4fbf
jmp 0x4fb5
movl -0x1c(%rbp), %eax
subl $0x2, %eax
je 0x4fd1
jmp 0x4fe3
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5000
movl %eax, -0x4(%rbp)
jmp 0x4fea
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x50a0
movl %eax, -0x4(%rbp)
jmp 0x4fea
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: binfile_read
static int binfile_read(const char *filename, struct databuf *dbuf)
{
    int fd = open(filename, O_RDONLY);
    if (fd < 0)
    {
        perror("binfile_read(): open()");
        return -1;
    }

    ssize_t readsize = read(fd, dbuf->data, dbuf->size);
    if (readsize <= 0)
    {
        perror("binfile_read(): read()");
        close(fd);
        return -1;
    }

    dbuf->length = readsize;

    close(fd);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x21e0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x503b
leaq 0x69f2(%rip), %rdi      # 0xba1f
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5097
movl -0x1c(%rbp), %edi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, %edx
callq 0x2130
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jg 0x507b
leaq 0x69d1(%rip), %rdi      # 0xba36
callq 0x2210
movl -0x1c(%rbp), %edi
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5097
movq -0x28(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x1c(%rbp), %edi
callq 0x2120
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: hexfile_read
static int hexfile_read(const char *filename, struct databuf *dbuf)
{
    FILE *stream = fopen(filename, "r");
    if (stream == NULL)
    {
        perror("hexfile_read(): fopen()");
        return -1;
    }

    while (1)
    {
        struct ihex_record record;
        memset(&record, 0x00, sizeof(struct ihex_record));

        int result = hexfile_getrecord(stream, &record);
        if (result == -1)
        {
            break;
        }

        if (record.type == 0x00)
        {
            if ((record.address > dbuf->size) ||
                (record.address + record.byte_count > dbuf->size)
               )
            {
                fprintf(stderr, "hexfile_read(): data out of bounds\n");
                break;
            }

            memcpy(&dbuf->data[record.address], record.data, record.byte_count);
            dbuf->length = record.address + record.byte_count;
        }
    }

    fclose(stream);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6992(%rip), %rsi      # 0xba4d
callq 0x21f0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x50e3
leaq 0x697d(%rip), %rdi      # 0xba4f
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5192
jmp 0x50e5
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
movq -0x20(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x56e0
movl %eax, -0x3c(%rbp)
cmpl $-0x1, -0x3c(%rbp)
jne 0x510d
jmp 0x5182
movzbl -0x34(%rbp), %eax
cmpl $0x0, %eax
jne 0x517d
movzwl -0x36(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
ja 0x5134
movzwl -0x36(%rbp), %eax
movzbl -0x38(%rbp), %ecx
addl %ecx, %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jbe 0x514e
movq 0xaebd(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x6922(%rip), %rsi      # 0xba67
movb $0x0, %al
callq 0x2160
jmp 0x5182
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movzwl -0x36(%rbp), %eax
addq %rax, %rdi
movq -0x30(%rbp), %rsi
movzbl -0x38(%rbp), %eax
movl %eax, %edx
callq 0x2190
movzwl -0x36(%rbp), %ecx
movzbl -0x38(%rbp), %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x50e5
movq -0x20(%rbp), %rdi
callq 0x2080
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: file_write
int file_write(const char *filename, struct databuf *dbuf)
{
    if (strncmp(filename, "-", 1) == 0)
    {
        dbuf_dump(dbuf);
        return 0;
    }

    switch (get_filetype(filename))
    {
        case FILETYPE_BINARY:
            return binfile_write(filename, dbuf);

        case FILETYPE_INTELHEX:
            return hexfile_write(filename, dbuf);

        default:
            return -1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6823(%rip), %rsi      # 0xb9de
movl $0x1, %edx
callq 0x2060
cmpl $0x0, %eax
jne 0x51dc
movq -0x18(%rbp), %rdi
callq 0x5230
movl $0x0, -0x4(%rbp)
jmp 0x5226
movq -0x10(%rbp), %rdi
callq 0x4e30
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
subl $0x1, %eax
je 0x51fb
jmp 0x51f1
movl -0x1c(%rbp), %eax
subl $0x2, %eax
je 0x520d
jmp 0x521f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x54d0
movl %eax, -0x4(%rbp)
jmp 0x5226
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5580
movl %eax, -0x4(%rbp)
jmp 0x5226
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: binfile_write
static int binfile_write(const char *filename, struct databuf *dbuf)
{
    int fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
    if (fd < 0)
    {
        perror("binfile_write(): open()");
        return -1;
    }

    ssize_t writesize = write(fd, dbuf->data, dbuf->length);
    if (writesize != dbuf->length)
    {
        perror("binfile_write(): write()");
        close(fd);
        return -1;
    }

    close(fd);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1a4, %edx            # imm = 0x1A4
movb $0x0, %al
callq 0x21e0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x5513
leaq 0x6622(%rip), %rdi      # 0xbb27
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x556c
movl -0x1c(%rbp), %edi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edx
callq 0x2070
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
je 0x555d
leaq 0x65f8(%rip), %rdi      # 0xbb3f
callq 0x2210
movl -0x1c(%rbp), %edi
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x556c
movl -0x1c(%rbp), %edi
callq 0x2120
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: hex2byte
static uint8_t hex2byte(const char *ptr)
{
    int i;
    uint8_t result = 0;

    for (i = 0; i < 2; i++)
    {
        result <<= 4;
        result |= (ptr[i] >= '0' && ptr[i] <= '9') ? (ptr[i] - '0')
                                                   : (((ptr[i] & 0xDF) >= 'A' && (ptr[i] & 0xDF) <= 'F') ? (ptr[i] - 'A' + 0x0A)
                                                                                                         : 0x00);
    }

    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movb $0x0, -0xd(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x2, -0xc(%rbp)
jge 0x5aa7
movzbl -0xd(%rbp), %eax
shll $0x4, %eax
movb %al, -0xd(%rbp)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jl 0x5a3d
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x39, %eax
jg 0x5a3d
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x30, %eax
movl %eax, -0x14(%rbp)
jmp 0x5a8d
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsbl (%rax,%rcx), %eax
andl $0xdf, %eax
cmpl $0x41, %eax
jl 0x5a80
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsbl (%rax,%rcx), %eax
andl $0xdf, %eax
cmpl $0x46, %eax
jg 0x5a80
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x41, %eax
addl $0xa, %eax
movl %eax, -0x18(%rbp)
jmp 0x5a87
xorl %eax, %eax
movl %eax, -0x18(%rbp)
jmp 0x5a87
movl -0x18(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movzbl -0xd(%rbp), %eax
orl %ecx, %eax
movb %al, -0xd(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x59f3
movb -0xd(%rbp), %al
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/filedata.c
// Function: hexfile_putrecord
static int hexfile_putrecord(FILE *stream, struct ihex_record *record)
{
    uint8_t chksum = record->byte_count;
    chksum += (record->address >> 8) & 0xFF;
    chksum += (record->address & 0xFF);
    chksum += record->type;

    int i, len = 0;
    char buf[64];

    buf[0] = '\0';
    for (i = 0; i < record->byte_count; i++)
    {
        len += snprintf(buf + len, sizeof(buf) - len, "%02X", record->data[i]);
        chksum += record->data[i];
    }

    fprintf(stream, ":%02X%04X%02X%s%02X\n",
            record->byte_count,
            record->address,
            record->type,
            buf,
            (uint8_t)(0x100 - chksum));

    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb (%rax), %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
movzbl -0x11(%rbp), %eax
addl %ecx, %eax
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %ecx
andl $0xff, %ecx
movzbl -0x11(%rbp), %eax
addl %ecx, %eax
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %ecx
movzbl -0x11(%rbp), %eax
addl %ecx, %eax
movb %al, -0x11(%rbp)
movl $0x0, -0x1c(%rbp)
movb $0x0, -0x60(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x5b8a
leaq -0x60(%rbp), %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rax
movl $0x40, %esi
subq %rax, %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
leaq 0x5fb5(%rip), %rdx      # 0xbb0e
movb $0x0, %al
callq 0x20e0
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
movzbl -0x11(%rbp), %eax
addl %ecx, %eax
movb %al, -0x11(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5b1d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %r8d
leaq -0x60(%rbp), %r9
movzbl -0x11(%rbp), %esi
movl $0x100, %eax            # imm = 0x100
subl %esi, %eax
movzbl %al, %eax
leaq 0x5fb2(%rip), %rsi      # 0xbb71
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_alloc
static struct multiboot * funk_alloc(void)
{
    struct multiboot * mboot = malloc(sizeof(struct multiboot));
    if (mboot == NULL)
    {
        return NULL;
    }

    memset(mboot, 0x00, sizeof(struct multiboot));
    mboot->ops = &funk_ops;

    struct funk_privdata *funk = malloc(sizeof(struct funk_privdata));
    if (funk == NULL)
    {
        free(mboot);
        return NULL;
    }

    memset(funk, 0x00, sizeof(struct funk_privdata));
    funk->device = NULL;
    funk->address = 0;

    optarg_register(funk_optargs, ARRAY_SIZE(funk_optargs), funk_optarg_cb, (void *)funk);

    mboot->privdata = funk;
    return mboot;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x20, %edi
callq 0x21b0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5c0a
movq $0x0, -0x8(%rbp)
jmp 0x5ca6
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x2100
movq -0x10(%rbp), %rax
leaq 0xa7bb(%rip), %rcx      # 0x103e0
movq %rcx, (%rax)
movl $0x68, %edi
callq 0x21b0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5c50
movq -0x10(%rbp), %rdi
callq 0x2030
movq $0x0, -0x8(%rbp)
jmp 0x5ca6
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x18(%rbp), %rcx
leaq 0xa7af(%rip), %rdi      # 0x10430
movl $0x2, %esi
leaq 0x853(%rip), %rdx       # 0x64e0
callq 0x9670
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_free
static void funk_free(struct multiboot *mboot)
{
    struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;

    if (funk->device != NULL)
    {
        free(funk->device);
    }

    free(funk);
    free(mboot);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5cde
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2030
movq -0x10(%rbp), %rdi
callq 0x2030
movq -0x8(%rbp), %rdi
callq 0x2030
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_get_memtype
static int funk_get_memtype(struct multiboot *mboot,
                            const char *memname)
{
    /* unused parameter */
    (void)mboot;

    if (strcmp(memname, "flash") == 0)
    {
        return MEMTYPE_FLASH;
    }
    else if (strcmp(memname, "eeprom") == 0)
    {
        return MEMTYPE_EEPROM;
    }

    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x581a(%rip), %rsi      # 0xb535
callq 0x2150
cmpl $0x0, %eax
jne 0x5d2e
movl $0x1, -0x4(%rbp)
jmp 0x5d55
movq -0x18(%rbp), %rdi
leaq 0x580a(%rip), %rsi      # 0xb543
callq 0x2150
cmpl $0x0, %eax
jne 0x5d4c
movl $0x2, -0x4(%rbp)
jmp 0x5d55
jmp 0x5d4e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_get_memsize
static uint32_t funk_get_memsize(struct multiboot *mboot,
                                 int memtype)
{
    struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;

    if (!funk->connected)
    {
        return 0;
    }

    switch (memtype)
    {
        case MEMTYPE_FLASH:
            return funk->flashsize;

        case MEMTYPE_EEPROM:
            return funk->eepromsize;

        default:
            return 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x5d8a
movl $0x0, -0x4(%rbp)
jmp 0x5dc0
movl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
subl $0x1, %eax
je 0x5da1
jmp 0x5d97
movl -0x24(%rbp), %eax
subl $0x2, %eax
je 0x5dad
jmp 0x5db9
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5dc0
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5dc0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_close
static int funk_close(struct multiboot *mboot)
{
    struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;

    if (funk->connected)
    {
        funk_switch_application(funk, BOOTTYPE_APPLICATION);
    }

    funk_close_device(funk);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x6090
movq -0x10(%rbp), %rdi
movl $0x80, %esi
callq 0x6800
movq -0x10(%rbp), %rdi
callq 0x7180
xorl %eax, %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_read
static int funk_read(struct multiboot *mboot,
                     struct databuf *dbuf,
                     int memtype)
{
    struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;
    char *progress_msg = (memtype == MEMTYPE_FLASH) ? "reading flash" : "reading eeprom";

    uint16_t pos = 0;
    uint16_t size = (memtype == MEMTYPE_FLASH) ? funk->flashsize : funk->eepromsize;

    while (pos < size)
    {
        mboot->progress_cb(progress_msg, pos, size);

        uint16_t len = MIN(READ_BLOCK_SIZE, size - pos);
        if (funk_read_memory(funk, dbuf->data + pos, len, memtype, pos))
        {
            mboot->progress_cb(progress_msg, -1, -1);
            return -1;
        }

        pos += len;
    }

    dbuf->length = pos;

    mboot->progress_cb(progress_msg, pos, size);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %edx
leaq 0x5462(%rip), %rax      # 0xb53b
leaq 0x544d(%rip), %rcx      # 0xb52d
cmpl $0x1, %edx
cmoveq %rcx, %rax
movq %rax, -0x30(%rbp)
movw $0x0, -0x32(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x6103
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x610d
movq -0x28(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x34(%rbp)
movzwl -0x32(%rbp), %eax
movzwl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jge 0x61cd
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movzwl -0x32(%rbp), %esi
movzwl -0x34(%rbp), %edx
callq *%rax
movzwl -0x34(%rbp), %ecx
movzwl -0x32(%rbp), %eax
subl %eax, %ecx
movl $0x20, %eax
cmpl %ecx, %eax
jge 0x6157
movl $0x20, %eax
movl %eax, -0x40(%rbp)
jmp 0x6164
movzwl -0x34(%rbp), %eax
movzwl -0x32(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movw %ax, -0x36(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movzwl -0x32(%rbp), %eax
cltq
addq %rax, %rsi
movw -0x36(%rbp), %cx
movl -0x1c(%rbp), %eax
movzwl %cx, %edx
movzbl %al, %ecx
movzwl -0x32(%rbp), %r8d
callq 0x71c0
cmpl $0x0, %eax
je 0x61ba
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq *%rax
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x61f5
movzwl -0x36(%rbp), %ecx
movzwl -0x32(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x32(%rbp)
jmp 0x6114
movzwl -0x32(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movzwl -0x32(%rbp), %esi
movzwl -0x34(%rbp), %edx
callq *%rax
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_write
static int funk_write(struct multiboot *mboot,
                      struct databuf *dbuf,
                      int memtype)
{
    struct funk_privdata *funk = (struct funk_privdata *)mboot->privdata;
    char *progress_msg = (memtype == MEMTYPE_FLASH) ? "writing flash" : "writing eeprom";

    uint16_t pos = 0;
    while (pos < dbuf->length)
    {
        mboot->progress_cb(progress_msg, pos, dbuf->length);

        uint16_t len = (memtype == MEMTYPE_FLASH) ? funk->flashpage : WRITE_BLOCK_SIZE;

        len = MIN(len, dbuf->length - pos);

        if (funk_write_memory(funk, dbuf->data + pos, len, memtype, pos))
        {
            mboot->progress_cb(progress_msg, -1, -1);
            return -1;
        }

        pos += len;
    }

    mboot->progress_cb(progress_msg, pos, dbuf->length);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %edx
leaq 0x51f6(%rip), %rax      # 0xb5af
leaq 0x51e1(%rip), %rcx      # 0xb5a1
cmpl $0x1, %edx
cmoveq %rcx, %rax
movq %rax, -0x30(%rbp)
movw $0x0, -0x32(%rbp)
movzwl -0x32(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x64b5
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movzwl -0x32(%rbp), %esi
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %edx
callq *%rax
cmpl $0x1, -0x1c(%rbp)
jne 0x640d
movq -0x28(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x38(%rbp)
jmp 0x6417
movl $0x20, %eax
movl %eax, -0x38(%rbp)
jmp 0x6417
movl -0x38(%rbp), %eax
movw %ax, -0x34(%rbp)
movzwl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
movzwl -0x32(%rbp), %edx
subl %edx, %ecx
cmpl %ecx, %eax
jae 0x643c
movzwl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x644c
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movzwl -0x32(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x34(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movzwl -0x32(%rbp), %eax
cltq
addq %rax, %rsi
movw -0x34(%rbp), %cx
movl -0x1c(%rbp), %eax
movzwl %cx, %edx
movzbl %al, %ecx
movzwl -0x32(%rbp), %r8d
callq 0x7320
cmpl $0x0, %eax
je 0x64a2
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq *%rax
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x64d5
movzwl -0x34(%rbp), %ecx
movzwl -0x32(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x32(%rbp)
jmp 0x63d1
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdi
movzwl -0x32(%rbp), %esi
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %edx
callq *%rax
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_open_device
static int funk_open_device(struct funk_privdata *funk)
{
    funk->fd = open(funk->device, O_RDWR | O_NOCTTY | O_CLOEXEC);
    if (funk->fd < 0)
    {
        perror("open()");
        return -1;
    }

    if (tcgetattr(funk->fd, &funk->oldtio) < 0)
    {
        perror("tcgetattr(oldtio)");
        close(funk->fd);
        return -1;
    }

    struct termios newtio;
    memset(&newtio, 0, sizeof(newtio));

    newtio.c_iflag |= IGNBRK;
    newtio.c_cflag |= B38400 | CS8 | CLOCAL | CREAD;

    newtio.c_cc[VMIN] = 1;
    newtio.c_cc[VTIME] = 0;

    int err = tcsetattr(funk->fd, TCSANOW, &newtio);
    if (err < 0)
    {
        perror("tcsetattr(newtio)");
        close(funk->fd);
        return -1;
    }

    funk->connected = 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x80102, %esi          # imm = 0x80102
movb $0x0, %al
callq 0x21e0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jge 0x669a
leaq 0x53a6(%rip), %rdi      # 0xba2f
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x674e
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rsi
addq $0x28, %rsi
callq 0x21c0
cmpl $0x0, %eax
jge 0x66d4
leaq 0x4e40(%rip), %rdi      # 0xb4fa
callq 0x2210
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x674e
leaq -0x4c(%rbp), %rdi
xorl %esi, %esi
movl $0x3c, %edx
callq 0x2100
movl -0x4c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x44(%rbp), %eax
orl $0x8bf, %eax            # imm = 0x8BF
movl %eax, -0x44(%rbp)
movb $0x1, -0x35(%rbp)
movb $0x0, -0x36(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
xorl %esi, %esi
leaq -0x4c(%rbp), %rdx
callq 0x21d0
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jge 0x673c
leaq 0x4dea(%rip), %rdi      # 0xb50c
callq 0x2210
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x674e
movq -0x10(%rbp), %rax
movl $0x1, 0xc(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_bridge_version
static int funk_bridge_version(struct funk_privdata *funk,
                               uint8_t *version,
                               int size)
{
    uint8_t request[] = { BRIDGE_CMD_VERSION, 0 };

    int ret = funk_bridge_send(funk, request, sizeof(request), NULL, 0);
    if (ret < 0)
    {
        return ret;
    }

    uint8_t cause = BRIDGE_CAUSE_SUCCESS;
    ret = funk_bridge_recv(funk, request[0], &cause, version, size);
    if (ret < 0)
    {
        return ret;
    }

    version[ret] = '\0';

    return (cause != BRIDGE_CAUSE_SUCCESS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movw 0x577e(%rip), %ax       # 0xbef8
movw %ax, -0x1e(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x1e(%rbp), %rsi
movl $0x2, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x6ba0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x67a8
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x67f6
movb $0x0, -0x25(%rbp)
movq -0x10(%rbp), %rdi
movb -0x1e(%rbp), %al
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
leaq -0x25(%rbp), %rdx
movzbl %al, %esi
callq 0x6c40
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x67d8
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x67f6
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movzbl -0x25(%rbp), %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_switch_application
static int funk_switch_application(struct funk_privdata *funk,
                                   uint8_t application)
{
    struct rfm12_pkt packet;

    packet.dest_address         = funk->address;
    packet.source_address       = 0xCC;             // TODO: changed in bridge
    packet.data_length          = 0x04;
    packet.header_checksum      = 0xCC;             // TODO: calced in bridge
    packet.msg.command          = MSG_CMD_SWITCHAPP_REQUEST;
    packet.msg.seqnum           = ++funk->seqnum;   // TODO: retransmit in bridge?
    packet.msg.cause            = CAUSE_SUCCESS;
    packet.msg.p.switchapp.app  = application;

    int ret = funk_send_packet(funk, &packet, 4 + packet.data_length);
    if (ret < 0)
    {
        fprintf(stderr, "funk_switch_application(): funk_send_packet()\n");
        return ret;
    }

    int response_size = sizeof(packet);
    ret = funk_recv_packet(funk, &packet, &response_size);
    if (ret < 0)
    {
        fprintf(stderr, "funk_switch_application(): funk_recv_packet()\n");
        return ret;
    }

    if ((packet.msg.command != MSG_CMD_SWITCHAPP_RESPONSE) ||
        (packet.msg.cause != CAUSE_SUCCESS)
       )
    {
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movb %al, -0x3c(%rbp)
movb $-0x34, -0x3b(%rbp)
movb $0x4, -0x3a(%rbp)
movb $-0x34, -0x39(%rbp)
movb $0x20, -0x38(%rbp)
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x18(%rcx)
movb %al, -0x37(%rbp)
movb $0x0, -0x36(%rbp)
movb -0x11(%rbp), %al
movb %al, -0x35(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x3a(%rbp), %edx
addl $0x4, %edx
leaq -0x3c(%rbp), %rsi
callq 0x7030
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jge 0x6883
movq 0x978e(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x56f2(%rip), %rsi      # 0xbf66
movb $0x0, %al
callq 0x2160
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x68e8
movl $0x2b, -0x44(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x70d0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jge 0x68c4
movq 0x974d(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x56e0(%rip), %rsi      # 0xbf95
movb $0x0, %al
callq 0x2160
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x68e8
movzbl -0x38(%rbp), %eax
cmpl $0xe0, %eax
jne 0x68d8
movzbl -0x36(%rbp), %eax
cmpl $0x0, %eax
je 0x68e1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x68e8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_read_chipinfo
static int funk_read_chipinfo(struct funk_privdata *funk,
                              uint8_t *chipinfo,
                              uint16_t length)
{
    struct rfm12_pkt packet;

    packet.dest_address         = funk->address;
    packet.source_address       = 0xCC;             // TODO: changed in bridge
    packet.data_length          = 0x03;
    packet.header_checksum      = 0xCC;             // TODO: calced in bridge
    packet.msg.command          = MSG_CMD_CHIPINFO_REQUEST;
    packet.msg.seqnum           = ++funk->seqnum;   // TODO: retransmit in bridge?
    packet.msg.cause            = CAUSE_SUCCESS;

    int ret = funk_send_packet(funk, &packet, 4 + packet.data_length);
    if (ret < 0)
    {
        fprintf(stderr, "funk_read_chipinfo(): funk_send_packet()\n");
        return ret;
    }

    int response_size = sizeof(packet);
    ret = funk_recv_packet(funk, &packet, &response_size);
    if (ret < 0) {
        fprintf(stderr, "funk_read_chipinfo(): funk_recv_packet()\n");
        return ret;
    }

    if ((packet.msg.command != MSG_CMD_CHIPINFO_RESPONSE) ||
        (packet.msg.cause != CAUSE_SUCCESS)
       )
    {
        return -1;
    }

    memcpy(chipinfo, packet.msg.p.chipinfo.data, MIN(packet.data_length -3, length));

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movb %al, -0x45(%rbp)
movb $-0x34, -0x44(%rbp)
movb $0x3, -0x43(%rbp)
movb $-0x34, -0x42(%rbp)
movb $0x22, -0x41(%rbp)
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x18(%rcx)
movb %al, -0x40(%rbp)
movb $0x0, -0x3f(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x43(%rbp), %edx
addl $0x4, %edx
leaq -0x45(%rbp), %rsi
callq 0x7030
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x6ae5
movq 0x952f(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x5545(%rip), %rsi      # 0xc018
movb $0x0, %al
callq 0x2160
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6b97
movl $0x2b, -0x50(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x45(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x70d0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x6b26
movq 0x94eb(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x552b(%rip), %rsi      # 0xc042
movb $0x0, %al
callq 0x2160
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6b97
movzbl -0x41(%rbp), %eax
cmpl $0xe2, %eax
jne 0x6b3a
movzbl -0x3f(%rbp), %eax
cmpl $0x0, %eax
je 0x6b43
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6b97
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x45(%rbp), %rax
addq $0x4, %rax
addq $0x3, %rax
movq %rax, -0x58(%rbp)
movzbl -0x43(%rbp), %eax
subl $0x3, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x6b76
movzbl -0x43(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x64(%rbp)
jmp 0x6b7d
movzwl -0x1a(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdi
movl -0x64(%rbp), %eax
movslq %eax, %rdx
callq 0x2190
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_bridge_send
static int funk_bridge_send(struct funk_privdata *funk,
                            uint8_t *header,
                            uint8_t headerlength,
                            uint8_t *data,
                            uint8_t datalength)
{
    if (headerlength > 0)
    {
        if (write(funk->fd, header, headerlength) != headerlength)
        {
            return -1;
        }
    }

    if (datalength > 0)
    {
        if (write(funk->fd, data, datalength) != datalength)
        {
            return -1;
        }
    }

#if (FUNK_BRIDGE_DEBUG == 1)
    char *dump = funk_print_data(data, datalength);
    printf("funk_bridge_send() cmd=0x%02x length=0x%02x\n%s\n", header[0], datalength, dump);
    free(dump);
#endif

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %dl, -0x19(%rbp)
movq %rcx, -0x28(%rbp)
movb %al, -0x29(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x0, %eax
jle 0x6bf0
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x18(%rbp), %rsi
movzbl -0x19(%rbp), %eax
movl %eax, %edx
callq 0x2070
movzbl -0x19(%rbp), %ecx
cmpq %rcx, %rax
je 0x6bee
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6c2a
jmp 0x6bf0
movzbl -0x29(%rbp), %eax
cmpl $0x0, %eax
jle 0x6c23
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x28(%rbp), %rsi
movzbl -0x29(%rbp), %eax
movl %eax, %edx
callq 0x2070
movzbl -0x29(%rbp), %ecx
cmpq %rcx, %rax
je 0x6c21
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6c2a
jmp 0x6c23
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/orempel[P]multiboot_tool/funkboot.c
// Function: funk_serial_read
static int funk_serial_read(int fd, void *data, int size)
{
    int pos = 0;

    while (1)
    {
        fd_set fdset;
        struct timeval timeout = { .tv_sec = 1, .tv_usec = 0 };

        FD_ZERO(&fdset);
        FD_SET(fd, &fdset);

        int ret = select(fd +1, &fdset, NULL, NULL, &timeout);
        if (ret == -1)
        {
            perror("select");
            return -1;

        }
        else if (ret == 0)
        {
            break;
        }
        else if (FD_ISSET(fd, &fdset))
        {
            int len = read(fd, data + pos, size - pos);
            if (len < 0)
            {
                return -1;

            }
            else
            {
                pos += len;
                if (pos == size)
                {
                    break;
                }
            }
        }
    }

    return pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq 0x52e5(%rip), %rax      # 0xc178
movq %rax, -0xa8(%rbp)
movq 0x52df(%rip), %rax      # 0xc180
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
cmpq $0x10, %rax
jae 0x6ef2
movq -0xb8(%rbp), %rax
movl -0xac(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x6ec0
jmp 0x6ef4
movl -0x8(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl -0x8(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x98(%rbp,%rax,8), %rcx
movq %rcx, -0x98(%rbp,%rax,8)
movl -0x8(%rbp), %edi
addl $0x1, %edi
leaq -0x98(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0xa8(%rbp), %r8
movq %rcx, %rdx
callq 0x21a0
movl %eax, -0xbc(%rbp)
cmpl $-0x1, -0xbc(%rbp)
jne 0x6f72
leaq 0x45bf(%rip), %rdi      # 0xb520
callq 0x2210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7021
cmpl $0x0, -0xbc(%rbp)
jne 0x6f80
jmp 0x701b
movl -0x8(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0x98(%rbp,%rax,8), %rax
movq %rax, -0xc8(%rbp)
movl -0x8(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xc8(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x7012
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movslq -0x18(%rbp), %rax
addq %rax, %rsi
movl -0x14(%rbp), %eax
subl -0x18(%rbp), %eax
movslq %eax, %rdx
callq 0x2130
movl %eax, -0xc0(%rbp)
cmpl $0x0, -0xc0(%rbp)
jge 0x6ff8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7021
movl -0xc0(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x700e
jmp 0x701b
jmp 0x7010
jmp 0x7012
jmp 0x7014
jmp 0x7016
jmp 0x6e8c
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)