LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_alloc
static struct multiboot * twi_alloc(void)
{
    struct multiboot * mboot = malloc(sizeof(struct multiboot));
    if (mboot == NULL)
    {
        return NULL;
    }

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

    struct twi_privdata *twi = malloc(sizeof(struct twi_privdata));
    if (twi == NULL)
    {
        free(mboot);
        return NULL;
    }

    memset(twi, 0x00, sizeof(struct twi_privdata));
    twi->device  = NULL;
    twi->address = 0;

    optarg_register(twi_optargs, ARRAY_SIZE(twi_optargs), twi_optarg_cb, (void *)twi);

    mboot->privdata = twi;
    return mboot;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x2160
testq %rax, %rax
je 0x6837
movq %rax, %rbx
leaq 0x6e06(%rip), %rax      # 0xd600
movq %rax, (%rbx)
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x2160
testq %rax, %rax
je 0x682f
movq %rax, %r14
leaq 0x6e39(%rip), %rdi      # 0xd650
leaq 0x76b(%rip), %rdx       # 0x6f89
pushq $0x3
popq %rsi
movq %rax, %rcx
callq 0x6544
movq %r14, 0x8(%rbx)
jmp 0x6839
movq %rbx, %rdi
callq 0x2030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_close
static int twi_close(struct multiboot *mboot)
{
    struct twi_privdata *twi = (struct twi_privdata *)mboot->privdata;

    if (twi->connected && !twi->stay_in_bootloader)
    {
        twi_switch_application(twi, BOOTTYPE_APPLICATION);
    }

    twi_close_device(twi);
    return 0;
}

// Assembly:
pushq %rbx
movq 0x8(%rdi), %rbx
cmpl $0x0, 0x10(%rbx)
je 0x6c08
cmpl $0x0, 0x14(%rbx)
jne 0x6c00
movq %rbx, %rdi
movl $0x80, %esi
callq 0x7088
cmpl $0x0, 0x10(%rbx)
je 0x6c08
movl 0xc(%rbx), %edi
callq 0x2140
andl $0x0, 0x10(%rbx)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_read
static int twi_read(struct multiboot *mboot,
                    struct databuf *dbuf,
                    int memtype)
{
    struct twi_privdata *twi = (struct twi_privdata *)mboot->privdata;
    char *progress_msg = (memtype == MEMTYPE_FLASH) ? "reading flash" : "reading eeprom";

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

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

        uint8_t len = MIN(READ_BLOCK_SIZE, size - pos);

        if (twi_read_memory(twi, 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rdi), %rdi
xorl %eax, %eax
cmpl $0x1, %edx
setne %al
leaq 0x182e(%rip), %rcx      # 0x8464
leaq 0x1835(%rip), %r15      # 0x8472
cmoveq %rcx, %r15
movq %rdi, 0x20(%rsp)
movzwl 0x1a(%rdi,%rax,2), %ebx
movq %rsi, 0x10(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
xorl %eax, %eax
movl $0x80, %r12d
movzbl %dl, %r13d
movzwl %ax, %r14d
cmpw %bx, %r14w
jae 0x6cb4
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
movq 0x8(%rsp), %rax
callq *0x18(%rax)
movl %ebx, %ebp
subl %r14d, %ebp
cmpl %r12d, %ebp
cmovgel %r12d, %ebp
movl %r14d, %esi
addq 0x18(%rsp), %rsi
movzbl %bpl, %edx
movq 0x20(%rsp), %rdi
movl %r13d, %ecx
movl %r14d, %r8d
callq 0x70af
testl %eax, %eax
jne 0x6cd1
movzbl %bpl, %eax
addl %r14d, %eax
jmp 0x6c65
movq 0x10(%rsp), %rax
movl %r14d, 0x4(%rax)
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
movq 0x8(%rsp), %rax
callq *0x18(%rax)
xorl %ebp, %ebp
jmp 0x6ce3
pushq $-0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
movl %ebp, %edx
movq 0x8(%rsp), %rax
callq *0x18(%rax)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_verify
static int twi_verify(struct multiboot *mboot, struct databuf *dbuf, int memtype)
{
    struct twi_privdata *twi = (struct twi_privdata *)mboot->privdata;
    char *progress_msg = (memtype == MEMTYPE_FLASH) ? "verifing flash" : "verifing eeprom";

    uint16_t pos = 0;
    uint8_t comp[READ_BLOCK_SIZE];

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

        int len = MIN(READ_BLOCK_SIZE, dbuf->length - pos);
        if (twi_read_memory(twi, comp, len, memtype, pos))
        {
            mboot->progress_cb(progress_msg, -1, -1);
            return -1;
        }

        if (memcmp(comp, dbuf->data + pos, len) != 0x00)
        {
            mboot->progress_cb(progress_msg, -1, -1);
            fprintf(stderr, "verify failed at page 0x%04x!!\n", pos);
            return -1;
        }

        pos += len;
    }

    dbuf->length = pos;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
movq 0x8(%rdi), %rax
movq %rax, 0x18(%rsp)
cmpl $0x1, %edx
leaq 0x177a(%rip), %rax      # 0x849a
leaq 0x1782(%rip), %r14      # 0x84a9
cmoveq %rax, %r14
leaq 0x8(%rsi), %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movzbl %dl, %r13d
leaq 0x20(%rsp), %rbx
movzwl %r12w, %ebp
movl 0x4(%r15), %edx
cmpl %ebp, %edx
jbe 0x6dd1
movq %r14, %rdi
movl %ebp, %esi
movq 0x8(%rsp), %rax
callq *0x18(%rax)
movl 0x4(%r15), %r12d
subl %ebp, %r12d
movl $0x80, %eax
cmpl %eax, %r12d
cmovael %eax, %r12d
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x70af
testl %eax, %eax
jne 0x6de8
movl %ebp, %esi
addq 0x10(%rsp), %rsi
movl %r12d, %edx
movq %rbx, %rdi
callq 0x21e0
addl %ebp, %r12d
testl %eax, %eax
je 0x6d40
pushq $-0x1
popq %rbx
movq %r14, %rdi
movl %ebx, %esi
movl %ebx, %edx
movq 0x8(%rsp), %rax
callq *0x18(%rax)
movq 0x623c(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x223a(%rip), %rsi      # 0x9000
movl %ebp, %edx
xorl %eax, %eax
callq 0x2180
jmp 0x6dfa
movl %ebp, 0x4(%r15)
movq %r14, %rdi
movl %ebp, %esi
movl %ebp, %edx
movq 0x8(%rsp), %rax
callq *0x18(%rax)
xorl %ebx, %ebx
jmp 0x6dfa
pushq $-0x1
popq %rbx
movq %r14, %rdi
movl %ebx, %esi
movl %ebx, %edx
movq 0x8(%rsp), %rax
callq *0x18(%rax)
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_write
static int twi_write(struct multiboot *mboot,
                     struct databuf *dbuf,
                     int memtype)
{
    struct twi_privdata *twi = (struct twi_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);

        uint8_t len = (memtype == MEMTYPE_FLASH) ? twi->pagesize : WRITE_BLOCK_SIZE;

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

        if (twi_write_memory(twi, 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
movq 0x8(%rdi), %rax
movq %rax, (%rsp)
cmpl $0x1, %edx
leaq 0x169f(%rip), %rax      # 0x84d8
leaq 0x16a6(%rip), %rcx      # 0x84e6
cmoveq %rax, %rcx
movq %rcx, 0x8(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movq %rsi, 0x20(%rsp)
movzwl %bx, %ebx
movl 0x4(%r12), %ebp
movq 0x8(%rsp), %rdi
movl %ebx, %esi
movl %ebp, %edx
movq 0x10(%rsp), %rax
callq *0x18(%rax)
cmpl %ebx, %ebp
jbe 0x6f57
pushq $0x10
popq %rax
cmpl $0x1, %r15d
jne 0x6e8b
movq (%rsp), %rax
movzbl 0x18(%rax), %eax
movl 0x4(%r12), %r14d
subl %ebx, %r14d
cmpl %r14d, %eax
cmovbl %eax, %r14d
movl %r14d, %r13d
cmpb $0x1, %r15b
jne 0x6eb8
movq (%rsp), %rax
movzbl 0x18(%rax), %r13d
leal -0x1(%r13), %eax
testl %ebx, %eax
jne 0x6f6a
addl $0x4, %r13d
movq %r13, %rdi
callq 0x21d0
testq %rax, %rax
je 0x6f41
movq %rax, %rbp
movl %ebx, %esi
addq 0x18(%rsp), %rsi
movb $0x2, (%rax)
movb %r15b, 0x1(%rax)
movb %bh, 0x2(%rax)
movb %bl, 0x3(%rax)
movq %rax, %r12
addq $0x4, %r12
movq %r12, %rdi
movq %r14, %rdx
callq 0x21b0
cmpb $0x1, %r15b
jne 0x6f13
addq %r14, %r12
movq (%rsp), %rax
movzbl 0x18(%rax), %edx
subq %r14, %rdx
movq %r12, %rdi
movl $0xff, %esi
callq 0x2120
movq (%rsp), %rax
movl 0xc(%rax), %edi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x7110
movl %eax, %r12d
movq %rbp, %rdi
callq 0x2030
addl %r14d, %ebx
cmpl %r13d, %r12d
movq 0x20(%rsp), %r12
je 0x6e59
pushq $-0x1
popq %rbx
movq 0x8(%rsp), %rdi
movl %ebx, %esi
movl %ebx, %edx
movq 0x10(%rsp), %rax
callq *0x18(%rax)
jmp 0x6f59
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6087(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x290a(%rip), %rsi      # 0x9885
movl %ebx, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2180
jmp 0x6f41
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_read_memory
static int twi_read_memory(struct twi_privdata *twi,
                           uint8_t *buffer, uint8_t size,
                           uint8_t memtype, uint16_t address)
{
    uint8_t cmd[] = { CMD_READ_MEMORY, memtype, (address >> 8) & 0xFF, (address & 0xFF) };

    if (twi_write_retries(twi->fd, cmd, sizeof(cmd)) != sizeof(cmd))
    {
        return -1;
    }

    return (read(twi->fd, buffer, size) != size);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movl %r8d, %eax
movq %rdi, %r14
leaq 0xc(%rsp), %rsi
movb $0x2, (%rsi)
movb %cl, 0x1(%rsi)
movb %ah, 0xe(%rsp)
movb %al, 0x3(%rsi)
movl 0xc(%rdi), %edi
pushq $0x4
popq %rdx
callq 0x7110
cmpl $0x4, %eax
jne 0x7104
movl 0xc(%r14), %edi
movzbl %bpl, %r14d
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2150
movq %rax, %rcx
xorl %eax, %eax
cmpq %r14, %rcx
setne %al
jmp 0x7107
pushq $-0x1
popq %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/orempel[P]multiboot_tool/twiboot.c
// Function: twi_write_retries
static int twi_write_retries(int fd, const void *buf, size_t count)
{
    int result;
    int retries = WRITE_RETRY_COUNT;
    do {
        result = write(fd, buf, count);
        if (result >= 0)
        {
            break;
        }
        else
        {
            /*
             * slave device does not acknowledge (eg. not able to clockstretch)
             * actual error code may be driver specific
             */
            if ((errno == ENXIO) || (errno == EREMOTEIO) || (errno == EIO))
            {
                usleep(WRITE_RETRY_DELAY_US);
            }
            else
            {
                fprintf(stderr, "twi_write_retries(): %s\n",
                        strerror(errno));

                retries = 0;
            }
        }
    } while (retries--);

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
pushq $-0x33
popq %r12
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2090
movq %rax, %rbx
testl %ebx, %ebx
jns 0x715b
callq 0x2060
movl (%rax), %edi
leal -0x5(%rdi), %eax
cmpl $0x2, %eax
jb 0x714c
cmpl $0x79, %edi
jne 0x7166
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x22c0
incl %r12d
jne 0x7124
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x5e8b(%rip), %rax      # 0xcff8
movq (%rax), %r14
callq 0x22a0
leaq 0x26f0(%rip), %rsi      # 0x986c
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2180
jmp 0x715b
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/../src/caching_ringbuffer.c
// Function: caching_ringbuffer_create
Ringbuffer* caching_ringbuffer_create(
        size_t capacity,
        void (*free_item)(void* item, void* additional_arg),
        void* free_item_additional_arg) {

    InternalRingbuffer* internal = calloc(1, sizeof(InternalRingbuffer));
    internal->cache =
    ringbuffer_create(capacity, free_item, free_item_additional_arg);
    internal->buffer = ringbuffer_create(capacity, cache_free, internal->cache);

    internal->public = (Ringbuffer) {
        .capacity = capacity_func,
        .add = add_func,
        .pop = pop_func,
        .free = free_func,
    };

    return (Ringbuffer*) internal;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x1050
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2448
movq %rax, 0x28(%r12)
leaq 0x4e(%rip), %rsi        # 0x1203
movq %r15, %rdi
movq %rax, %rdx
callq 0x2448
movq %rax, 0x20(%r12)
leaq 0x77(%rip), %rax        # 0x1243
movq %rax, (%r12)
leaq 0x7a(%rip), %rax        # 0x1251
movq %rax, 0x8(%r12)
leaq 0x85(%rip), %rax        # 0x1268
movq %rax, 0x10(%r12)
leaq 0x8d(%rip), %rax        # 0x127c
movq %rax, 0x18(%r12)
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/../src/caching_ringbuffer.c
// Function: cache_free
static void cache_free(void* item, void* cache) {

    if(0 == cache) goto finish;
    if(0 == item) goto finish;

    Ringbuffer* ringbuffer_cache = cache;

    if(! ringbuffer_cache->add(ringbuffer_cache, item)) {

        fprintf(stderr, "Could not enqueue item into cache");

    }

finish:

    do{}while(0);

}

// Assembly:
pushq %rax
movq %rsi, %rax
testq %rsi, %rsi
sete %cl
testq %rdi, %rdi
sete %dl
orb %cl, %dl
jne 0x1224
movq %rdi, %rsi
movq %rax, %rdi
callq *0x8(%rax)
testb %al, %al
je 0x1226
popq %rax
retq
movq 0x3dcb(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x2094(%rip), %rdi      # 0x32cb
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
popq %rax
jmp 0x1070
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/caching_ringbuffer_test.c
// Function: test_caching_ringbuffer_create
void test_caching_ringbuffer_create() {

    Ringbuffer* buffer = 0;

    buffer = caching_ringbuffer_create(1, 0, 0);
    assert(buffer);
    assert(capacity_func == buffer->capacity);
    assert(add_func == buffer->add);
    assert(pop_func == buffer->pop);
    assert(free_func == buffer->free);

    buffer = buffer->free(buffer);

    fprintf(stdout, "caching ringbuffer_create OK\n");

}

// Assembly:
pushq %rax
pushq $0x1
popq %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x117c
testq %rax, %rax
je 0x133e
leaq -0xa2(%rip), %rcx       # 0x1243
cmpq %rcx, (%rax)
jne 0x1357
leaq -0xa0(%rip), %rcx       # 0x1251
cmpq %rcx, 0x8(%rax)
jne 0x1370
leaq -0x96(%rip), %rcx       # 0x1268
cmpq %rcx, 0x10(%rax)
jne 0x1389
leaq -0x93(%rip), %rcx       # 0x127c
cmpq %rcx, 0x18(%rax)
jne 0x13a2
movq %rax, %rdi
callq 0x127c
movq 0x3cb0(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1d8a(%rip), %rdi      # 0x30bc
pushq $0x1d
popq %rsi
pushq $0x1
popq %rdx
popq %rax
jmp 0x1070
leaq 0x1cbf(%rip), %rdi      # 0x3004
leaq 0x1cbf(%rip), %rsi      # 0x300b
leaq 0x1cd7(%rip), %rcx      # 0x302a
pushq $0x43
jmp 0x13b9
leaq 0x1cf2(%rip), %rdi      # 0x3050
leaq 0x1ca6(%rip), %rsi      # 0x300b
leaq 0x1cbe(%rip), %rcx      # 0x302a
pushq $0x44
jmp 0x13b9
leaq 0x1cfb(%rip), %rdi      # 0x3072
leaq 0x1c8d(%rip), %rsi      # 0x300b
leaq 0x1ca5(%rip), %rcx      # 0x302a
pushq $0x45
jmp 0x13b9
leaq 0x1cfa(%rip), %rdi      # 0x308a
leaq 0x1c74(%rip), %rsi      # 0x300b
leaq 0x1c8c(%rip), %rcx      # 0x302a
pushq $0x46
jmp 0x13b9
leaq 0x1cf9(%rip), %rdi      # 0x30a2
leaq 0x1c5b(%rip), %rsi      # 0x300b
leaq 0x1c73(%rip), %rcx      # 0x302a
pushq $0x47
popq %rdx
callq 0x1040
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/caching_ringbuffer_test.c
// Function: test_caching_ringbuffer_release
void test_caching_ringbuffer_release() {

    int a = 0;

    assert(! caching_ringbuffer_release(0, &a));

    Ringbuffer* buffer = caching_ringbuffer_create(1, 0, 0);
    assert(caching_ringbuffer_release(buffer, &a));
    assert(&a == caching_ringbuffer_get_cached(buffer));
    buffer = buffer->free(buffer);

    fprintf(stdout, "caching ringbuffer_release OK\n");

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
andl $0x0, 0xc(%rsp)
pushq $0x1
popq %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x117c
testq %rax, %rax
je 0x1655
movq %rax, %rbx
movq 0x28(%rax), %r15
leaq 0xc(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq *0x8(%r15)
testb %al, %al
je 0x1655
movq %r15, %rdi
callq *0x10(%r15)
cmpq %rax, %r14
jne 0x166e
movq %rbx, %rdi
callq *0x18(%rbx)
movq 0x39a2(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1c07(%rip), %rdi      # 0x3247
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1070
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1b98(%rip), %rdi      # 0x31f4
leaq 0x19a8(%rip), %rsi      # 0x300b
leaq 0x1b63(%rip), %rcx      # 0x31cd
pushq $0x75
jmp 0x1685
leaq 0x1ba6(%rip), %rdi      # 0x321b
leaq 0x198f(%rip), %rsi      # 0x300b
leaq 0x1b4a(%rip), %rcx      # 0x31cd
pushq $0x76
popq %rdx
callq 0x1040
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/caching_ringbuffer_test.c
// Function: test_caching_free
void test_caching_free() {

    const size_t NUM_ELEMENTS = 114;
    size_t frees_count = 0;

    int test_data[NUM_ELEMENTS];

    for(size_t i = 0; i < NUM_ELEMENTS; ++i) {

        test_data[i] = i;

    }

    Ringbuffer* buffer =
        caching_ringbuffer_create(NUM_ELEMENTS / 2, count_free, &frees_count);

    size_t i = 0;

    while(10 > frees_count) {
        /* just some abritrary data that has been allocated dynamically */
        ++i;
        /* We want to create really new data buffers, thus cache == 0 ... */
        buffer->add(buffer, test_data + i);
    };

    const size_t initial_count = frees_count;

    /* Shift some elements out of cache into ringbuffer */
    for(i = 0; i < 3 * buffer->capacity(buffer); ++i) {
        void* item = caching_ringbuffer_get_cached(buffer);
        assert(item);
        buffer->add(buffer, item);
    }

    assert(initial_count == frees_count);
    assert(0 == buffer->free(buffer));

    fprintf(stdout, "free() OK: %zu\n", frees_count);

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsp, %r15
andq $0x0, 0x8(%rsp)
xorl %eax, %eax
cmpq $0x72, %rax
je 0x16b3
movl %eax, 0x10(%rsp,%rax,4)
incq %rax
jmp 0x16a4
leaq 0xf8(%rip), %rsi        # 0x17b2
pushq $0x39
popq %rdi
leaq 0x8(%rsp), %rdx
callq 0x117c
movq %rax, %rbx
leaq 0x14(%rsp), %r14
movq 0x8(%rsp), %r12
cmpq $0xa, %r12
jae 0x16e9
movq %rbx, %rdi
movq %r14, %rsi
callq *0x8(%rbx)
addq $0x4, %r14
jmp 0x16cf
xorl %r14d, %r14d
movq %rbx, %rdi
callq *(%rbx)
leaq (%rax,%rax,2), %rax
cmpq %rax, %r14
jae 0x1714
movq 0x28(%rbx), %rdi
callq *0x10(%rdi)
testq %rax, %rax
je 0x1755
movq %rbx, %rdi
movq %rax, %rsi
callq *0x8(%rbx)
incq %r14
jmp 0x16ec
cmpq 0x8(%rsp), %r12
jne 0x1774
movq %rbx, %rdi
callq *0x18(%rbx)
testq %rax, %rax
jne 0x1793
movq 0x38ab(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movq 0x8(%rsp), %rdx
leaq 0x1b7f(%rip), %rsi      # 0x32bb
xorl %eax, %eax
callq 0x1060
movq %r15, %rsp
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1b0a(%rip), %rdi      # 0x3266
leaq 0x18a8(%rip), %rsi      # 0x300b
leaq 0x1b01(%rip), %rcx      # 0x326b
movl $0x9c, %edx
callq 0x1040
leaq 0x1b09(%rip), %rdi      # 0x3284
leaq 0x1889(%rip), %rsi      # 0x300b
leaq 0x1ae2(%rip), %rcx      # 0x326b
movl $0xa0, %edx
callq 0x1040
leaq 0x1b07(%rip), %rdi      # 0x32a1
leaq 0x186a(%rip), %rsi      # 0x300b
leaq 0x1ac3(%rip), %rcx      # 0x326b
movl $0xa1, %edx
callq 0x1040
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/caching_ringbuffer_test.c
// Function: main
int main(int argc, char** argv) {

    /* The interface tests */
    size_t free_count = 0;

    create = caching_ringbuffer_create;

    Ringbuffer* cache = ringbuffer_create(31, count_free, &free_count);
    free_item = cache_free;
    free_item_additional_arg = cache;

    test_ringbuffer_create();
    test_capacity();
    test_add();
    test_pop();
    cache->free(cache);
    cache = 0;

    /* Caching tests */
    test_caching_ringbuffer_create();
    test_caching_ringbuffer_get_cached();
    test_caching_ringbuffer_release();
    test_caching_free();

}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0x8(%rsp), %rdx
andq $0x0, (%rdx)
leaq -0x654(%rip), %rax      # 0x117c
leaq 0x3879(%rip), %rcx      # 0x5050
movq %rax, (%rcx)
leaq -0x2f(%rip), %rsi       # 0x17b2
pushq $0x1f
popq %rdi
callq 0x2448
movq %rax, %rbx
leaq -0x5f0(%rip), %rax      # 0x1203
leaq 0x3866(%rip), %rcx      # 0x5060
movq %rax, (%rcx)
leaq 0x3864(%rip), %rax      # 0x5068
movq %rbx, (%rax)
xorl %eax, %eax
callq 0x1848
xorl %eax, %eax
callq 0x18c3
xorl %eax, %eax
callq 0x1951
xorl %eax, %eax
callq 0x1b8f
movq %rbx, %rdi
callq *0x18(%rbx)
callq 0x12cc
callq 0x13bf
callq 0x15e4
callq 0x168b
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/test_helper.c
// Function: test_ringbuffer_create
void test_ringbuffer_create() {

    Ringbuffer* buffer = 0;

    assert(0 == ringbuffer_create(0, 0, 0));

    buffer = ringbuffer_create(1, 0, 0);
    assert(buffer);

    buffer = buffer->free(buffer);

    fprintf(stdout, "ringbuffer_create OK\n");

}

// Assembly:
pushq %rax
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2448
testq %rax, %rax
jne 0x188d
pushq $0x1
popq %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2448
testq %rax, %rax
je 0x18a6
movq %rax, %rdi
callq *0x18(%rax)
movq 0x3761(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1843(%rip), %rdi      # 0x30c4
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
popq %rax
jmp 0x1070
leaq 0x1a59(%rip), %rdi      # 0x32ed
leaq 0x1a72(%rip), %rsi      # 0x330d
leaq 0x1a7e(%rip), %rcx      # 0x3320
pushq $0x36
jmp 0x18bd
leaq 0x1757(%rip), %rdi      # 0x3004
leaq 0x1a59(%rip), %rsi      # 0x330d
leaq 0x1a65(%rip), %rcx      # 0x3320
pushq $0x39
popq %rdx
callq 0x1040
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/test/test_helper.c
// Function: test_capacity
void test_capacity() {

    Ringbuffer* b = create(1, free_item, free_item_additional_arg);
    assert(1 == b->capacity(b));
    b = b->free(b);

    b = create(124, free_item, free_item_additional_arg);
    assert(124 == b->capacity(b));
    b = b->free(b);
}

// Assembly:
pushq %rbx
movq 0x3795(%rip), %rsi      # 0x5060
movq 0x3796(%rip), %rdx      # 0x5068
pushq $0x1
popq %rdi
callq *0x3775(%rip)           # 0x5050
movq %rax, %rbx
movq %rax, %rdi
callq *(%rax)
cmpq $0x1, %rax
jne 0x191b
movq %rbx, %rdi
callq *0x18(%rbx)
movq 0x376a(%rip), %rsi      # 0x5060
movq 0x376b(%rip), %rdx      # 0x5068
pushq $0x7c
popq %rdi
callq *0x374a(%rip)           # 0x5050
movq %rax, %rdi
movq %rax, %rbx
callq *(%rax)
cmpq $0x7c, %rax
jne 0x1934
movq %rbx, %rdi
popq %rbx
jmpq *0x18(%rdi)
leaq 0x1a1c(%rip), %rdi      # 0x333e
leaq 0x19e4(%rip), %rsi      # 0x330d
leaq 0x1a22(%rip), %rcx      # 0x3352
pushq $0x46
jmp 0x194b
leaq 0x1a2c(%rip), %rdi      # 0x3367
leaq 0x19cb(%rip), %rsi      # 0x330d
leaq 0x1a09(%rip), %rcx      # 0x3352
pushq $0x4a
popq %rdx
callq 0x1040
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/src/ringbuffer.c
// Function: ringbuffer_create
Ringbuffer* ringbuffer_create(
        size_t capacity,
        void (*free_item)(void* item, void* additional_arg),
        void* free_item_additional_arg) {

    if(0 >= capacity) {
        goto error;
    }

    Entry* list_start = calloc(1, sizeof(Entry));
    Entry* next = list_start;

    for(size_t i = 1; i < capacity; ++i) {

        next->next = calloc(1, sizeof(Entry));
        next = next->next;

    }

    next->next = list_start;

    InternalRingbuffer* buffer = calloc(1, sizeof(InternalRingbuffer));

    *buffer = (InternalRingbuffer) {
        .next_entry_to_write = list_start,
        .next_entry_to_read = list_start,
        .max_num_items = capacity,
        .free_item = free_item,
        .free_item_additional_arg = free_item_additional_arg,
    };

    buffer->public = (Ringbuffer) {
        .capacity = capacity_func,
        .add = add_func,
        .pop = pop_func,
        .free = free_func,
    };


    return (Ringbuffer*)buffer;

error:

    return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x2508
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq %rsi, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
pushq $0x1
popq %rbx
pushq $0x10
popq %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1050
movq %rax, %r14
movq %rbx, %r13
movq %rax, %r12
cmpq %r13, %r15
je 0x24a0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1050
movq %rax, 0x8(%r12)
incq %r13
jmp 0x2483
movq %r14, 0x8(%r12)
pushq $0x1
popq %rdi
pushq $0x48
popq %rsi
callq 0x1050
movq %r14, 0x20(%rax)
movq %r14, 0x28(%rax)
movq %r15, 0x30(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x38(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x40(%rax)
leaq 0x36(%rip), %rcx        # 0x250b
movq %rcx, (%rax)
leaq 0x39(%rip), %rcx        # 0x2518
movq %rcx, 0x8(%rax)
leaq 0x87(%rip), %rcx        # 0x2571
movq %rcx, 0x10(%rax)
leaq 0x9d(%rip), %rcx        # 0x2592
movq %rcx, 0x18(%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/src/ringbuffer.c
// Function: add_func
static bool add_func(Ringbuffer* self, void* item) {

    if(0 == self) goto error;

    InternalRingbuffer* internal = (InternalRingbuffer*) self;

    Entry* read = internal->next_entry_to_read;
    Entry* write = internal->next_entry_to_write;

    if((read == write) && (0 != read->next->item)) {
        internal->next_entry_to_read = read->next;
    }

    if((0 != write->item) && (0 != internal->free_item)) {
        internal->free_item(
                write->item,
                internal->free_item_additional_arg);
    }

    write->item = item;
    internal->next_entry_to_write = write->next;

    return true;

error:

    return false;

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
testq %rdi, %rdi
je 0x2565
movq %rsi, %r14
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %r15
cmpq %r15, %rax
jne 0x2543
movq 0x8(%rax), %rax
cmpq $0x0, (%rax)
je 0x2543
movq %rax, 0x20(%rbx)
movq (%r15), %rdi
testq %rdi, %rdi
je 0x255a
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x255a
movq 0x40(%rbx), %rsi
callq *%rax
movq %r14, (%r15)
movq 0x8(%r15), %rax
movq %rax, 0x28(%rbx)
testq %rbx, %rbx
setne %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/vidarr[P]ringbuffer/src/ringbuffer.c
// Function: free_func
static Ringbuffer* free_func(Ringbuffer* self) {

    if(0 == self) goto error;

    InternalRingbuffer* internal = (InternalRingbuffer*) self;

    Entry* current = internal->next_entry_to_write;
    Entry* start = current;

    do {

        Entry* next = current->next;

        if((0 != current->item) && (internal->free_item)) {

            internal->free_item(
                    current->item,
                    internal->free_item_additional_arg);

        }

        free(current);
        current = next;

    } while(current != start);

    free(self);
    self = 0;

error:

    return self;

}

// Assembly:
testq %rdi, %rdi
je 0x25e9
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %r15
movq %r15, %r12
movq %r12, %r14
movq (%r12), %rdi
movq 0x8(%r12), %r12
testq %rdi, %rdi
je 0x25c9
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x25c9
movq 0x40(%rbx), %rsi
callq *%rax
movq %r14, %rdi
callq 0x1030
cmpq %r15, %r12
jne 0x25a9
movq %rbx, %rdi
callq 0x1030
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_create_with_filename
plm_t *plm_create_with_filename(const char *filename) {
	plm_buffer_t *buffer = plm_buffer_create_with_filename(filename);
	if (!buffer) {
		return NULL;
	}
	return plm_create_with_buffer(buffer, TRUE);
}

// Assembly:
pushq %rax
callq 0x23c7
testq %rax, %rax
je 0x23c3
pushq $0x1
popq %rsi
movq %rax, %rdi
popq %rax
jmp 0x23e9
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_create_with_filename
plm_buffer_t *plm_buffer_create_with_filename(const char *filename) {
	FILE *fh = fopen(filename, "rb");
	if (!fh) {
		return NULL;
	}
	return plm_buffer_create_with_file(fh, TRUE);
}

// Assembly:
pushq %rax
leaq 0x72c9(%rip), %rsi      # 0x9698
callq 0x21b0
testq %rax, %rax
je 0x23e5
pushq $0x1
popq %rsi
movq %rax, %rdi
popq %rax
jmp 0x243e
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_create_with_buffer
plm_t *plm_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) {
	plm_t *self = (plm_t *)PLM_MALLOC(sizeof(plm_t));
	memset(self, 0, sizeof(plm_t));

	self->demux = plm_demux_create(buffer, destroy_when_done);
	self->video_enabled = TRUE;
	self->audio_enabled = TRUE;
	plm_init_decoders(self);

	return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
pushq $0x1
popq %rdi
movl $0x80, %esi
callq 0x2110
movq %rax, %r15
movq %r14, %rdi
movl %ebx, %esi
callq 0x24fe
movq %rax, (%r15)
pushq $0x1
popq %rax
movl %eax, 0x1c(%r15)
movl %eax, 0x38(%r15)
movq %r15, %rdi
callq 0x253e
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_create_with_file
plm_buffer_t *plm_buffer_create_with_file(FILE *fh, int close_when_done) {
	plm_buffer_t *self = plm_buffer_create_with_capacity(PLM_BUFFER_DEFAULT_SIZE);
	self->fh = fh;
	self->close_when_done = close_when_done;
	self->mode = PLM_BUFFER_MODE_FILE;
	self->discard_read_bytes = TRUE;
	
	fseek(self->fh, 0, SEEK_END);
	self->total_size = ftell(self->fh);
	fseek(self->fh, 0, SEEK_SET);

	self->load_callback = plm_buffer_load_file_callback;
	self->seek_callback = plm_buffer_seek_file_callback;
	self->tell_callback = plm_buffer_tell_file_callback;
	return self;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
movl $0x20000, %edi          # imm = 0x20000
callq 0x277f
movq %rax, %rbx
movq %r14, 0x30(%rax)
movl %ebp, 0x2c(%rax)
andl $0x0, 0x60(%rax)
movl $0x1, 0x20(%rax)
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2190
movq %r14, %rdi
callq 0x2030
movq %rax, 0x18(%rbx)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2190
leaq 0x153c(%rip), %rax      # 0x39ce
movq %rax, 0x38(%rbx)
leaq 0x1570(%rip), %rax      # 0x3a0d
movq %rax, 0x40(%rbx)
leaq 0x1570(%rip), %rax      # 0x3a18
movq %rax, 0x48(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_create_with_memory
plm_buffer_t *plm_buffer_create_with_memory(uint8_t *bytes, size_t length, int free_when_done) {
	plm_buffer_t *self = (plm_buffer_t *)PLM_MALLOC(sizeof(plm_buffer_t));
	memset(self, 0, sizeof(plm_buffer_t));
	self->capacity = length;
	self->length = length;
	self->total_size = length;
	self->free_when_done = free_when_done;
	self->bytes = bytes;
	self->mode = PLM_BUFFER_MODE_FIXED_MEM;
	self->discard_read_bytes = FALSE;
	return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
pushq $0x1
popq %rdi
pushq $0x68
popq %rsi
callq 0x2110
movq %r14, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r14, 0x18(%rax)
movl %ebx, 0x28(%rax)
movq %r15, 0x58(%rax)
movl $0x1, 0x60(%rax)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_create
plm_demux_t *plm_demux_create(plm_buffer_t *buffer, int destroy_when_done) {
	plm_demux_t *self = (plm_demux_t *)PLM_MALLOC(sizeof(plm_demux_t));
	memset(self, 0, sizeof(plm_demux_t));

	self->buffer = buffer;
	self->destroy_buffer_when_done = destroy_when_done;

	self->start_time = PLM_PACKET_INVALID_TS;
	self->duration = PLM_PACKET_INVALID_TS;
	self->start_code = -1;

	plm_demux_has_headers(self);
	return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
pushq $0x1
popq %rdi
movl $0x90, %esi
callq 0x2110
movq %rax, %r15
movq %r14, (%rax)
movl %ebx, 0x8(%rax)
movaps 0x5aeb(%rip), %xmm0     # 0x8010
movups %xmm0, 0x28(%rax)
orl $-0x1, 0x38(%rax)
movq %rax, %rdi
callq 0x2619
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_init_decoders
int plm_init_decoders(plm_t *self) {
	if (self->has_decoders) {
		return TRUE;
	}

	if (!plm_demux_has_headers(self->demux)) {
		return FALSE;
	}

	if (plm_demux_get_num_video_streams(self->demux) > 0) {
		if (self->video_enabled) {
			self->video_packet_type = PLM_DEMUX_PACKET_VIDEO_1;
		}
		if (!self->video_decoder) {
			self->video_buffer = plm_buffer_create_with_capacity(PLM_BUFFER_DEFAULT_SIZE);
			plm_buffer_set_load_callback(self->video_buffer, plm_read_video_packet, self);
			self->video_decoder = plm_video_create_with_buffer(self->video_buffer, TRUE);
		}
	}

	if (plm_demux_get_num_audio_streams(self->demux) > 0) {
		if (self->audio_enabled) {
			self->audio_packet_type = PLM_DEMUX_PACKET_AUDIO_1 + self->audio_stream_index;
		}
		if (!self->audio_decoder) {
			self->audio_buffer = plm_buffer_create_with_capacity(PLM_BUFFER_DEFAULT_SIZE);
			plm_buffer_set_load_callback(self->audio_buffer, plm_read_audio_packet, self);
			self->audio_decoder = plm_audio_create_with_buffer(self->audio_buffer, TRUE);
		}
	}

	self->has_decoders = TRUE;
	return TRUE;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
pushq $0x1
popq %rbx
cmpl $0x0, 0x18(%rdi)
jne 0x260f
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x2619
testl %eax, %eax
je 0x260d
movq (%r14), %rdi
callq 0x2769
testl %eax, %eax
jle 0x25b0
cmpl $0x0, 0x1c(%r14)
je 0x257d
movl $0xe0, 0x20(%r14)
cmpq $0x0, 0x30(%r14)
jne 0x25b0
movl $0x20000, %edi          # imm = 0x20000
callq 0x277f
movq %rax, 0x28(%r14)
leaq 0x22e(%rip), %rcx       # 0x27c7
movq %rcx, 0x38(%rax)
movq %r14, 0x50(%rax)
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x27d2
movq %rax, 0x30(%r14)
movq (%r14), %rdi
callq 0x281d
testl %eax, %eax
jle 0x2603
cmpl $0x0, 0x38(%r14)
je 0x25d0
movl $0xc0, %eax
addl 0x3c(%r14), %eax
movl %eax, 0x40(%r14)
cmpq $0x0, 0x58(%r14)
jne 0x2603
movl $0x20000, %edi          # imm = 0x20000
callq 0x277f
movq %rax, 0x50(%r14)
leaq 0x247(%rip), %rcx       # 0x2833
movq %rcx, 0x38(%rax)
movq %r14, 0x50(%rax)
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x283e
movq %rax, 0x58(%r14)
movl $0x1, 0x18(%r14)
jmp 0x260f
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_has_headers
int plm_demux_has_headers(plm_demux_t *self) {
	if (self->has_headers) {
		return TRUE;
	}

	// Decode pack header
	if (!self->has_pack_header) {
		if (
			self->start_code != PLM_START_PACK &&
			plm_buffer_find_start_code(self->buffer, PLM_START_PACK) == -1
		) {
			return FALSE;
		}

		self->start_code = PLM_START_PACK;
		if (!plm_buffer_has(self->buffer, 64)) {
			return FALSE;
		}
		self->start_code = -1;

		if (plm_buffer_read(self->buffer, 4) != 0x02) {
			return FALSE;
		}

		self->system_clock_ref = plm_demux_decode_time(self);
		plm_buffer_skip(self->buffer, 1);
		plm_buffer_skip(self->buffer, 22); // mux_rate * 50
		plm_buffer_skip(self->buffer, 1);

		self->has_pack_header = TRUE;
	}

	// Decode system header
	if (!self->has_system_header) {
		if (
			self->start_code != PLM_START_SYSTEM &&
			plm_buffer_find_start_code(self->buffer, PLM_START_SYSTEM) == -1
		) {
			return FALSE;
		}

		self->start_code = PLM_START_SYSTEM;
		if (!plm_buffer_has(self->buffer, 56)) {
			return FALSE;
		}
		self->start_code = -1;

		plm_buffer_skip(self->buffer, 16); // header_length
		plm_buffer_skip(self->buffer, 24); // rate bound
		self->num_audio_streams = plm_buffer_read(self->buffer, 6);
		plm_buffer_skip(self->buffer, 5); // misc flags
		self->num_video_streams = plm_buffer_read(self->buffer, 5);

		self->has_system_header = TRUE;
	}

	self->has_headers = TRUE;
	return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
pushq $0x1
popq %r15
cmpl $0x0, 0x44(%rdi)
jne 0x26cd
movq %rdi, %rbx
cmpl $0x0, 0x3c(%rdi)
je 0x26dd
cmpl $0x0, 0x40(%rbx)
jne 0x26c6
cmpl $0xbb, 0x38(%rbx)
je 0x2664
movq (%rbx), %rdi
movl $0xbb, %esi
callq 0x3d76
cmpl $-0x1, %eax
je 0x2762
movl $0xbb, 0x38(%rbx)
movq (%rbx), %rdi
pushq $0x38
popq %rsi
callq 0x3b9d
testl %eax, %eax
je 0x2762
orl $-0x1, 0x38(%rbx)
movq (%rbx), %rdi
pushq $0x10
popq %rsi
callq 0x3c94
movq (%rbx), %rdi
pushq $0x18
popq %rsi
callq 0x3c94
movq (%rbx), %rdi
pushq $0x6
popq %rsi
callq 0x3c08
movl %eax, 0x48(%rbx)
movq (%rbx), %rdi
pushq $0x5
popq %rsi
callq 0x3c94
movq (%rbx), %rdi
pushq $0x5
popq %rsi
callq 0x3c08
movl %eax, 0x4c(%rbx)
movl $0x1, 0x40(%rbx)
movl $0x1, 0x44(%rbx)
movl %r15d, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0xba, 0x38(%rbx)
je 0x26f8
movq (%rbx), %rdi
movl $0xba, %esi
callq 0x3d76
cmpl $-0x1, %eax
je 0x2762
movl $0xba, 0x38(%rbx)
movq (%rbx), %rdi
pushq $0x40
popq %rsi
callq 0x3b9d
xorl %ebp, %ebp
testl %eax, %eax
je 0x26d0
orl $-0x1, 0x38(%rbx)
movq (%rbx), %rdi
pushq $0x4
popq %rsi
callq 0x3c08
cmpl $0x2, %eax
jne 0x26d0
movq %rbx, %rdi
callq 0x3e39
movsd %xmm0, 0x10(%rbx)
movq (%rbx), %rdi
pushq $0x1
popq %r14
movq %r14, %rsi
callq 0x3c94
movq (%rbx), %rdi
pushq $0x16
popq %rsi
callq 0x3c94
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x3c94
movl $0x1, 0x3c(%rbx)
jmp 0x263b
xorl %ebp, %ebp
jmp 0x26d0
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_create_with_capacity
plm_buffer_t *plm_buffer_create_with_capacity(size_t capacity) {
	plm_buffer_t *self = (plm_buffer_t *)PLM_MALLOC(sizeof(plm_buffer_t));
	memset(self, 0, sizeof(plm_buffer_t));
	self->capacity = capacity;
	self->free_when_done = TRUE;
	self->bytes = (uint8_t *)PLM_MALLOC(capacity);
	self->mode = PLM_BUFFER_MODE_RING;
	self->discard_read_bytes = TRUE;
	return self;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
pushq $0x1
popq %rdi
pushq $0x68
popq %rsi
callq 0x2110
movq %rax, %r14
movq %rbx, 0x8(%rax)
pushq $0x1
popq %rbp
movl %ebp, 0x28(%rax)
movq %rbx, %rdi
callq 0x2210
movq %rax, 0x58(%r14)
movl $0x2, 0x60(%r14)
movl %ebp, 0x20(%r14)
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_create_with_buffer
plm_video_t * plm_video_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) {
	plm_video_t *self = (plm_video_t *)PLM_MALLOC(sizeof(plm_video_t));
	memset(self, 0, sizeof(plm_video_t));
	
	self->buffer = buffer;
	self->destroy_buffer_when_done = destroy_when_done;

	// Attempt to decode the sequence header
	self->start_code = plm_buffer_find_start_code(self->buffer, PLM_START_SEQUENCE);
	if (self->start_code != -1) {
		plm_video_decode_sequence_header(self);
	}
	return self;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
pushq $0x1
popq %rdi
movl $0x300, %esi            # imm = 0x300
callq 0x2110
movq %rax, %rbx
movq %r14, 0xa0(%rax)
movl %ebp, 0xa8(%rax)
movq %r14, %rdi
movl $0xb3, %esi
callq 0x3d76
movl %eax, 0x40(%rbx)
cmpl $-0x1, %eax
je 0x2815
movq %rbx, %rdi
callq 0x402b
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_audio_create_with_buffer
plm_audio_t *plm_audio_create_with_buffer(plm_buffer_t *buffer, int destroy_when_done) {
	plm_audio_t *self = (plm_audio_t *)PLM_MALLOC(sizeof(plm_audio_t));
	memset(self, 0, sizeof(plm_audio_t));

	self->samples.count = PLM_AUDIO_SAMPLES_PER_FRAME;
	self->buffer = buffer;
	self->destroy_buffer_when_done = destroy_when_done;
	self->samplerate_index = 3; // Indicates 0

	memcpy(self->D, PLM_AUDIO_SYNTHESIS_WINDOW, 512 * sizeof(float));
	memcpy(self->D + 512, PLM_AUDIO_SYNTHESIS_WINDOW, 512 * sizeof(float));

	// Attempt to decode first header
	self->next_frame_data_size = plm_audio_decode_header(self);

	return self;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
pushq $0x1
popq %rdi
movl $0x5d10, %esi           # imm = 0x5D10
callq 0x2110
movq %rax, %rbx
movl $0x480, 0x888(%rax)     # imm = 0x480
movq %r14, 0x30(%rax)
movl %ebp, 0x38(%rax)
movl $0x3, 0xc(%rax)
leaq 0x2c90(%rax), %rdi
leaq 0x6333(%rip), %r14      # 0x8bb0
movl $0x800, %edx            # imm = 0x800
movq %r14, %rsi
callq 0x2140
leaq 0x3490(%rbx), %rdi
movl $0x800, %edx            # imm = 0x800
movq %r14, %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x6596
movl %eax, 0x28(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_destroy
void plm_destroy(plm_t *self) {
	if (self->video_decoder) {
		plm_video_destroy(self->video_decoder);
	}
	if (self->audio_decoder) {
		plm_audio_destroy(self->audio_decoder);
	}

	plm_demux_destroy(self->demux);
	PLM_FREE(self);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
testq %rdi, %rdi
je 0x28c3
callq 0x28e2
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x28d1
callq 0x2916
movq (%rbx), %rdi
callq 0x2932
movq %rbx, %rdi
popq %rbx
jmp 0x21c0
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_destroy
void plm_video_destroy(plm_video_t *self) {
	if (self->destroy_buffer_when_done) {
		plm_buffer_destroy(self->buffer);
	}

	if (self->has_sequence_header) {
		PLM_FREE(self->frames_data);
	}

	PLM_FREE(self);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0xa8(%rdi)
je 0x28fb
movq 0xa0(%rbx), %rdi
callq 0x3a78
cmpl $0x0, 0x70(%rbx)
je 0x290d
movq 0x170(%rbx), %rdi
callq 0x21c0
movq %rbx, %rdi
popq %rbx
jmp 0x21c0
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_has_headers
int plm_has_headers(plm_t *self) {
	if (!plm_demux_has_headers(self->demux)) {
		return FALSE;
	}
	
	if (!plm_init_decoders(self)) {
		return FALSE;
	}

	if (
		(self->video_decoder && !plm_video_has_header(self->video_decoder)) ||
		(self->audio_decoder && !plm_audio_has_header(self->audio_decoder))
	) {
		return FALSE;
	}

	return TRUE;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x2619
xorl %ebx, %ebx
testl %eax, %eax
je 0x2999
movq %r14, %rdi
callq 0x253e
testl %eax, %eax
je 0x2999
movq 0x30(%r14), %rdi
testq %rdi, %rdi
je 0x2984
callq 0x29a3
testl %eax, %eax
je 0x2999
movq 0x58(%r14), %rdi
testq %rdi, %rdi
je 0x2996
callq 0x29e1
testl %eax, %eax
je 0x2999
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_has_header
int plm_video_has_header(plm_video_t *self) {
	if (self->has_sequence_header) {
		return TRUE;
	}

	if (self->start_code != PLM_START_SEQUENCE) {
		self->start_code = plm_buffer_find_start_code(self->buffer, PLM_START_SEQUENCE);
	}
	if (self->start_code == -1) {
		return FALSE;
	}
	
	if (!plm_video_decode_sequence_header(self)) {
		return FALSE;
	}

	return TRUE;
}

// Assembly:
pushq %rbx
cmpl $0x0, 0x70(%rdi)
je 0x29af
pushq $0x1
popq %rax
popq %rbx
retq
movq %rdi, %rbx
cmpl $0xb3, 0x40(%rdi)
je 0x29d4
movq 0xa0(%rbx), %rdi
movl $0xb3, %esi
callq 0x3d76
movl %eax, 0x40(%rbx)
cmpl $-0x1, %eax
je 0x29dd
movq %rbx, %rdi
popq %rbx
jmp 0x402b
xorl %eax, %eax
jmp 0x29ad
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_probe
int plm_probe(plm_t *self, size_t probesize) {
	int found_streams = plm_demux_probe(self->demux, probesize);
	if (!found_streams) {
		return FALSE;
	}

	// Re-init decoders
	self->has_decoders = FALSE;
	self->video_packet_type = 0;
	self->audio_packet_type = 0;
	return plm_init_decoders(self);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2a25
testl %eax, %eax
je 0x2a21
andl $0x0, 0x18(%rbx)
andl $0x0, 0x20(%rbx)
andl $0x0, 0x40(%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x253e
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_probe
int plm_demux_probe(plm_demux_t *self, size_t probesize) {
	int previous_pos = plm_buffer_tell(self->buffer);

	int video_stream = FALSE;
	int audio_streams[4] = {FALSE, FALSE, FALSE, FALSE};
	do {
		self->start_code = plm_buffer_next_start_code(self->buffer);
		if (self->start_code == PLM_DEMUX_PACKET_VIDEO_1) {
			video_stream = TRUE;
		}
		else if (
			self->start_code >= PLM_DEMUX_PACKET_AUDIO_1 && 
			self->start_code <= PLM_DEMUX_PACKET_AUDIO_4
		) {
			audio_streams[self->start_code - PLM_DEMUX_PACKET_AUDIO_1] = TRUE;
		}
	} while (
		self->start_code != -1 && 
		plm_buffer_tell(self->buffer) - previous_pos < probesize
	);

	self->num_video_streams = video_stream ? 1 : 0;
	self->num_audio_streams = 0;
	for (int i = 0; i < 4; i++) {
		if (audio_streams[i]) {
			self->num_audio_streams++;
		}
	}

	plm_demux_buffer_seek(self, previous_pos);
	return (self->num_video_streams || self->num_audio_streams);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3b67
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movslq %eax, %r14
xorl %r12d, %r12d
pushq $0x1
popq %rbp
movq (%rbx), %rdi
callq 0x3d0c
movl %eax, 0x38(%rbx)
movl %ebp, %r13d
cmpl $0xe0, %eax
je 0x2a8c
movl %eax, %ecx
andl $-0x4, %ecx
cmpl $0xc0, %ecx
jne 0x2a84
addl $0xffffff40, %eax       # imm = 0xFFFFFF40
movl $0x1, (%rsp,%rax,4)
movl %r12d, %r13d
jmp 0x2a8c
movl %r12d, %r13d
cmpl $-0x1, %eax
je 0x2a9f
movq (%rbx), %rdi
callq 0x3b67
subq %r14, %rax
movl %r13d, %r12d
cmpq %r15, %rax
jb 0x2a51
xorl %eax, %eax
testl %r12d, %r12d
setne %al
movl %eax, 0x4c(%rbx)
andl $0x0, 0x48(%rbx)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x4, %rcx
je 0x2ac8
cmpl $0x0, (%rsp,%rcx,4)
je 0x2ac3
incl %eax
movl %eax, 0x48(%rbx)
incq %rcx
jmp 0x2ab2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3eb7
cmpl $0x0, 0x4c(%rbx)
je 0x2ade
pushq $0x1
popq %rax
jmp 0x2ae7
xorl %eax, %eax
cmpl $0x0, 0x48(%rbx)
setne %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_set_audio_enabled
void plm_set_audio_enabled(plm_t *self, int enabled) {
	self->audio_enabled = enabled;

	if (!enabled) {
		self->audio_packet_type = 0;
		return;
	}

	self->audio_packet_type = (plm_init_decoders(self) && self->audio_decoder)
		? PLM_DEMUX_PACKET_AUDIO_1 + self->audio_stream_index
		: 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, 0x38(%rdi)
xorl %ebp, %ebp
testl %esi, %esi
je 0x2b20
movq %rbx, %rdi
callq 0x253e
testl %eax, %eax
je 0x2b20
cmpq $0x0, 0x58(%rbx)
je 0x2b20
movl $0xc0, %ebp
addl 0x3c(%rbx), %ebp
movl %ebp, 0x40(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_set_video_enabled
void plm_set_video_enabled(plm_t *self, int enabled) {
	self->video_enabled = enabled;

	if (!enabled) {
		self->video_packet_type = 0;
		return;
	}

	self->video_packet_type = (plm_init_decoders(self) && self->video_decoder)
		? PLM_DEMUX_PACKET_VIDEO_1
		: 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, 0x1c(%rdi)
xorl %ebp, %ebp
testl %esi, %esi
je 0x2b69
movq %rbx, %rdi
callq 0x253e
testl %eax, %eax
je 0x2b69
xorl %eax, %eax
cmpq $0x0, 0x30(%rbx)
movl $0xe0, %ebp
cmovel %eax, %ebp
movl %ebp, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq