LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: transfer_spi
static int transfer_spi(const uint8_t *tx_buf, uint8_t *rx_buf, uint16_t len) {
    assert(spi > 0);
    assert(len > 0);
    assert(len <= 31);  //  CAUTION: CH341 SPI doesn't seem to support 32-byte SPI transfers 

    //  Prepare SPI Transfer
    struct spi_ioc_transfer spi_trans;
    memset(&spi_trans, 0, sizeof(spi_trans));
    spi_trans.tx_buf = (unsigned long) tx_buf;  //  Transmit Buffer
    spi_trans.rx_buf = (unsigned long) rx_buf;  //  Receive Buffer
    spi_trans.cs_change = true;   //  Set SPI Chip Select to Low
    spi_trans.len       = len;    //  How many bytes
    printf("spi tx: "); for (int i = 0; i < len; i++) { printf("%02x ", tx_buf[i]); } printf("\n");

    //  Transfer and receive the SPI buffers
    int rc = ioctl(spi, SPI_IOC_MESSAGE(1), &spi_trans);
    assert(rc >= 0);
    assert(rc == len);

    printf("spi rx: "); for (int i = 0; i < len; i++) { printf("%02x ", rx_buf[i]); } printf("\n");
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x0, 0x5bc2(%rip)      # 0xacc0
jle 0x51ed
testw %di, %di
je 0x520c
cmpw $0x20, %di
jae 0x522b
movzwl %di, %r14d
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq 0x5393(%rip), %r12      # 0xa4c0
movq %r12, -0x50(%rbp)
leaq 0x5788(%rip), %r15      # 0xa8c0
movq %r15, -0x48(%rbp)
movb $0x1, -0x35(%rbp)
movl %r14d, -0x40(%rbp)
leaq 0x185f(%rip), %rdi      # 0x69aa
xorl %eax, %eax
callq 0x2050
leaq 0xf23(%rip), %rbx       # 0x607c
xorl %r13d, %r13d
movzbl (%r13,%r12), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
incq %r13
cmpq %r13, %r14
jne 0x515c
movl $0xa, %edi
callq 0x21c0
movl 0x5b3c(%rip), %edi      # 0xacc0
leaq -0x50(%rbp), %rdx
movl $0x40206b00, %esi       # imm = 0x40206B00
xorl %eax, %eax
callq 0x21e0
testl %eax, %eax
js 0x524a
cmpl %r14d, %eax
jne 0x5269
leaq 0x1819(%rip), %rdi      # 0x69c5
xorl %eax, %eax
callq 0x2050
leaq 0xec2(%rip), %rbx       # 0x607c
xorl %r12d, %r12d
movzbl (%r12,%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
incq %r12
cmpq %r12, %r14
jne 0x51bd
movl $0xa, %edi
callq 0x21c0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x176d(%rip), %rdi      # 0x6961
leaq 0x1527(%rip), %rsi      # 0x6722
leaq 0x1767(%rip), %rcx      # 0x6969
movl $0x29f, %edx            # imm = 0x29F
callq 0x20f0
leaq 0x16ca(%rip), %rdi      # 0x68dd
leaq 0x1508(%rip), %rsi      # 0x6722
leaq 0x1748(%rip), %rcx      # 0x6969
movl $0x2a0, %edx            # imm = 0x2A0
callq 0x20f0
leaq 0x176e(%rip), %rdi      # 0x69a0
leaq 0x14e9(%rip), %rsi      # 0x6722
leaq 0x1729(%rip), %rcx      # 0x6969
movl $0x2a1, %edx            # imm = 0x2A1
callq 0x20f0
leaq 0x1762(%rip), %rdi      # 0x69b3
leaq 0x14ca(%rip), %rsi      # 0x6722
leaq 0x170a(%rip), %rcx      # 0x6969
movl $0x2ae, %edx            # imm = 0x2AE
callq 0x20f0
leaq 0x174b(%rip), %rdi      # 0x69bb
leaq 0x14ab(%rip), %rsi      # 0x6722
leaq 0x16eb(%rip), %rcx      # 0x6969
movl $0x2af, %edx            # imm = 0x2AF
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_callout.c
// Function: ble_npl_callout_init
void ble_npl_callout_init(struct ble_npl_callout *c, 
                          struct ble_npl_eventq *evq,
                          ble_npl_event_fn *ev_cb, 
                          void *ev_arg)
{
    struct sigevent         event;

    /* Initialize the callout. */
    memset(c, 0, sizeof(*c));
    c->c_ev.ev_cb = ev_cb;
    c->c_ev.ev_arg = ev_arg;
    c->c_evq = evq;
    c->c_active = false;

    event.sigev_notify = SIGEV_THREAD;
    event.sigev_value.sival_ptr = c;     // put callout obj in signal args
    event.sigev_notify_function = ble_npl_callout_timer_cb;
    event.sigev_notify_attributes = NULL;

    timer_create(CLOCK_REALTIME, &event, &c->c_timer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movups %xmm0, 0x10(%rdi)
xorl %eax, %eax
movq %rax, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movq %rdx, 0x8(%rdi)
movq %rcx, 0x10(%rdi)
movq %rsi, 0x18(%rdi)
movb $0x0, 0x30(%rdi)
leaq -0x40(%rbp), %rsi
movl $0x2, 0xc(%rsi)
movq %rdi, (%rsi)
leaq 0x19(%rip), %rcx        # 0x52e2
movq %rcx, 0x10(%rsi)
movq %rax, 0x18(%rsi)
leaq 0x28(%rdi), %rdx
xorl %edi, %edi
callq 0x2080
addq $0x40, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_callout.c
// Function: ble_npl_callout_timer_cb
static void
ble_npl_callout_timer_cb(union sigval sv)
{
    struct ble_npl_callout *c = (struct ble_npl_callout *)sv.sival_ptr;
    assert(c);

    if (c->c_evq) {
        ble_npl_eventq_put(c->c_evq, &c->c_ev);
    } else {
        c->c_ev.ev_cb(&c->c_ev);
    }
}

// Assembly:
testq %rdi, %rdi
je 0x52fd
movq %rdi, %rsi
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
jne 0x247b
movq %rsi, %rdi
jmpq *0x8(%rsi)
pushq %rbp
movq %rsp, %rbp
leaq 0x1891(%rip), %rdi      # 0x6b99
leaq 0x182a(%rip), %rsi      # 0x6b39
leaq 0x183e(%rip), %rcx      # 0x6b54
movl $0x22, %edx
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_callout.c
// Function: ble_npl_callout_reset
ble_npl_error_t ble_npl_callout_reset(struct ble_npl_callout *c,
				      ble_npl_time_t ticks)
{
    struct itimerspec       its;

    if (ticks < 0) {
        return BLE_NPL_EINVAL;
    }

    if (ticks == 0) {
        ticks = 1;
    }

    c->c_ticks = ble_npl_time_get() + ticks;

    its.it_interval.tv_sec = 0;
    its.it_interval.tv_nsec = 0;                     // one shot
    its.it_value.tv_sec = (ticks / 1000);
    its.it_value.tv_nsec = (ticks % 1000) * 1000000; // expiration
    its.it_value.tv_nsec %= 1000000000;
    c->c_active = true;
    timer_settime(c->c_timer, 0, &its, NULL);

    return BLE_NPL_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %r14d
movq %rdi, %rbx
cmpl $0x1, %esi
adcl $0x0, %r14d
callq 0x56ac
addl %r14d, %eax
movl %eax, 0x20(%rbx)
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rdx
movaps %xmm0, (%rdx)
imulq $0x10624dd3, %r14, %rax # imm = 0x10624DD3
shrq $0x26, %rax
movq %rax, 0x10(%rdx)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r14d
imull $0xf4240, %r14d, %eax   # imm = 0xF4240
imulq $0x44b82fa1, %rax, %rcx # imm = 0x44B82FA1
shrq $0x3c, %rcx
imull $0x3b9aca00, %ecx, %ecx # imm = 0x3B9ACA00
subl %ecx, %eax
movq %rax, 0x18(%rdx)
movb $0x1, 0x30(%rbx)
movq 0x28(%rbx), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2270
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_callout.c
// Function: ble_npl_callout_stop
void ble_npl_callout_stop(struct ble_npl_callout *c)
{
    if (!ble_npl_callout_inited(c)) {
        return;
    }

    struct itimerspec its;
    its.it_interval.tv_sec = 0;
    its.it_interval.tv_nsec = 0;
    its.it_value.tv_sec = 0;
    its.it_value.tv_nsec = 0;
    timer_settime(c->c_timer, 0, &its, NULL);
    c->c_active = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x541d
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rdx
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2270
movb $0x0, 0x30(%rbx)
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_callout.c
// Function: ble_npl_callout_remaining_ticks
uint32_t
ble_npl_callout_remaining_ticks(struct ble_npl_callout *co,
                                ble_npl_time_t now)
{
    ble_npl_time_t rt;
    uint32_t exp;

    struct itimerspec its;
    timer_gettime(co->c_timer, &its);

    exp = its.it_value.tv_sec * 1000;

    if (exp > now) {
        rt = exp - now;
    } else {
        rt = 0;
    }

    return rt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebx
movq 0x28(%rdi), %rdi
leaq -0x30(%rbp), %r14
movq %r14, %rsi
callq 0x20b0
imull $0x3e8, 0x10(%r14), %eax # imm = 0x3E8
xorl %ecx, %ecx
subl %ebx, %eax
cmovbl %ecx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_sem.c
// Function: ble_npl_sem_pend
ble_npl_error_t
ble_npl_sem_pend(struct ble_npl_sem *sem, uint32_t timeout)
{
    int err = 0;
    struct timespec wait;

    if (!sem) {
        return BLE_NPL_INVALID_PARAM;
    }

    if (timeout == BLE_NPL_TIME_FOREVER) {
        err = sem_wait(&sem->lock);
    } else {
        err = clock_gettime(CLOCK_REALTIME, &wait);
        if (err) {
            return BLE_NPL_ERROR;
        }

        wait.tv_sec  += timeout / 1000;
        wait.tv_nsec += (timeout % 1000) * 1000000;

        err = sem_timedwait(&sem->lock, &wait);
        if (err && errno == ETIMEDOUT) {
            return BLE_NPL_TIMEOUT;
        }
    }

    return (err) ? BLE_NPL_ERROR : BLE_NPL_OK;
}

// Assembly:
testq %rdi, %rdi
je 0x54e9
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %r14d
movq %rdi, %rbx
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
jne 0x54ef
movq %rbx, %rdi
callq 0x20e0
movl %eax, %ecx
testl %eax, %eax
movl $0xc, %eax
cmovel %ecx, %eax
jmp 0x5505
movl $0x3, %eax
retq
leaq -0x20(%rbp), %rsi
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movl $0xc, %eax
testl %ecx, %ecx
je 0x550e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl %r14d, %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
shrq $0x26, %rax
leaq -0x20(%rbp), %rsi
addq %rax, (%rsi)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r14d
imull $0xf4240, %r14d, %eax   # imm = 0xF4240
addq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0x2290
movl %eax, %ecx
movl $0x0, %eax
testl %ecx, %ecx
je 0x5505
callq 0x2040
cmpl $0x6e, (%rax)
movl $0x6, %ecx
jmp 0x54df
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_sem.c
// Function: ble_npl_sem_get_count
uint16_t
ble_npl_sem_get_count(struct ble_npl_sem *sem)
{
    int count;

    assert(sem);
    assert(&sem->lock);
    sem_getvalue(&sem->lock, &count);

    return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x557a
leaq -0xc(%rbp), %rbx
movq %rbx, %rsi
callq 0x2240
movzwl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x15ff(%rip), %rdi      # 0x6b80
leaq 0x15fc(%rip), %rsi      # 0x6b84
leaq 0x160c(%rip), %rcx      # 0x6b9b
movl $0x58, %edx
callq 0x20f0
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_task.c
// Function: ble_npl_task_init
int
ble_npl_task_init(struct ble_npl_task *t, const char *name, ble_npl_task_func_t func,
        void *arg, uint8_t prio, ble_npl_time_t sanity_itvl,
        ble_npl_stack_t *stack_bottom, uint16_t stack_size)
{
    int err;
    if ((t == NULL) || (func == NULL)) {
        return OS_INVALID_PARM;
    }

    err = pthread_attr_init(&t->attr);
    if (err) return err;
    err = pthread_attr_getschedparam (&t->attr, &t->param);
    if (err) return err;
    err = pthread_attr_setschedpolicy(&t->attr, SCHED_RR);
    if (err) return err;
    t->param.sched_priority = prio;
    err = pthread_attr_setschedparam (&t->attr, &t->param);
    if (err) return err;

    t->name = name;
    err = pthread_create(&t->handle, &t->attr, func, arg);

    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
testq %rdi, %rdi
sete %al
testq %rdx, %rdx
sete %dl
orb %al, %dl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x561d
movl %r8d, %r13d
movq %rsi, %r12
movq %rdi, %r15
movq %rcx, -0x38(%rbp)
leaq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq 0x21a0
testl %eax, %eax
jne 0x561d
leaq 0x40(%r15), %rsi
movq %rbx, %rdi
movq %rsi, -0x30(%rbp)
callq 0x22d0
testl %eax, %eax
jne 0x561d
movq %rbx, %rdi
movl $0x2, %esi
callq 0x21b0
testl %eax, %eax
jne 0x561d
movzbl %r13b, %eax
movq -0x30(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x20c0
testl %eax, %eax
je 0x562c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x48(%r15)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq -0x38(%rbp), %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_time.c
// Function: ble_npl_time_delay
void
ble_npl_time_delay(ble_npl_time_t ticks)
{
    struct timespec sleep_time;
    long ms = ble_npl_time_ticks_to_ms32(ticks);
    uint32_t s = ms / 1000;

    ms -= s * 1000;
    sleep_time.tv_sec = s;
    sleep_time.tv_nsec = ms * 1000000;

    nanosleep(&sleep_time, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, %eax
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
shrq $0x26, %rcx
imull $0x3e8, %ecx, %edx      # imm = 0x3E8
subq %rdx, %rax
leaq -0x10(%rbp), %rdi
movq %rcx, (%rdi)
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq %rax, 0x8(%rdi)
xorl %esi, %esi
callq 0x2090
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_mutex.c
// Function: ble_npl_mutex_init
ble_npl_error_t
ble_npl_mutex_init(struct ble_npl_mutex *mu)
{
    if (!mu) {
        return BLE_NPL_INVALID_PARAM;
    }

    pthread_mutexattr_init(&mu->attr);
    pthread_mutexattr_settype(&mu->attr, PTHREAD_MUTEX_RECURSIVE_NP);
    pthread_mutex_init(&mu->lock, &mu->attr);

    return BLE_NPL_OK;
}

// Assembly:
testq %rdi, %rdi
je 0x5792
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x28(%rdi), %r14
movq %r14, %rdi
callq 0x2060
movq %r14, %rdi
movl $0x1, %esi
callq 0x2220
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x3, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/npl/linux/src/os_mutex.c
// Function: ble_npl_mutex_pend
ble_npl_error_t
ble_npl_mutex_pend(struct ble_npl_mutex *mu, uint32_t timeout)
{
    int err;

    if (!mu) {
        return BLE_NPL_INVALID_PARAM;
    }

    if (timeout == BLE_NPL_TIME_FOREVER) {
        err = pthread_mutex_lock(&mu->lock);
    } else {
        err = clock_gettime(CLOCK_REALTIME, &mu->wait);
        if (err) {
            return BLE_NPL_ERROR;
        }

        mu->wait.tv_sec  += timeout / 1000;
        mu->wait.tv_nsec += (timeout % 1000) * 1000000;

        err = pthread_mutex_timedlock(&mu->lock, &mu->wait);
        if (err == ETIMEDOUT) {
            return BLE_NPL_TIMEOUT;
        }
    }

    return (err) ? BLE_NPL_ERROR : BLE_NPL_OK;
}

// Assembly:
testq %rdi, %rdi
je 0x57eb
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
jne 0x57f1
movq %rbx, %rdi
callq 0x2210
movl %eax, %ecx
testl %ecx, %ecx
movl $0xc, %eax
cmovel %ecx, %eax
jmp 0x5847
movl $0x3, %eax
retq
leaq 0x30(%rbx), %r15
xorl %edi, %edi
movq %r15, %rsi
callq 0x2160
movl %eax, %ecx
movl $0xc, %eax
testl %ecx, %ecx
jne 0x5847
movl %r14d, %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
shrq $0x26, %rax
addq %rax, 0x30(%rbx)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r14d
imull $0xf4240, %r14d, %eax   # imm = 0xF4240
addq %rax, 0x38(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22c0
movl %eax, %ecx
movl $0x6, %eax
cmpl $0x6e, %ecx
jne 0x57df
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/main.c
// Function: popup_quit
static bool
popup_quit(bool saving)
{
    panel_t popup;
    char *message;
    if (saving)
        message = "Really save and quit? (Rk{y}/Rk{n})";
    else
        message = "Really quit Yk{without saving}? (Rk{y}/Rk{n})";
    size_t length = strlen(message) - 8;
    panel_center_init(&popup, length + 2, 3);
    panel_printf(&popup, 1, 1, message);
    display_push(&popup);
    display_refresh();
    int input = device_getch();
    display_pop_free();
    display_refresh();
    if (input == 'y' || input == 'Y')
        return true;
    return false;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x3c18, %rsp           # imm = 0x3C18
leaq 0x49bc(%rip), %rax      # 0x7580
leaq 0x49d9(%rip), %rbx      # 0x75a4
testl %edi, %edi
cmovneq %rax, %rbx
movl $0x1d, %eax
movl $0x27, %esi
cmovnel %eax, %esi
movq %rsp, %r14
movq %r14, %rdi
movl $0x3, %edx
callq 0x345f
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x373c
movq %r14, %rdi
callq 0x33e8
callq 0x323c
callq 0x5ffc
movl %eax, %ebx
callq 0x341f
callq 0x323c
andl $-0x21, %ebx
cmpl $0x59, %ebx
sete %al
addq $0x3c18, %rsp           # imm = 0x3C18
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/main.c
// Function: game_getch
static int
game_getch(game_t *game, panel_t *terrain)
{
    for (;;) {
        map_draw_terrain(game->map, terrain);
        display_refresh();
        uint64_t wait = device_uepoch() % PERIOD;
        if (device_kbhit(wait))
            return device_getch();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movabsq $-0x456d8a7abe346c9, %r12 # imm = 0xFBA92758541CB937
movq 0x38(%r14), %rdi
movq %rbx, %rsi
callq 0x441c
callq 0x323c
callq 0x6128
movq %rax, %rdi
mulq %r12
shrq $0x10, %rdx
imulq $0x1046a, %rdx, %rax    # imm = 0x1046A
subq %rax, %rdi
callq 0x60b0
movl %eax, %r15d
testb %al, %al
je 0x2ef8
callq 0x5ffc
movl %eax, %ebp
testb %r15b, %r15b
je 0x2ebb
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/main.c
// Function: popup_message
static void
popup_message(font_t font, char *format, ...)
{
    va_list ap;
    va_start(ap, format);
    int length = vsnprintf(NULL, 0, format, ap);
    va_end(ap);
    va_start(ap, format);
    char buffer[length + 1];
    vsprintf(buffer, format, ap);
    va_end(ap);
    int width = length + 2;
    int height = 3;
    panel_t popup;
    panel_center_init(&popup, width, height);
    panel_puts(&popup, 1, 1, font, buffer);
    display_push(&popup);
    for (;;) {
        int key = display_getch();
        if (is_exit_key(key) || key == 13 || key == ' ')
            break;
    }
    display_pop_free();
    display_refresh();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3cf8, %rsp           # imm = 0x3CF8
movq %rsi, %rbx
leaq -0x100(%rbp), %r12
movq %rdx, 0x10(%r12)
movq %rcx, 0x18(%r12)
movq %r8, 0x20(%r12)
movq %r9, 0x28(%r12)
testb %al, %al
je 0x2f6d
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
movaps %xmm2, -0xb0(%rbp)
movaps %xmm3, -0xa0(%rbp)
movaps %xmm4, -0x90(%rbp)
movaps %xmm5, -0x80(%rbp)
movaps %xmm6, -0x70(%rbp)
movaps %xmm7, -0x60(%rbp)
leaq -0x50(%rbp), %r14
movq %r12, 0x10(%r14)
leaq 0x10(%rbp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000010, %r13     # imm = 0x3000000010
movq %r13, (%r14)
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1090
movl %eax, %r15d
movq %rsp, -0x30(%rbp)
movq %r13, (%r14)
leaq 0x10(%rbp), %rax
movq %rax, 0x8(%r14)
movq %r12, 0x10(%r14)
leal 0x1(%r15), %eax
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x11e0
addl $0x2, %r15d
leaq -0x3d18(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
movl $0x3, %edx
callq 0x345f
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
movl $0x10003, %ecx          # imm = 0x10003
movq %r12, %r8
callq 0x353e
movq %rbx, %rdi
callq 0x33e8
callq 0x3453
movl %eax, %ecx
andl $-0x21, %ecx
cmpl $0x51, %ecx
sete %cl
cmpl $0x1b, %eax
sete %dl
orb %cl, %dl
jne 0x3033
cmpl $0x20, %eax
je 0x3033
cmpl $0xd, %eax
jne 0x300f
callq 0x341f
callq 0x323c
movq -0x30(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/main.c
// Function: sideinfo
static int
sideinfo(panel_t *p, char *message)
{
    panel_init(p, DISPLAY_WIDTH - SIDEMENU_WIDTH, 0,
               SIDEMENU_WIDTH, DISPLAY_HEIGHT);
    display_push(p);
    panel_fill(p, FONT(K, k), 0x2591);
    panel_border(p, FONT(K, k));
    int y = DISPLAY_HEIGHT / 2 - 1;
    int x = p->w / 2 - panel_strlen(message) / 2 - 1;
    panel_printf(p, x, y, message);
    return y;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl $0x3c, %esi
xorl %edx, %edx
movl $0x14, %ecx
movl $0x18, %r8d
callq 0x3166
movq %r14, %rdi
callq 0x33e8
movq %r14, %rdi
movl $0x10000, %esi          # imm = 0x10000
movl $0x2591, %edx           # imm = 0x2591
callq 0x34a0
movq %r14, %rdi
movl $0x10000, %esi          # imm = 0x10000
callq 0x3b2b
movl 0x8(%r14), %eax
movl %eax, %ebp
shrl $0x1f, %ebp
addl %eax, %ebp
sarl %ebp
movq %rbx, %rdi
callq 0x3d47
shrq %rax
notl %eax
addl %eax, %ebp
movq %r14, %rdi
movl %ebp, %esi
movl $0xb, %edx
movq %rbx, %rcx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x373c
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: display_init
void
display_init(void)
{
    device_init();
    panel_init(&display.base, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT);
    for (int y = 0; y < DISPLAY_HEIGHT; y++)
        for (int x = 0; x < DISPLAY_WIDTH; x++)
            panel_putc(&display.base, x, y, FONT_DEFAULT, ' ');
    display.panels = &display.base;
    display_refresh();
}

// Assembly:
pushq %rax
callq 0x5de4
movaps 0x4557(%rip), %xmm0     # 0x7630
movups %xmm0, 0xc4e8(%rip)     # 0xf5c8
leaq 0xc4f3(%rip), %rax      # 0xf5da
xorl %ecx, %ecx
xorl %edx, %edx
movb $0x1, (%rax,%rdx)
addq $0xc0, %rdx
cmpq $0x3c00, %rdx           # imm = 0x3C00
jne 0x30eb
incq %rcx
addq $0x8, %rax
cmpq $0x18, %rcx
jne 0x30e9
movq $0x0, 0x100c1(%rip) # 0x131d8
leaq 0xc4bd(%rip), %rax      # 0xf5db
xorl %ecx, %ecx
xorl %edx, %edx
movb $0x0, -0x1(%rax,%rdx)
movw $0x20, -0x3(%rax,%rdx)
movl $0x10007, (%rax,%rdx)   # imm = 0x10007
addq $0xc0, %rdx
cmpq $0x3c00, %rdx           # imm = 0x3C00
jne 0x3122
incq %rcx
addq $0x8, %rax
cmpq $0x18, %rcx
jne 0x3120
leaq 0xc46f(%rip), %rax      # 0xf5c8
movq %rax, 0x10080(%rip)     # 0x131e0
popq %rax
jmp 0x323c
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: panel_init
void
panel_init(panel_t *p, int x, int y, int w, int h)
{
    p->x = x;
    p->y = y;
    p->w = w;
    p->h = h;
    assert(w <= DISPLAY_WIDTH);
    assert(h <= DISPLAY_HEIGHT);
    for (int y = 0; y < DISPLAY_HEIGHT; y++)
        for (int x = 0; x < DISPLAY_WIDTH; x++)
            p->tiles[x][y].transparent = true;
    p->next = NULL;
}

// Assembly:
pushq %rax
movl %esi, (%rdi)
movl %edx, 0x4(%rdi)
movl %ecx, 0x8(%rdi)
movl %r8d, 0xc(%rdi)
cmpl $0x51, %ecx
jge 0x31b6
cmpl $0x18, %r8d
jg 0x31d5
xorl %eax, %eax
movq %rdi, %rcx
movl $0x12, %edx
movb $0x1, (%rcx,%rdx)
addq $0xc0, %rdx
cmpq $0x3c12, %rdx           # imm = 0x3C12
jne 0x3188
incq %rax
addq $0x8, %rcx
cmpq $0x18, %rax
jne 0x3183
movq $0x0, 0x3c10(%rdi)
popq %rax
retq
leaq 0x44ed(%rip), %rdi      # 0x76aa
leaq 0x44c4(%rip), %rsi      # 0x7688
leaq 0x44f2(%rip), %rcx      # 0x76bd
movl $0x71, %edx
callq 0x10e0
leaq 0x4510(%rip), %rdi      # 0x76ec
leaq 0x44a5(%rip), %rsi      # 0x7688
leaq 0x44d3(%rip), %rcx      # 0x76bd
movl $0x72, %edx
callq 0x10e0
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: panel_putc
void
panel_putc(panel_t *p, int x, int y, font_t font, uint16_t c)
{
    x += p->x;
    y += p->y;
    if (x >= 0 && x < p->x + p->w && y >= 0 && y < p->y + p->h) {
        p->tiles[x][y].transparent = false;
        p->tiles[x][y].c = c;
        p->tiles[x][y].font = font;
    }
}

// Assembly:
movl (%rdi), %r9d
addl %esi, %r9d
js 0x323b
movl 0x4(%rdi), %eax
addl %edx, %eax
cmpl %esi, 0x8(%rdi)
setg %sil
testl %eax, %eax
setns %r10b
andb %sil, %r10b
cmpb $0x1, %r10b
jne 0x323b
cmpl %edx, 0xc(%rdi)
jle 0x323b
movl %r9d, %edx
leaq (%rdx,%rdx,2), %rdx
shlq $0x6, %rdx
addq %rdx, %rdi
movl %eax, %eax
movb $0x0, 0x12(%rdi,%rax,8)
movw %r8w, 0x10(%rdi,%rax,8)
movl %ecx, 0x13(%rdi,%rax,8)
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: display_refresh
void
display_refresh(void)
{
    int cx = 0;
    int cy = 0;
    device_move(cx, cy);
    for (int y = 0; y < DISPLAY_HEIGHT; y++) {
        for (int x = 0; x < DISPLAY_WIDTH; x++) {
            panel_t *p = display.panels;
            while (p->tiles[x][y].transparent)
                p = p->next;
            uint16_t oldc = display.current[x][y].c;
            uint16_t newc = p->tiles[x][y].c;
            font_t oldf = display.current[x][y].font;
            font_t newf = p->tiles[x][y].font;
            if (oldc != newc || !font_equal(oldf, newf)) {
                if (cx != x || cy != y)
                    device_move(cx = x, cy = y);
                device_putc(newf, newc);
                display.current[x][y].font = newf;
                display.current[x][y].c = newc;
                cx++;
            }
        }
    }
    device_flush();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %ebx, %ebx
xorl %edi, %edi
xorl %esi, %esi
callq 0x5e93
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
leaq (%rbx,%rbx,2), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
leaq (%r14,%r14,2), %rax
shlq $0x6, %rax
leaq 0xff65(%rip), %rcx      # 0x131e0
movq (%rcx), %rcx
leaq (%rcx,%rax), %rdx
addq $0x3c10, %rcx           # imm = 0x3C10
cmpb $0x0, 0x12(%rdx,%rbx,8)
jne 0x327b
leaq (%rdx,%rbx,8), %rax
addq $0x10, %rax
leaq (%r14,%r14,8), %rcx
shlq $0x4, %rcx
leaq 0x9621(%rip), %rdx      # 0xc8c8
addq %rdx, %rcx
movq 0x10(%rsp), %rdx
leaq (%rcx,%rdx,2), %r13
movzwl (%rax), %r15d
movl 0x3(%rax), %ebp
cmpw %r15w, (%r13)
jne 0x32ce
movl 0x2(%r13), %ecx
movl %ecx, %eax
xorl %ebp, %eax
testw %ax, %ax
je 0x3319
movl %r12d, %eax
cmpq %rax, %r14
jne 0x32df
movl 0xc(%rsp), %eax
cmpq %rax, %rbx
je 0x32f0
movl %r14d, %edi
movl %ebx, %esi
callq 0x5e93
movl %ebx, 0xc(%rsp)
movl %r14d, %r12d
movzwl %r15w, %r15d
movl %ebp, %edi
movl %r15d, %esi
callq 0x5ed7
movl %ebp, 0x2(%r13)
movw %r15w, (%r13)
incl %r12d
incq %r14
cmpq $0x50, %r14
jne 0x326c
jmp 0x3331
btl $0x18, %ecx
jae 0x32ce
andl $0x10000, %eax          # imm = 0x10000
jne 0x32ce
movl %ebp, %eax
andl $0x1000000, %eax        # imm = 0x1000000
jne 0x330a
jmp 0x32ce
incq %rbx
cmpq $0x18, %rbx
jne 0x3260
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5fed
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: display_free
void
display_free()
{
    device_move(0, DISPLAY_HEIGHT);
    panel_free(&display.base);
    device_free();
    assert(display.panels == &display.base);
}

// Assembly:
pushq %rax
xorl %edi, %edi
movl $0x18, %esi
callq 0x5e93
cmpq $0x0, 0xfe72(%rip)      # 0x131d8
jne 0x337f
callq 0x5e75
leaq 0xc254(%rip), %rax      # 0xf5c8
cmpq %rax, 0xfe65(%rip)      # 0x131e0
jne 0x339e
popq %rax
retq
leaq 0x437a(%rip), %rdi      # 0x7700
leaq 0x42fb(%rip), %rsi      # 0x7688
leaq 0x437c(%rip), %rcx      # 0x7710
movl $0x86, %edx
callq 0x10e0
leaq 0x42c3(%rip), %rdi      # 0x7668
leaq 0x42dc(%rip), %rsi      # 0x7688
leaq 0x42e3(%rip), %rcx      # 0x7696
movl $0x25, %edx
callq 0x10e0
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: panel_center_init
void
panel_center_init(panel_t *p, int w, int h)
{
    int x = DISPLAY_WIDTH / 2 - w / 2;
    int y = DISPLAY_HEIGHT / 2 - h / 2;
    panel_init(p, x, y, w, h);
    panel_fill(p, FONT_DEFAULT, ' ');
}

// Assembly:
pushq %rbx
movl %edx, %r8d
movl %esi, %ecx
movq %rdi, %rbx
movl %esi, %eax
shrl $0x1f, %eax
addl %esi, %eax
sarl %eax
movl $0x28, %esi
subl %eax, %esi
movl %edx, %eax
shrl $0x1f, %eax
addl %edx, %eax
sarl %eax
movl $0xc, %edx
subl %eax, %edx
callq 0x3166
movq %rbx, %rdi
movl $0x10007, %esi          # imm = 0x10007
movl $0x20, %edx
popq %rbx
jmp 0x34a0
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: panel_puts
void
panel_puts(panel_t *p, int x, int y, font_t font, const char *s)
{
    for (uint8_t *s8 = (uint8_t *)s; *s8; s8 += utf8_charlen(*s8), x++) {
        uint32_t c = utf8_to_32(s8);
        assert(c <= UINT16_MAX);
        panel_putc(p, x, y, font, c);
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpb $0x0, (%r8)
je 0x3620
movq %r8, %r14
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r12
leaq 0x10(%rdi), %r13
movq %r14, %rdi
callq 0x364e
cmpl $0x10000, %eax          # imm = 0x10000
jae 0x362f
movl (%r12), %ecx
addl %r15d, %ecx
js 0x35c2
movl 0x4(%r12), %edx
addl %ebp, %edx
cmpl %r15d, 0x8(%r12)
setg %sil
testl %edx, %edx
setns %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x35c2
cmpl %ebp, 0xc(%r12)
jle 0x35c2
movl %ecx, %ecx
movl %edx, %edx
leaq (%rcx,%rcx,2), %rcx
shlq $0x6, %rcx
addq %r13, %rcx
movb $0x0, 0x2(%rcx,%rdx,8)
movw %ax, (%rcx,%rdx,8)
movl %ebx, 0x3(%rcx,%rdx,8)
movzbl (%r14), %eax
movl $0x1, %ecx
testb %al, %al
jns 0x360e
movl %eax, %edx
andl $-0x20, %edx
movl $0x2, %ecx
cmpl $0xc0, %edx
je 0x360e
movl %eax, %edx
andl $-0x10, %edx
movl $0x3, %ecx
cmpl $0xe0, %edx
je 0x360e
movl %eax, %ecx
andl $-0x8, %ecx
cmpl $0xf0, %ecx
sete %cl
cmpb $-0xb, %al
setb %al
andb %cl, %al
movzbl %al, %ecx
shll $0x2, %ecx
incl %r15d
cmpb $0x0, (%r14,%rcx)
leaq (%r14,%rcx), %r14
jne 0x3564
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40f5(%rip), %rdi      # 0x772b
leaq 0x404b(%rip), %rsi      # 0x7688
leaq 0x40f7(%rip), %rcx      # 0x773b
movl $0x9a, %edx
callq 0x10e0
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/utf.h
// Function: utf8_to_32
static inline
size_t utf8_valid(const uint8_t *c)
{
    size_t clen = utf8_charlen(*c);
    switch(clen) { /* use fall through */
    case 4: if ((c[3] & 0xc0) != 0x80) return 0;
    case 3: if ((c[2] & 0xc0) != 0x80) return 0;
    case 2: if ((c[1] & 0xc0) != 0x80) return 0;
    case 1: return clen;  /* no trailing bytes to validate */
    case 0: return 0;     /* invalid utf8 */
    }
    return clen; /* don't complain, gcc */
}

// Assembly:
movzbl (%rdi), %ecx
movl $0x1, %edx
testb %cl, %cl
jns 0x3697
movl %ecx, %eax
andl $-0x20, %eax
movl $0x2, %edx
cmpl $0xc0, %eax
je 0x3697
movl %ecx, %eax
andl $-0x10, %eax
movl $0x3, %edx
cmpl $0xe0, %eax
je 0x3697
movl %ecx, %eax
andl $-0x8, %eax
cmpl $0xf0, %eax
sete %al
cmpb $-0xb, %cl
setb %dl
andb %al, %dl
movzbl %dl, %edx
shll $0x2, %edx
leaq 0x3fa2(%rip), %rax      # 0x7640
movslq (%rax,%rdx,4), %rsi
addq %rax, %rsi
jmpq *%rsi
movb 0x3(%rdi), %al
andb $-0x40, %al
negb %al
jno 0x36d5
movb 0x2(%rdi), %al
andb $-0x40, %al
negb %al
jno 0x36d5
movb 0x1(%rdi), %al
andb $-0x40, %al
negb %al
jno 0x36d5
xorl %eax, %eax
leaq 0x3f89(%rip), %rsi      # 0x7654
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
retq
xorl %edx, %edx
xorl %eax, %eax
leaq 0x3f74(%rip), %rsi      # 0x7654
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl %ecx, %eax
retq
andl $0x7, %ecx
shll $0x12, %ecx
movzbl 0x1(%rdi), %eax
andl $0x3f, %eax
shll $0xc, %eax
orl %ecx, %eax
movzbl 0x2(%rdi), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
orl %eax, %ecx
movzbl 0x3(%rdi), %eax
jmp 0x371a
andl $0x1f, %ecx
shll $0x6, %ecx
movzbl 0x1(%rdi), %eax
andl $0x3f, %eax
orl %ecx, %eax
retq
andl $0xf, %ecx
shll $0xc, %ecx
movzbl 0x1(%rdi), %edx
andl $0x3f, %edx
shll $0x6, %edx
orl %ecx, %edx
movzbl 0x2(%rdi), %eax
andl $0x3f, %eax
orl %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: panel_attr
void
panel_attr(panel_t *p, int x, int y, font_t font)
{
    x += p->x;
    y += p->y;
    if (x >= 0 && x < DISPLAY_WIDTH && y >= 0 && y < DISPLAY_HEIGHT) {
        p->tiles[x][y].transparent = false;
        p->tiles[x][y].font = font;
    }
}

// Assembly:
addl (%rdi), %esi
addl 0x4(%rdi), %edx
cmpl $0x50, %esi
setb %al
cmpl $0x18, %edx
setb %r8b
andb %al, %r8b
cmpb $0x1, %r8b
jne 0x3aad
movl %esi, %eax
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
addq %rax, %rdi
movl %edx, %eax
movb $0x0, 0x12(%rdi,%rax,8)
movl %ecx, 0x13(%rdi,%rax,8)
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/display.c
// Function: panel_strlen
size_t
panel_strlen(const char *s)
{
    size_t count = 0;
    for (const char *p = s; *p; p += utf8_charlen((uint8_t) *p)) {
        if (is_color_directive(p))
            p += 3;
        else if (*p != '}')
            count++;
    }
    return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movb (%rdi), %bpl
testb %bpl, %bpl
je 0x3e0e
movq %rdi, %r14
xorl %ebx, %ebx
leaq 0x3a4a(%rip), %r15      # 0x77b0
movsbl %bpl, %esi
movl $0x11, %edx
movq %r15, %rdi
callq 0x1140
testq %rax, %rax
je 0x3da4
movsbl 0x1(%r14), %esi
testl %esi, %esi
je 0x3da4
movl $0x11, %edx
movq %r15, %rdi
callq 0x1140
testq %rax, %rax
je 0x3da4
cmpb $0x7b, 0x2(%r14)
jne 0x3da4
addq $0x3, %r14
jmp 0x3db0
xorl %eax, %eax
cmpb $0x7d, %bpl
setne %al
addq %rax, %rbx
movzbl (%r14), %eax
movl $0x1, %ecx
testb %al, %al
jns 0x3dfc
movl %eax, %edx
andl $-0x20, %edx
movl $0x2, %ecx
cmpl $0xc0, %edx
je 0x3dfc
movl %eax, %edx
andl $-0x10, %edx
movl $0x3, %ecx
cmpl $0xe0, %edx
je 0x3dfc
movl %eax, %ecx
andl $-0x8, %ecx
cmpl $0xf0, %ecx
sete %cl
cmpb $-0xb, %al
setb %al
andb %cl, %al
movzbl %al, %ecx
shll $0x2, %ecx
movb (%r14,%rcx), %bpl
addq %rcx, %r14
testb %bpl, %bpl
jne 0x3d66
jmp 0x3e10
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/map.c
// Function: map_draw_buildings
void
map_draw_buildings(map_t *map, panel_t *p)
{
    for (size_t y = 0; y < MAP_HEIGHT; y++) {
        for (size_t x = 0; x < MAP_WIDTH; x++) {
            enum building building = map->high[x][y].building;
            if (building != C_NONE) {
                uint16_t c = building;
                font_t font = FONT(Y, k);
                if (map->high[x][y].building_age < 0) {
                    font.fore = COLOR_CYAN;
                    c = tolower(c);
                }
                panel_putc(p, x, y, font, c);
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
addq $0x8, %r14
xorl %r15d, %r15d
movq %r14, %r13
xorl %r12d, %r12d
movzwl -0x6(%r13), %eax
testl %eax, %eax
je 0x4692
cmpq $0x0, (%r13)
js 0x4674
movl $0x10003, %ecx          # imm = 0x10003
jmp 0x4680
movl %eax, %edi
callq 0x11b0
movl $0x10006, %ecx          # imm = 0x10006
movzwl %ax, %r8d
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x31f4
incq %r12
addq $0x180, %r13            # imm = 0x180
cmpq $0x3c, %r12
jne 0x465d
incq %r15
addq $0x10, %r14
cmpq $0x18, %r15
jne 0x4657
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: game_hero_generate
hero_t
game_hero_generate(void)
{
    hero_t hero;
    memset(&hero, 0, sizeof(hero));
    hero.active = true;
    rand_name(hero.name, sizeof(hero.name));
    hero.hp = hero.hp_max = rand_range(10, 20);
    hero.ap = hero.ap_max = rand_range(20, 40);
    hero.str = rand_range(10, 18);
    hero.dex = rand_range(10, 18);
    hero.mind = rand_range(10, 18);
    hero.squad = -1;
    return hero;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movl $0x0, 0x30(%rdi)
movb $0x1, (%rdi)
incq %rdi
movl $0x10, %esi
callq 0x5bf2
movl $0xa, %edi
movl $0x14, %esi
callq 0x5baa
movl %eax, 0x18(%rbx)
movl %eax, 0x14(%rbx)
movl $0x14, %edi
movl $0x28, %esi
callq 0x5baa
movl %eax, 0x20(%rbx)
movl %eax, 0x1c(%rbx)
movl $0xa, %edi
movl $0x12, %esi
callq 0x5baa
movl %eax, 0x24(%rbx)
movl $0xa, %edi
movl $0x12, %esi
callq 0x5baa
movl %eax, 0x28(%rbx)
movl $0xa, %edi
movl $0x12, %esi
callq 0x5baa
movl %eax, 0x2c(%rbx)
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: game_create
game_t *
game_create(uint64_t map_seed)
{
    game_t *game = calloc(sizeof(*game), 1);
    game->map_seed = map_seed;
    game->time = 0;
    game->speed = 1;
    game->gold = INIT_GOLD;
    game->wood = INIT_WOOD;
    game->food = INIT_FOOD;
    game->population = INIT_POPULATION;
    game->spawn_rate = INVADER_SPAWN_RATE;
    game->map = map_generate(map_seed);
    game->map->high[CASTLE_X][CASTLE_Y].building = C_CASTLE;
    game->max_hero = MAX_HERO_INIT;
    for (int i = 0; i < (int)countof(game->squads); i++) {
        game->squads[i].x = CASTLE_X;
        game->squads[i].y = CASTLE_Y;
        game->squads[i].target = -1;
    }
    for (int i = 0; i < HERO_INIT; i++) {
        game->heroes[i] = game_hero_generate();
        game->heroes[i].squad = 0;
    }
    game->squads[0].member_count = HERO_INIT;
    return game;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %r14
movl $0x1df0, %edi           # imm = 0x1DF0
movl $0x1, %esi
callq 0x1160
movq %rax, %rbx
movq %r14, (%rax)
movq $0x0, 0x8(%rax)
movl $0x1, 0x10(%rax)
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x28(%rbx)
movabsq $0x406f400000000000, %rax # imm = 0x406F400000000000
movq %rax, 0x30(%rbx)
movl $0x3f800000, 0x40(%rbx) # imm = 0x3F800000
movq %r14, %rdi
callq 0x3e20
movq %rax, 0x38(%rbx)
movw $0x43, 0x2dc2(%rax)
movl $0x4, 0x3c8(%rbx)
movl $0x2d0, %eax            # imm = 0x2D0
movabsq $0x4140000041f00000, %rcx # imm = 0x4140000041F00000
movq %rcx, -0x8(%rbx,%rax)
movl $0xffffffff, (%rbx,%rax) # imm = 0xFFFFFFFF
addq $0x10, %rax
cmpq $0x3d0, %rax            # imm = 0x3D0
jne 0x483c
movl $0x3cc, %r15d           # imm = 0x3CC
leaq 0xc(%rsp), %r14
movq %r14, %rdi
callq 0x4714
movl 0x3c(%rsp), %eax
movl %eax, 0x30(%rbx,%r15)
movups 0xc(%rsp), %xmm0
movups 0x1c(%rsp), %xmm1
movups 0x2c(%rsp), %xmm2
movups %xmm2, 0x20(%rbx,%r15)
movups %xmm1, 0x10(%rbx,%r15)
movups %xmm0, (%rbx,%r15)
movl $0x0, 0x30(%rbx,%r15)
addq $0x34, %r15
cmpq $0x400, %r15            # imm = 0x400
je 0x485f
movl $0x2, 0x2d4(%rbx)
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: game_load
game_t *
game_load(FILE *out)
{
    game_t *game = malloc(sizeof(*game));
    if (fread(game, sizeof(*game), 1, out) == 1) {
        game->map = map_generate(game->map_seed);
        if (fread(game->map->high, sizeof(game->map->high), 1, out) == 1)
            return game;
    }
    return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x1df0, %edi           # imm = 0x1DF0
callq 0x11c0
movq %rax, %rbx
movl $0x1df0, %esi           # imm = 0x1DF0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x1080
cmpq $0x1, %rax
jne 0x495e
movq (%rbx), %rdi
callq 0x3e20
movq %rax, 0x38(%rbx)
movl $0x5a00, %esi           # imm = 0x5A00
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x4960
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: add_population
static void
add_population(game_t *game, long amount)
{
    long start_population = game->population;
    game->population += amount;
    if (start_population < GAME_WIN_POP / 4 &&
        game->population >= GAME_WIN_POP / 4) {
        game_event_push(game, EVENT_PROGRESS_1);
    }
    if (game->population <= 0)
        game_event_push(game, EVENT_LOSE);
}

// Assembly:
movsd 0x30(%rdi), %xmm1
cvttsd2si %xmm1, %rax
cvtsi2sd %rsi, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rdi)
cmpq $0x3e7, %rax            # imm = 0x3E7
jg 0x4c00
ucomisd 0x2cc4(%rip), %xmm0     # 0x78a0
jb 0x4c00
xorl %eax, %eax
cmpl $0x0, 0x1dcc(%rdi,%rax,4)
je 0x4bf5
incq %rax
cmpq $0x8, %rax
jne 0x4be0
jmp 0x4c00
movl $0x3, 0x1dcc(%rdi,%rax,4)
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jb 0x4c1f
xorl %eax, %eax
cmpl $0x0, 0x1dcc(%rdi,%rax,4)
je 0x4c20
incq %rax
cmpq $0x8, %rax
jne 0x4c0c
retq
movl $0x1, 0x1dcc(%rdi,%rax,4)
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: game_unbuild
void
game_unbuild(game_t *game, int x, int y)
{
    uint16_t building = map_building(game->map, x, y);
    switch (building) {
    case C_HAMLET:
        add_population(game, -HAMLET_INC);
        break;
    case C_STABLE:
        game->max_hero -= STABLE_INC;
        break;
    case C_MINE:
    case C_LUMBERYARD:
    case C_ROAD:
    case C_FARM:
        /* Nothing special */
        break;
    case C_CASTLE:
        add_population(game, -50);
        return; // don't destroy
    }
    game->map->high[x][y].building = C_NONE;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
callq 0x46e7
cmpw $0x43, %ax
je 0x4d12
movzwl %ax, %eax
cmpl $0x53, %eax
je 0x4ce9
cmpl $0x48, %eax
jne 0x4cf0
movq %rbx, %rdi
movq $-0xc8, %rsi
callq 0x4bb4
jmp 0x4cf0
addl $-0x2, 0x3c8(%rbx)
movslq %r14d, %rax
movslq %ebp, %rcx
leaq (%rax,%rax,2), %rax
shlq $0x7, %rax
addq 0x38(%rbx), %rax
shlq $0x4, %rcx
movw $0x0, 0x2(%rcx,%rax)
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
movq $-0x32, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x4bb4
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: game_date
void
game_date(game_t *game, char *buffer)
{
    long time = game->time;
    long day = game->time / DAY;
    time -= day * DAY;
    long hour = time / HOUR;
    time -= hour * HOUR;
    long minute = time / MINUTE;
    char *ampm = hour < 12 ? "am" : "pm";
    long hour12 = hour == 0 ? 12 : hour;
    if (hour12 > 12)
        hour12 -= 12;
    sprintf(buffer, "Day %ld, %ld:%02ld%s", day, hour12, minute, ampm);
}

// Assembly:
cvtsi2sdq 0x8(%rdi), %xmm0
movq %rsi, %rdi
movsd 0x2b72(%rip), %xmm1     # 0x78a8
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rdx
xorps %xmm2, %xmm2
cvtsi2sd %rdx, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
cvttsd2si %xmm0, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x2b48(%rip), %xmm1     # 0x78b0
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
testq %rax, %rax
movl $0xc, %esi
cmovneq %rax, %rsi
leaq -0xc(%rsi), %rcx
cmpq $0xd, %rsi
cmovlq %rsi, %rcx
cmpq $0xc, %rax
leaq 0x2b98(%rip), %rsi      # 0x7930
leaq 0x2b94(%rip), %r9       # 0x7933
cmovlq %rsi, %r9
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
cvttsd2si %xmm0, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x2af0(%rip), %xmm0     # 0x78b8
cvttsd2si %xmm0, %r8
leaq 0x2b62(%rip), %rsi      # 0x7936
xorl %eax, %eax
jmp 0x1230
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: yield_string
void
yield_string(char *b, yield_t yield, bool rate)
{
    char *end = b;
    int count = 0;
    if (yield.gold)
        end += sprintf(end, "%s%d gold%s",
                       count++ > 0 ? ", " : "",
                       yield.gold,
                       rate ? "/day" : "");
    if (yield.wood)
        end += sprintf(end, "%s%d wood%s",
                       count++ > 0 ? ", " : "",
                       yield.wood,
                       rate ? "/day" : "");
    if (yield.food)
        end += sprintf(end, "%s%d food%s",
                       count++ > 0 ? ", " : "",
                       yield.food,
                       rate ? "/day" : "");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movl %ebx, %r12d
testl %ebx, %ebx
je 0x4e2e
leaq 0x2b5b(%rip), %r8       # 0x795a
leaq 0x2bc5(%rip), %rdx      # 0x79cb
testb %bpl, %bpl
cmoveq %rdx, %r8
leaq 0x2b37(%rip), %rsi      # 0x794b
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x1230
cltq
addq %rax, %r14
movl $0x1, %r13d
jmp 0x4e31
xorl %r13d, %r13d
shrq $0x20, %rbx
testl %r15d, %r15d
je 0x4e79
incl %r13d
testl %r12d, %r12d
leaq 0x2b84(%rip), %rax      # 0x79cb
leaq 0x2b09(%rip), %rdx      # 0x7957
cmoveq %rax, %rdx
leaq 0x2b01(%rip), %r8       # 0x795a
testb %bpl, %bpl
cmoveq %rax, %r8
leaq 0x2af8(%rip), %rsi      # 0x795f
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x1230
cltq
addq %rax, %r14
testq %rbx, %rbx
jne 0x4e8d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r13d, %r13d
leaq 0x2ac0(%rip), %rdx      # 0x7957
leaq 0x2b2d(%rip), %rax      # 0x79cb
cmovleq %rax, %rdx
leaq 0x2ab1(%rip), %r8       # 0x795a
testb %bpl, %bpl
cmoveq %rax, %r8
leaq 0x2ab4(%rip), %rsi      # 0x796b
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1230
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: game_hero_push
bool
game_hero_push(game_t *game, hero_t hero)
{
    for (int i = 0; i < game->max_hero; i++) {
        if (!game->heroes[i].active) {
            game->heroes[i] = hero;
            return true;
        }
    }
    return false;
}

// Assembly:
movslq 0x3c8(%rdi), %rcx
testq %rcx, %rcx
setg %al
jle 0x4f3d
leaq 0x3cc(%rdi), %rsi
cmpb $0x1, 0x3cc(%rdi)
jne 0x4f15
movl $0x1, %eax
cmpq %rax, %rcx
je 0x4f3a
leaq 0x34(%rsi), %rdx
incq %rax
cmpb $0x0, 0x34(%rsi)
movq %rdx, %rsi
jne 0x4ef5
decq %rax
cmpq %rcx, %rax
setb %al
jmp 0x4f18
movq %rsi, %rdx
leaq 0x8(%rsp), %rcx
movl 0x30(%rcx), %esi
movl %esi, 0x30(%rdx)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rdx)
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
retq
seta %al
retq
// File: /workspace/github_c_makefile_star2_O1/skeeto[P]goblin-com/src/game.c
// Function: building_yield
yield_t
building_yield(uint16_t building)
{
    switch (building) {
    case C_CASTLE:
        return YIELD_CASTLE;
    case C_LUMBERYARD:
        return YIELD_LUMBERYARD;
    case C_FARM:
        return YIELD_FARM;
    case C_STABLE:
        return YIELD_STABLE;
    case C_MINE:
        return YIELD_MINE;
    case C_ROAD:
        return YIELD_ROAD;
    case C_HAMLET:
        return YIELD_HAMLET;
    case C_NONE:
        break;
    }
    return (yield_t){0, 0, 0};
}

// Assembly:
movl $0x2, %eax
cmpl $0x47, %edi
jle 0x5718
cmpl $0x52, %edi
jg 0x5735
cmpl $0x48, %edi
je 0x5759
cmpl $0x4d, %edi
jne 0x5753
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x5, %eax
jmp 0x5746
cmpl $0x2b, %edi
je 0x574a
cmpl $0x43, %edi
je 0x5779
cmpl $0x46, %edi
jne 0x5753
xorl %eax, %eax
movabsq $0x400000000, %rcx      # imm = 0x400000000
jmp 0x5773
cmpl $0x53, %edi
je 0x5767
cmpl $0x57, %edi
jne 0x5753
movl $0x5, %edx
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x5775
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5773
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x5773
xorl %edx, %edx
movabsq $-0x200000000, %rcx     # imm = 0xFFFFFFFE00000000
jmp 0x5775
xorl %eax, %eax
movabsq $-0x200000000, %rcx     # imm = 0xFFFFFFFE00000000
xorl %edx, %edx
orq %rcx, %rax
retq
movl $0x2, %edx
movabsq $0x200000000, %rcx      # imm = 0x200000000
jmp 0x5775