LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_udp_server_init
int shoit_network_udp_server_init(struct sockaddr_in *udpLocalAddr,int udpLocalPort,char *remoteHost,int remoteUdpPort)
{
    struct sockaddr_in cliaddr;
    struct hostent *phe;
    int udpSockfd;
    

    // Create a UDP sink 
    if ((udpSockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
        perror("socket error");
        return udpSockfd;
    }
    bzero((char *)udpLocalAddr, sizeof(struct sockaddr_in));
    udpLocalAddr->sin_family = AF_INET;
    udpLocalAddr->sin_addr.s_addr = htonl(INADDR_ANY);
    udpLocalAddr->sin_port = htons(udpLocalPort);

    if((bind(udpSockfd, (struct sockaddr *)udpLocalAddr, sizeof(struct sockaddr_in))) < 0) {
        perror("UDP bind error");
        close(udpSockfd);
        return -1;
    }

    // Use connected UDP to receive only from a specific host and port.
    bzero(&cliaddr, sizeof(cliaddr));
    if ((phe = gethostbyname(remoteHost)))
        memcpy(&cliaddr.sin_addr, phe->h_addr, phe->h_length);
    else if ((cliaddr.sin_addr.s_addr = inet_addr(remoteHost)) == INADDR_NONE){
        perror("gethostbyname remotehost error");
        close(udpSockfd);
        return -1;
    }

    cliaddr.sin_family = AF_INET;
    cliaddr.sin_port = htons(remoteUdpPort);

    if (connect(udpSockfd, (struct sockaddr *) &cliaddr, sizeof(cliaddr)) < 0)
    {
        perror("connect() error");
        close(udpSockfd);
        return -1;
    }

    return udpSockfd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r12d
movq %rdi, %r15
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x24c0
movl %eax, %ebx
testl %eax, %eax
js 0x31de
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movw $0x2, (%r15)
movl $0x0, 0x4(%r15)
rolw $0x8, %r12w
movw %r12w, 0x2(%r15)
movl %ebx, %edi
movq %r15, %rsi
movl $0x10, %edx
callq 0x2330
testl %eax, %eax
js 0x31ec
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
callq 0x2240
testq %rax, %rax
je 0x319e
leaq 0x4(%rsp), %rdi
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
callq 0x2280
jmp 0x31af
movq %r14, %rdi
callq 0x2220
movl %eax, 0x4(%rsp)
cmpl $-0x1, %eax
je 0x31fe
movq %rsp, %rsi
movw $0x2, (%rsi)
rolw $0x8, %bp
movw %bp, 0x2(%rsi)
movl %ebx, %edi
movl $0x10, %edx
callq 0x2400
testl %eax, %eax
js 0x31f5
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3287(%rip), %rdi      # 0x646c
callq 0x2390
jmp 0x31cf
leaq 0x32a7(%rip), %rdi      # 0x649a
jmp 0x3205
leaq 0x32cc(%rip), %rdi      # 0x64c8
jmp 0x3205
leaq 0x32a4(%rip), %rdi      # 0x64a9
callq 0x2390
movl %ebx, %edi
callq 0x21b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x31cf
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_connect_tcp
int shoit_network_connect_tcp(char * remoteHost,int remoteHostPort)
{
    #define USEC(st, fi) (((fi)->tv_sec-(st)->tv_sec)*1000000+((fi)->tv_usec-(st)->tv_usec))
    static struct sockaddr_in tcpServerAddr;
    int retval = 0;
    struct hostent *phe;
    struct timeval start, now;
    int tcpSockfd;

    /*Create a TCP connection */
    bzero((char *)&tcpServerAddr, sizeof(tcpServerAddr));
    tcpServerAddr.sin_family = AF_INET;

    if ((phe = gethostbyname(remoteHost)))
        memcpy(&tcpServerAddr.sin_addr, phe->h_addr, phe->h_length);
    else if ((tcpServerAddr.sin_addr.s_addr = inet_addr(remoteHost)) == INADDR_NONE)
    {
        perror("can't get host entry");
        return -1;
    }
    tcpServerAddr.sin_port = htons(remoteHostPort);
    if((tcpSockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
        perror("socket error");
        return -1;
    }
    gettimeofday(&start, NULL);
    do {
        retval = connect(tcpSockfd, (struct sockaddr *)&tcpServerAddr, sizeof(tcpServerAddr));
        gettimeofday(&now, NULL);
        if(retval<0) break;
    } while ((retval < 0) &&  (USEC(&start, &now) < 5000000));
    tcpSockfd = !retval ? tcpSockfd:-1;
    return tcpSockfd;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebx
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x605d(%rip)     # 0x928c
movw $0x2, 0x6054(%rip)      # 0x928c
callq 0x2240
testq %rax, %rax
je 0x325b
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
leaq 0x603c(%rip), %rdi      # 0x9290
callq 0x2280
jmp 0x326e
movq %r14, %rdi
callq 0x2220
movl %eax, 0x6027(%rip)      # 0x9290
cmpl $-0x1, %eax
je 0x32d9
rolw $0x8, %bx
movw %bx, 0x6015(%rip)       # 0x928e
xorl %ebx, %ebx
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x24c0
testl %eax, %eax
js 0x32d0
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2170
leaq 0x5fe7(%rip), %rsi      # 0x928c
movl %ebp, %edi
movl $0x10, %edx
callq 0x2400
movl %eax, %r14d
movq %rsp, %rdi
xorl %esi, %esi
callq 0x2170
negl %r14d
sbbl %ebx, %ebx
orl %ebp, %ebx
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x3195(%rip), %rdi      # 0x646c
jmp 0x32e0
leaq 0x3177(%rip), %rdi      # 0x6457
callq 0x2390
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x32c5
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_readn
ssize_t shoit_network_readn(int fd, void *vptr,ssize_t nbytes)
{
    ssize_t nleft, nread;
    char *ptr;

    ptr =(char*)vptr;
    nleft = nbytes;

    while(nleft > 0)
    {
        if ( (nread = read(fd, ptr, nleft)) < 0) {
            if (errno == EINTR)
                nread = 0;      /* and call read() again */
            else
                return (-1);
        } else if (nread == 0)
            break;              /* EOF */

        nleft -= nread;
        ptr += nread;
    }
    return (nbytes - nleft);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdx, %r15
testq %rdx, %rdx
jle 0x3493
movq %rsi, %r14
movl %edi, %ebp
movq %rbx, %r15
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2200
testq %rax, %rax
js 0x347f
jne 0x348b
jmp 0x3493
callq 0x2060
cmpl $0x4, (%rax)
jne 0x34a4
xorl %eax, %eax
addq %rax, %r14
subq %rax, %r15
jg 0x3469
subq %r15, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq $-0x1, %rbx
jmp 0x3496
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_writen
ssize_t shoit_network_writen(int fd,void *vptr,ssize_t nbytes)
{
    ssize_t nleft, nwritten;
    char *ptr;

    ptr = (char*)vptr;
    nleft = nbytes;
    while(nleft > 0)
    {
        if ( (nwritten = write(fd, ptr, nleft)) <= 0) {
            if (nwritten < 0 && errno == EINTR)
                nwritten = 0;   /* and call write() again */
            else
                return (-1);    /* error */
        }

        nleft -= nwritten;
        ptr += nwritten;
    }
    return (nbytes -nleft);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rdx, %r15
testq %rdx, %rdx
jle 0x34f7
movq %rsi, %r14
movl %edi, %ebp
movq %rbx, %r15
movq $-0x1, %r12
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x20b0
testq %rax, %rax
jg 0x34ef
jns 0x34fd
callq 0x2060
cmpl $0x4, (%rax)
jne 0x34fd
xorl %eax, %eax
addq %rax, %r14
subq %rax, %r15
jg 0x34cf
subq %r15, %rbx
movq %rbx, %r12
movq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_misc.c
// Function: shoit_misc_nocr
char *shoit_misc_nocr(char *s)
{
    if(s==NULL) return s;
    char *pos = s;

    while(*pos){
        if(*pos==' ' || *pos == '\n' || *pos=='\r') break;
        pos++;
    }
    *pos='\0';

    return s;
}

// Assembly:
movq %rdi, %rax
testq %rdi, %rdi
je 0x3538
movabsq $0x100002401, %rdx      # imm = 0x100002401
movq %rax, %rcx
movzbl (%rcx), %esi
cmpq $0x20, %rsi
ja 0x3530
btq %rsi, %rdx
jb 0x3535
incq %rcx
jmp 0x3521
movb $0x0, (%rcx)
retq
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_misc.c
// Function: shoit_misc_sleepto
void shoit_misc_sleepto(uint64_t nexttime, pthread_mutex_t *tickLock,pthread_cond_t *tickCond)
{
    uint64_t schedTime = nexttime;
    uint64_t t = shoit_misc_get_timer();

    while (t < schedTime)
    {
        struct timeval now;
        struct timespec timeout;
        gettimeofday(&now, 0);

        if (now.tv_usec < 990000){
            timeout.tv_sec = now.tv_sec;
            timeout.tv_nsec = (now.tv_usec + 10000) * 1000;
        } else {
            timeout.tv_sec = now.tv_sec + 1;
            timeout.tv_nsec = (now.tv_usec + 10000 - 1000000) * 1000;
        }

        pthread_mutex_lock(tickLock);
        pthread_cond_timedwait(tickCond, tickLock,&timeout);
        pthread_mutex_unlock(tickLock);
        t = shoit_misc_get_timer();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x2170
imulq $0xf4240, (%r12), %rax  # imm = 0xF4240
addq 0x8(%r12), %rax
cmpq %r15, %rax
jae 0x362c
leaq 0x28(%rsp), %r12
leaq 0x18(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
xorl %esi, %esi
callq 0x2170
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq 0x1(%rax), %rdx
imulq $0x3e8, %rcx, %rsi      # imm = 0x3E8
leaq -0x3b023380(%rsi), %rdi
addq $0x989680, %rsi         # imm = 0x989680
cmpq $0xf1b30, %rcx          # imm = 0xF1B30
cmovlq %rax, %rdx
movq %rdx, 0x18(%rsp)
cmovgeq %rdi, %rsi
movq %rsi, 0x20(%rsp)
movq %r14, %rdi
callq 0x2490
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2350
movq %r14, %rdi
callq 0x22c0
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2170
imulq $0xf4240, 0x8(%rsp), %rax # imm = 0xF4240
addq 0x10(%rsp), %rax
cmpq %r15, %rax
jb 0x35a7
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_misc.c
// Function: shoit_misc_resolve_line
int shoit_misc_resolve_line(char *line,char *host,int *port)
{
    char *pos;
    if(line==NULL || strlen(line)==0) return -1;
    if( (pos =strchr(line,':'))==NULL) return -1;
    
    memcpy(host,line,(int)(pos-line));
    pos ++; //del ':'
    if(pos==NULL) return -1; /*port error*/

    char *endptr;
    errno = 0;    /* To distinguish success/failure after call */
    long val = strtol(pos, &endptr,10);
    if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
                   || (errno != 0 && val == 0)) {
        return -1;
    }
    if (endptr == pos) {
        fprintf(stderr, "No digits were found\n");
        return -1;
    }
   
    *port = (int)val; 

    return 0;
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x36f2
movq %rdi, %r15
cmpb $0x0, (%rdi)
je 0x36f2
movq %rdx, %rbx
movq %rsi, %r12
movq %r15, %rdi
movl $0x3a, %esi
callq 0x2100
testq %rax, %rax
je 0x36f2
movq %rax, %r14
subl %r15d, %eax
movslq %eax, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x2280
incq %r14
callq 0x2060
movq %rax, %r15
movl $0x0, (%rax)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
movl $0xa, %edx
callq 0x2270
movl (%r15), %ecx
cmpl $0x22, %ecx
sete %dl
movabsq $-0x7fffffffffffffff, %rsi # imm = 0x8000000000000001
addq %rax, %rsi
cmpq $0x2, %rsi
setb %sil
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %sil, %dl
jne 0x36f2
testl %ecx, %ecx
setne %cl
testq %rax, %rax
sete %dl
testb %dl, %cl
jne 0x36f2
cmpq %r14, 0x8(%rsp)
je 0x3701
movl %eax, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x2609
jmp 0x36f2
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_misc.c
// Function: shoit_misc_log
void shoit_misc_log(FILE *fp,char *format, ...)
{

    if(!fp) return;

    va_list arglist;
    va_start( arglist, format);
    vfprintf(fp, format, arglist);
    fprintf(fp, "\n");
    va_end(arglist);
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x3798
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
testq %rdi, %rdi
je 0x37d7
movq %rdi, %rbx
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
callq 0x23c0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x21f0
addq $0xd0, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_misc.c
// Function: shoit_misc_report_time
int shoit_misc_report_time(struct timeval *start)
{
    struct timeval end;
    int usecs;

    gettimeofday(&end, NULL);
    usecs = 1000000 * (end.tv_sec - start->tv_sec) + (end.tv_usec - start->tv_usec);
    start->tv_sec = end.tv_sec;
    start->tv_usec = end.tv_usec;

    return usecs;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2170
movq (%r14), %rax
movq 0x8(%r14), %rcx
movl (%rbx), %edx
movl 0x8(%rbx), %esi
movq %rax, (%rbx)
subl %edx, %eax
imull $0xf4240, %eax, %edx    # imm = 0xF4240
movq %rcx, 0x8(%rbx)
movl %ecx, %eax
subl %esi, %eax
addl %edx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_progress.c
// Function: shoit_progress_init
void shoit_progress_init(progress_t *progress, char *title, int max, int style)
{

    //fprintf(stderr,"call func:%s\n",__func__);
    progress->chr = '#';
    progress->title = title;
    progress->style = style;
    progress->max = max;
    progress->offset = 100 / (float)max;
    progress->pro = (char *) malloc(max+1);

    if ( style == PROGRESS_BGC_STYLE ){
        memset(progress->pro,0, max+1);
    }else {
        memset(progress->pro, 32, max);
        memset(progress->pro+max, 0, 1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movl %edx, %ebx
movq %rdi, %r12
movb $0x23, (%rdi)
movq %rsi, 0x8(%rdi)
movl %ecx, 0x10(%rdi)
movl %edx, 0x14(%rdi)
cvtsi2ss %edx, %xmm0
movss 0x2c34(%rip), %xmm1     # 0x6538
divss %xmm0, %xmm1
movss %xmm1, 0x18(%rdi)
leal 0x1(%rbx), %eax
movslq %eax, %r15
movq %r15, %rdi
callq 0x22e0
movq %rax, %r14
movq %rax, 0x20(%r12)
cmpl $0x2, %ebp
jne 0x393d
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2190
movslq %ebx, %rbx
movq %r14, %rdi
movl $0x20, %esi
movq %rbx, %rdx
callq 0x2190
movb $0x0, (%r14,%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/pencode-lab[P]Shoit/shoit_progress.c
// Function: shoit_progress_for_stream
void shoit_progress_for_stream(FILE *fp,progress_t *progress, float bit)
{
    char buffer[512]={0};

    memset(buffer,0,512);
    
    float mbps = 1e-6 * 8*progress->total / (progress->utime == 0 ? .01 : progress->utime);

    snprintf(buffer,sizeof(buffer)-1,"%gMbps    %ldK    %.2fs    ",mbps,progress->total>>10,progress->utime);

    fprintf(fp,"\033[?25l\033[31m\033[1m%s%%\033[?25h\033[0m\r", buffer);
    fflush(fp); 
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rsi, %r15
movq %rdi, %rbx
movq %rsp, %r14
movl $0x200, %edx            # imm = 0x200
movq %r14, %rdi
xorl %esi, %esi
callq 0x2190
movq 0x28(%r15), %rcx
movss 0x30(%r15), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movaps %xmm1, %xmm0
jne 0x3b31
movaps %xmm1, %xmm0
jp 0x3b31
movsd 0x2a0f(%rip), %xmm0     # 0x6540
movq %rcx, %xmm2
punpckldq 0x2a12(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x2a1a(%rip), %xmm2     # 0x6560
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
mulsd 0x29ee(%rip), %xmm3     # 0x6548
divsd %xmm0, %xmm3
xorps %xmm0, %xmm0
cvtsd2ss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
shrq $0xa, %rcx
leaq 0x2a8f(%rip), %rdx      # 0x6603
movl $0x1ff, %esi            # imm = 0x1FF
movq %r14, %rdi
movb $0x2, %al
callq 0x2130
leaq 0x2a95(%rip), %rsi      # 0x661f
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2250
movq %rbx, %rdi
callq 0x22f0
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: tracestate
static void
tracestate(KD11A *cpu)
{
	(void)cpu;
	trace(" R0 %06o R1 %06o R2 %06o R3 %06o R4 %06o R5 %06o R6 %06o R7 %06o\n"
		" 10 %06o 11 %06o 12 %06o 13 %06o 14 %06o 15 %06o 16 %06o 17 %06o\n"
		" BA %06o IR %06o PSW %06o\n"
		,
		cpu->r[0], cpu->r[1], cpu->r[2], cpu->r[3],
		cpu->r[4], cpu->r[5], cpu->r[6], cpu->r[7],
		cpu->r[8], cpu->r[9], cpu->r[10], cpu->r[11],
		cpu->r[12], cpu->r[13], cpu->r[14], cpu->r[15],
		cpu->ba, cpu->ir, cpu->cur<<14 | cpu->prev<<12 | cpu->psw);
	trace(" SR0 %06o SR2 %06o\n",
		cpu->sr0, cpu->sr2);
	trace(" PAR %06o %06o %06o %06o %06o %06o %06o %06o\n"
	       "     %06o %06o %06o %06o %06o %06o %06o %06o\n",
		cpu->par[0], cpu->par[1], cpu->par[2], cpu->par[3],
		cpu->par[4], cpu->par[5], cpu->par[6], cpu->par[7],
		cpu->par[010], cpu->par[011], cpu->par[012], cpu->par[013],
		cpu->par[014], cpu->par[015], cpu->par[016], cpu->par[017]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x45534(%rip)     # 0x4ad60
je 0x58fe
movzwl (%rbx), %esi
movzwl 0x2(%rbx), %edx
movzwl 0x4(%rbx), %ecx
movzwl 0x6(%rbx), %r8d
movzwl 0x8(%rbx), %r9d
movzwl 0xa(%rbx), %eax
movq %rax, 0x10(%rsp)
movzwl 0xc(%rbx), %eax
movq %rax, 0x8(%rsp)
movzwl 0xe(%rbx), %eax
movq %rax, (%rsp)
movzwl 0x10(%rbx), %eax
movq %rax, 0x30(%rsp)
movzwl 0x12(%rbx), %eax
movq %rax, 0x28(%rsp)
movzwl 0x14(%rbx), %eax
movq %rax, 0x20(%rsp)
movzwl 0x16(%rbx), %eax
movq %rax, 0x18(%rsp)
movzwl 0x18(%rbx), %ebp
movzwl 0x86(%rbx), %eax
shll $0xe, %eax
movzwl 0x88(%rbx), %edi
shll $0xc, %edi
orl %eax, %edi
movzbl 0x30(%rbx), %r10d
orl %edi, %r10d
movzwl 0x1a(%rbx), %r13d
movzwl 0x1c(%rbx), %r11d
movzwl 0x1e(%rbx), %r14d
movzwl 0x24(%rbx), %r15d
movzwl 0x26(%rbx), %r12d
leaq 0x3d0e(%rip), %rdi      # 0x95d5
xorl %eax, %eax
pushq %r10
pushq %r12
pushq %r15
pushq %r14
pushq %r11
pushq %r13
pushq %rbp
pushq 0x50(%rsp)
pushq 0x60(%rsp)
pushq 0x70(%rsp)
pushq 0x80(%rsp)
pushq 0x58(%rsp)
pushq 0x68(%rsp)
pushq 0x78(%rsp)
callq 0x20a0
addq $0x70, %rsp
cmpl $0x0, 0x4545b(%rip)     # 0x4ad60
je 0x5923
movzwl 0x138(%rbx), %esi
movzwl 0x13a(%rbx), %edx
leaq 0x3d56(%rip), %rdi      # 0x9672
xorl %eax, %eax
callq 0x20a0
cmpl $0x0, 0x45436(%rip)     # 0x4ad60
je 0x59eb
movzwl 0x8c(%rbx), %esi
movzwl 0x8e(%rbx), %edx
movzwl 0x90(%rbx), %ecx
movzwl 0x92(%rbx), %r8d
movzwl 0x94(%rbx), %r9d
movzwl 0x96(%rbx), %eax
movq %rax, 0x10(%rsp)
movzwl 0x98(%rbx), %eax
movq %rax, 0x8(%rsp)
movzwl 0x9a(%rbx), %eax
movq %rax, (%rsp)
movzwl 0x9c(%rbx), %r15d
movzwl 0x9e(%rbx), %r12d
movzwl 0xa0(%rbx), %r13d
movzwl 0xa2(%rbx), %ebp
movzwl 0xa4(%rbx), %r10d
movzwl 0xa6(%rbx), %r11d
movzwl 0xa8(%rbx), %r14d
movzwl 0xaa(%rbx), %ebx
subq $0x8, %rsp
leaq 0x3cc5(%rip), %rdi      # 0x9686
xorl %eax, %eax
pushq %rbx
pushq %r14
pushq %r11
pushq %r10
pushq %rbp
pushq %r13
pushq %r12
pushq %r15
pushq 0x48(%rsp)
pushq 0x58(%rsp)
pushq 0x68(%rsp)
callq 0x20a0
addq $0x98, %rsp
jmp 0x59ef
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: setBA
static word
setBA(KD11A *cpu, word ba, int r, int ov, int oda)
{
	if(ov && r == SP && !(cpu->flags & FLAG_STALL))
		cpu->flags |= FLAG_CKOVF;
	else
		cpu->flags &= ~FLAG_CKOVF;
	if(oda)
		cpu->flags |= FLAG_CKODA;
	else
		cpu->flags &= ~FLAG_CKODA;
	return BA = ba;
}

// Assembly:
movl %esi, %eax
testl %ecx, %ecx
sete %cl
cmpl $0x6, %edx
setne %dl
orb %cl, %dl
jne 0x5a1b
movl 0x38(%rdi), %ecx
testb $0x8, %cl
jne 0x5a1b
orl $0x20, %ecx
movl %ecx, 0x38(%rdi)
jmp 0x5a1f
andb $-0x21, 0x38(%rdi)
xorl %ecx, %ecx
testl %r8d, %r8d
setne %cl
movl 0x38(%rdi), %edx
andl $-0x41, %edx
shll $0x6, %ecx
orl %edx, %ecx
movl %ecx, 0x38(%rdi)
movw %ax, 0x24(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: setMM
static void
setMM(KD11A *cpu, int mm)
{
	if(cpu->flags & FLAG_STALL){
		cpu->mode = 0;
		cpu->relocate = 0;
		return;
	}
	switch(mm&014){
	case 00: cpu->mode = cpu->cur; break;
	case 04: cpu->mode = cpu->temp; break;
	case 010: cpu->mode = cpu->mtp ? cpu->prev : cpu->cur; break;
	case 014: cpu->mode = cpu->mfp ? cpu->prev : cpu->cur; break;
	}
	cpu->relocate = (cpu->sr0&1) || (cpu->sr0&0400 && mm&1);
}

// Assembly:
testb $0x8, 0x38(%rdi)
jne 0x5a5f
movl %esi, %eax
shrl $0x2, %eax
andl $0x3, %eax
leaq 0x36fd(%rip), %rcx      # 0x914c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x86, %eax
jmp 0x5a92
movw $0x0, 0x84(%rdi)
xorl %ecx, %ecx
jmp 0x5ab7
xorl %eax, %eax
cmpl $0x0, 0x144(%rdi)
jmp 0x5a80
xorl %eax, %eax
cmpl $0x0, 0x140(%rdi)
setne %al
leaq 0x86(,%rax,2), %rax
jmp 0x5a92
movl $0x8a, %eax
movzwl (%rdi,%rax), %eax
movw %ax, 0x84(%rdi)
movzwl 0x138(%rdi), %eax
movl $0x1, %ecx
testb $0x1, %al
jne 0x5ab7
shrl $0x8, %eax
andl %esi, %eax
andl $0x1, %eax
movl %eax, %ecx
movl %ecx, 0x13c(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: writedest
static int
writedest(KD11A *cpu, int b)
{
	int d;
	// TODO: can we make this nicer??
	if((cpu->ir & 070) == 0){
		codes(cpu);
		d = cpu->ir & 7;
		if(d == SP && USER) d = USP;	// KT11-SP
		if(b) SETMASK(cpu->r[d], D, 0377);
		else cpu->r[d] = D;
	}else{
		if(b) D = (D<<8) | D&0377;
		setMM(cpu, 1);
		if(dato(cpu, b)) return 1;
	}
	return 0;
}

// Assembly:
movzwl 0x26(%rdi), %eax
testb $0x38, %al
je 0x69b2
testl %esi, %esi
je 0x698a
movb 0x22(%rdi), %al
movb %al, 0x23(%rdi)
testb $0x8, 0x38(%rdi)
jne 0x69f2
movzwl 0x86(%rdi), %eax
movw %ax, 0x84(%rdi)
movzwl 0x138(%rdi), %ecx
xorl %eax, %eax
testl $0x101, %ecx            # imm = 0x101
setne %al
jmp 0x69fd
movl 0x30(%rdi), %ecx
movl 0x14c(%rdi), %edx
xorl %ecx, %edx
andl 0x150(%rdi), %edx
xorl %ecx, %edx
movb %dl, 0x30(%rdi)
andl $0x7, %eax
cmpl $0x6, %eax
jne 0x69e4
movb 0x86(%rdi), %al
andb $0x2, %al
shrb %al
movzbl %al, %eax
leal 0x6(,%rax,8), %eax
testl %esi, %esi
je 0x6a1a
movl %eax, %eax
movb 0x22(%rdi), %cl
movb %cl, (%rdi,%rax,2)
jmp 0x6a24
movw $0x0, 0x84(%rdi)
xorl %eax, %eax
pushq %rax
movl %eax, 0x13c(%rdi)
callq 0x6262
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
leaq 0x8(%rsp), %rsp
je 0x6a24
retq
movzwl 0x22(%rdi), %ecx
movl %eax, %eax
movw %cx, (%rdi,%rax,2)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: remapBA
static int
remapBA(KD11A *cpu, int wr)
{
#ifdef KT11
	int i, pg, abrt;
	cpu->wrpg = nil;
	if(!cpu->relocate){
		PBA = ubxt(BA);
		cpu->flags &= ~FLAG_FAULT;
		return 0;
	}
	pg = BA>>13;
	i = (cpu->mode&2 ? 0 : 8) | pg;
	PBA = ((BA&017777) + (cpu->par[i]<<6)) & 0777777;

	abrt = 0;
	// not resident (or illegal mode)
	if((cpu->acf[i]&2)==0 || (6>>cpu->mode)&1)
		abrt |= 0100000;
	// page length
	if(cpu->acf[i]&010 ? ((BA&017700) < cpu->plf[i]) : ((BA&017700) > cpu->plf[i]))
		abrt |= 0040000;
	// read-only
	if(wr && (cpu->acf[i]&6)==2)
		abrt |= 0020000;
	abrt |= cpu->mode<<5 | pg<<1;
	if(!ABORT)
		SETMASK(cpu->sr0, abrt, 0160156);
	if((abrt&0160000) && !(cpu->flags & FLAG_STALL) && !(cpu->flags&FLAG_CKODA && BA&1)){
		cpu->flags |= FLAG_FAULT;
		return 1;
	}
	if(wr &&
	   !((PBA&0777770) == 0777570 && (PBA&0777776) != 0777570))	// ignore write to SR registers
		cpu->wrpg = &cpu->acf[i];
	cpu->flags &= ~FLAG_FAULT;
	return 0;
#else
	PBA = ubxt(BA);
	return 0;
#endif
}

// Assembly:
movq $0x0, 0x130(%rdi)
cmpl $0x0, 0x13c(%rdi)
movzwl 0x24(%rdi), %ecx
je 0x7397
pushq %rbp
pushq %rbx
movl %ecx, %r8d
shrl $0xd, %r8d
movzwl 0x84(%rdi), %r9d
movl %r9d, %eax
notl %eax
andl $0x2, %eax
leal (%r8,%rax,4), %eax
movl %ecx, %r10d
andl $0x1fff, %r10d          # imm = 0x1FFF
movzwl 0x8c(%rdi,%rax,2), %edx
shll $0x6, %edx
addl %r10d, %edx
movl %edx, %r10d
andl $0x3ffff, %r10d         # imm = 0x3FFFF
movq 0x28(%rdi), %r11
movl %r10d, 0x8(%r11)
movl 0xac(%rdi,%rax,4), %r10d
testb $0x2, %r10b
je 0x7376
xorl %r11d, %r11d
movl $0x6, %ebx
btl %r9d, %ebx
jae 0x737c
movl $0x8000, %r11d          # imm = 0x8000
movl %ecx, %ebx
andl $0x1fc0, %ebx           # imm = 0x1FC0
movl 0xec(%rdi,%rax,4), %ebp
testb $0x8, %r10b
jne 0x73b5
cmpl %ebx, %ebp
jl 0x73b9
jmp 0x73c0
movl %ecx, %eax
notl %eax
leal 0x30000(%rcx), %edx
testl $0xe000, %eax           # imm = 0xE000
cmovnel %ecx, %edx
movq 0x28(%rdi), %rax
movl %edx, 0x8(%rax)
jmp 0x747f
cmpl %ebx, %ebp
jle 0x73c0
orl $0x4000, %r11d          # imm = 0x4000
andl $0x6, %r10d
movl %r11d, %ebx
orl $0x2000, %ebx           # imm = 0x2000
cmpl $0x2, %r10d
cmovnel %r11d, %ebx
testl %esi, %esi
cmovel %r11d, %ebx
shll $0x5, %r9d
leal (%r9,%r8,2), %r8d
orl %ebx, %r8d
movzwl 0x138(%rdi), %r9d
cmpl $0x1fff, %r9d           # imm = 0x1FFF
popq %rbx
popq %rbp
ja 0x7415
andl $0x1f91, %r9d           # imm = 0x1F91
movl %r8d, %r10d
andl $0x1fe06e, %r10d        # imm = 0x1FE06E
orl %r9d, %r10d
movw %r10w, 0x138(%rdi)
testl $0xe000, %r8d           # imm = 0xE000
je 0x7449
movl 0x38(%rdi), %r8d
testb $0x8, %r8b
jne 0x7449
movl %r8d, %r9d
andl $0x40, %r9d
shrl $0x6, %r9d
testl %r9d, %ecx
jne 0x7449
orl $0x200, %r8d            # imm = 0x200
movl %r8d, 0x38(%rdi)
movl $0x1, %eax
retq
testl %esi, %esi
je 0x747f
movl %edx, %ecx
andl $0x3fff8, %ecx          # imm = 0x3FFF8
movl $0x3ff78, %esi          # imm = 0x3FF78
cmpl %esi, %ecx
sete %cl
andl $0x3ff7e, %edx          # imm = 0x3FF7E
cmpl %esi, %edx
setne %dl
testb %dl, %cl
jne 0x747f
leaq (%rdi,%rax,4), %rax
addq $0xac, %rax
movq %rax, 0x130(%rdi)
andb $-0x3, 0x39(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: checkbus
static int
checkbus(KD11A *cpu, int wr, int pse)
{
	int err = 0;
	int ba = BA&~1;
	if((wr|pse) && !(cpu->mode&2) && cpu->flags&FLAG_CKOVF){
		if(ba == 0177776 ||	// PSW
#ifdef KJ11
		   ba == 0177774 ||	// SLR
#endif
		   ba == 0177570){	// SR
			cpu->flags |= FLAG_OVFLW;	// proc address
			err = ovflwerr(cpu);
// TODO: what's going on here with KT11?
		}else if((BA&0177400) < SLR){
			cpu->flags |= FLAG_OVFLW;
			err = ovflwerr(cpu);
		}else if((BA&0177400) == SLR){
			cpu->flags |= FLAG_OVFLW;	// yellow zone
			if((BA&0340)!=0340)
				err = ovflwerr(cpu);
		}
	}
	if(cpu->flags&FLAG_CKODA && BA&1)
		err = buserr(cpu);
	return err;
}

// Assembly:
movzwl 0x24(%rdi), %ecx
xorl %eax, %eax
orl %edx, %esi
je 0x7501
testb $0x2, 0x84(%rdi)
jne 0x7501
movl 0x38(%rdi), %edx
testb $0x20, %dl
je 0x7501
movl %ecx, %r8d
andl $-0x2, %r8d
movl %ecx, %esi
notl %esi
testl $0xfffc, %esi           # imm = 0xFFFC
sete %r9b
cmpl $0xff78, %r8d           # imm = 0xFF78
sete %r8b
orb %r9b, %r8b
jne 0x74dd
movl %ecx, %r8d
andl $0xff00, %r8d           # imm = 0xFF00
movzwl 0x82(%rdi), %r9d
cmpl %r9d, %r8d
jae 0x7540
orl $0x98, %edx
movw $0x0, 0x84(%rdi)
movl $0x0, 0x13c(%rdi)
andl $-0x7, %edx
movl %edx, 0x38(%rdi)
movl $0x1, %eax
movl 0x38(%rdi), %edx
testb $0x40, %dl
je 0x753f
andl $0x1, %ecx
je 0x753f
testb $0x1, %dl
je 0x752f
orl $0x108, %edx            # imm = 0x108
movl %edx, 0x38(%rdi)
movw $0x0, 0x84(%rdi)
movl $0x0, 0x13c(%rdi)
movl 0x38(%rdi), %eax
andl $-0x8, %eax
incl %eax
movl %eax, 0x38(%rdi)
movl $0x1, %eax
retq
jne 0x7501
movl %edx, %r8d
orl $0x10, %r8d
movl %r8d, 0x38(%rdi)
testb $-0x20, %sil
jne 0x74dd
jmp 0x7501
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: wrpdr
static void
wrpdr(KD11A *cpu, int i, int b)
{
	if(!b || (BA&1)==0)
		cpu->acf[i] = UNIBUS_DATA & 016;
	if(!b || BA&1)
		cpu->plf[i] = UNIBUS_DATA>>2 & 017700;
	cpu->acf[i] &= ~0100;	// W bit
}

// Assembly:
movl %esi, %eax
testl %edx, %edx
je 0x7561
testb $0x1, 0x24(%rdi)
jne 0x7573
movq 0x28(%rdi), %rcx
movzwl 0xc(%rcx), %ecx
andl $0xe, %ecx
movl %ecx, 0xac(%rdi,%rax,4)
testl %edx, %edx
je 0x757d
testb $0x1, 0x24(%rdi)
je 0x7594
movq 0x28(%rdi), %rcx
movl 0xc(%rcx), %ecx
shrl $0x2, %ecx
andl $0x1fc0, %ecx           # imm = 0x1FC0
movl %ecx, 0xec(%rdi,%rax,4)
andb $-0x41, 0xac(%rdi,%rax,4)
retq
// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: wrpar
static void
wrpar(KD11A *cpu, int i, int b)
{
	if(!b || (BA&1)==0)
		cpu->par[i] = cpu->par[i]&07400 | UNIBUS_DATA&0377;
	if(!b || BA&1)
		cpu->par[i] = UNIBUS_DATA&07400 | cpu->par[i]&0377;
	cpu->acf[i] &= ~0100;	// W bit
}

// Assembly:
movl %esi, %eax
testl %edx, %edx
je 0x75a9
testb $0x1, 0x24(%rdi)
jne 0x75c9
movzwl 0x8c(%rdi,%rax,2), %ecx
andl $0xf00, %ecx            # imm = 0xF00
movq 0x28(%rdi), %rsi
movzbl 0xc(%rsi), %esi
orl %ecx, %esi
movw %si, 0x8c(%rdi,%rax,2)
testl %edx, %edx
je 0x75d3
testb $0x1, 0x24(%rdi)
je 0x75e5
movq 0x28(%rdi), %rcx
movzbl 0xd(%rcx), %ecx
andl $0xf, %ecx
movb %cl, 0x8d(%rdi,%rax,2)
andb $-0x41, 0xac(%rdi,%rax,4)
retq
nop
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/main.c
// Function: readRom
uint8_t* readRom(const char* filename, int print)
{
    FILE* romfile = fopen(filename, "rb");
    if (romfile == NULL)
    {
        printf("Error reading file %s\n", filename);
        exit(1);
    }
    uint8_t* rom = malloc(sizeof(uint8_t) * 128 * MEMORY_SEGMENT_SIZE);
    memset(rom, 0, sizeof(uint8_t) * 128 * MEMORY_SEGMENT_SIZE);
    size_t bytesRead = fread(rom, sizeof(uint8_t), 128 * MEMORY_SEGMENT_SIZE, romfile);
    printf("Read %Id bytes from the rom\n", bytesRead);
    if (print)
    {
        printf("Rom:\n");
        int i;
        for (i = 0; i < bytesRead; i++)
            printf("%2X\n", rom[i]);
    }
    fclose(romfile);
    return rom;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
leaq 0x1969(%rip), %rsi      # 0x3010
callq 0x1150
testq %rax, %rax
je 0x174e
movq %rax, %rbx
movl $0x8000, %edi           # imm = 0x8000
callq 0x1180
movq %rax, %r14
movl $0x8000, %edx           # imm = 0x8000
movq %rax, %rdi
xorl %esi, %esi
callq 0x10a0
movl $0x1, %esi
movl $0x8000, %edx           # imm = 0x8000
movq %r14, %rdi
movq %rbx, %rcx
callq 0x11c0
movq %rax, %r12
leaq 0x1980(%rip), %rdi      # 0x3073
movq %rax, %rsi
xorl %eax, %eax
callq 0x1040
testl %r15d, %r15d
je 0x1734
leaq 0x19b7(%rip), %rdi      # 0x30c0
callq 0x11d0
testq %r12, %r12
je 0x1734
leaq 0x1954(%rip), %r15      # 0x306e
xorl %r13d, %r13d
movzbl (%r14,%r13), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1040
incq %r13
cmpq %r13, %r12
jne 0x171d
movq %rbx, %rdi
callq 0x1120
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18be(%rip), %rdi      # 0x3013
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
movl $0x1, %edi
callq 0x1170
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/vm.c
// Function: createVM
VM* createVM(uint16_t* code, uint8_t* rom, Display* display, int debugMode)
{
    VM* vm = (VM*)malloc(sizeof(VM));
    vm->cpu.code = code;
    vm->cpu.pc = code;
    vm->cpu.debugMode = debugMode;
    vm->cpu.breakState = 0;
    vm->cpu.step = 0;
    vm->display = display;
    vm->gpu = createGPU();
    vm->ipu = createIPU();
    memset(vm->memory, 0, sizeof(vm->memory[0][0]) * MEMORY_SEGMENT_COUNT * MEMORY_SEGMENT_SIZE);
    memset(vm->cpu.regs, 0, sizeof(vm->cpu.regs[0]) * REGISTER_COUNT);
    if (rom != NULL) // ROM is optional
        memcpy(vm->memory[128], rom, 128 * MEMORY_SEGMENT_SIZE);
    return vm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
movl $0x10048, %edi          # imm = 0x10048
callq 0x1180
movq %rax, %r14
movq %r13, 0x18(%rax)
movq %r13, 0x10(%rax)
movl %r15d, 0x20(%rax)
movq $0x0, 0x24(%rax)
movq %r12, 0x10040(%rax)
callq 0x1d3c
movq %rax, 0x10030(%r14)
xorl %eax, %eax
callq 0x23b0
movq %rax, 0x10038(%r14)
leaq 0x30(%r14), %rdi
movl $0x10000, %edx          # imm = 0x10000
xorl %esi, %esi
callq 0x10a0
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
testq %rbx, %rbx
je 0x17fb
movq %r14, %rdi
addq $0x8030, %rdi           # imm = 0x8030
movl $0x8000, %edx           # imm = 0x8000
movq %rbx, %rsi
callq 0x10e0
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/vm.c
// Function: destroyVM
void destroyVM(VM* vm)
{
    destroyGPU(vm->gpu);
    vm->gpu = NULL;
    destroyIPU(vm->ipu);
    vm->ipu = NULL;
    free(vm);
    vm = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x10030(%rdi), %rdi
callq 0x1d82
xorl %r14d, %r14d
movq %r14, 0x10030(%rbx)
movq 0x10038(%rbx), %rdi
callq 0x241c
movq %r14, 0x10038(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1160
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/display.c
// Function: createDisplay
Display* createDisplay(int width, int height, int scale, int pitch)
{
    SDL_Init(SDL_INIT_VIDEO);

    Display* display = (Display*)malloc(sizeof(Display));
    display->width = width;
    display->height = height;
    display->scale = scale;
    display->pitch = pitch;
    display->window = SDL_CreateWindow("Vapor Spec", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 
            width * scale, height * scale, 0);
    display->renderer = SDL_CreateRenderer(display->window, -1, 0);
    display->back = SDL_CreateTexture(display->renderer, 
            SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, width, height);
    SDL_Surface* splash = SDL_LoadBMP("title.bmp");
    SDL_Texture* splashTex = SDL_CreateTextureFromSurface(display->renderer, splash);
    SDL_RenderCopy(display->renderer, splashTex, NULL, NULL);
    SDL_RenderPresent(display->renderer);
    SDL_Delay(2000); // Show splash screen for 2 seconds
    return display;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r12d
movl %edx, %r13d
movl %esi, %r14d
movl %edi, %r15d
movl $0x20, %edi
callq 0x10f0
movl $0x28, %edi
callq 0x1180
movq %rax, %rbx
movl %r15d, 0x18(%rax)
movl %r14d, 0x1c(%rax)
movl %r13d, 0x20(%rax)
movl %r12d, 0x24(%rax)
movl %r13d, %ecx
imull %r15d, %ecx
imull %r14d, %r13d
leaq 0x1525(%rip), %rdi      # 0x3154
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0x1050
movq %rax, (%rbx)
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x1030
movq %rax, %r12
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movl $0x17101803, %esi       # imm = 0x17101803
movl $0x1, %edx
movl %r15d, %ecx
movl %r14d, %r8d
callq 0x11f0
movq %rax, 0x10(%rbx)
leaq 0x14df(%rip), %rdi      # 0x315f
leaq 0x1389(%rip), %rsi      # 0x3010
callq 0x1090
movq %rax, %rdi
movl $0x1, %esi
callq 0x1100
movq %r12, %rdi
movq %rax, %rsi
callq 0x1190
movq %r12, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1140
movq %r12, %rdi
callq 0x1070
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x10c0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/display.c
// Function: updateDisplay
void updateDisplay(Display* display, GPU* gpu)
{
    SDL_UpdateTexture(display->back, NULL, gpu->pixels, gpu->pitch);
    SDL_RenderClear(display->renderer);
    SDL_RenderCopy(display->renderer, display->back, NULL, NULL);
    SDL_RenderPresent(display->renderer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq 0xc00(%rsi), %rdx
movl 0xc08(%rsi), %ecx
xorl %esi, %esi
callq 0x10d0
movq 0x8(%rbx), %rdi
callq 0x1110
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1140
movq 0x8(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1070
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/display.c
// Function: quitDisplay
void quitDisplay(Display* display)
{
    display->window = NULL;
    display->back = NULL;
    free(display);
    display = NULL;
    SDL_Quit();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movq %rax, (%rdi)
movq %rax, 0x10(%rdi)
callq 0x1160
popq %rbp
jmp 0x1060
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/gpu.c
// Function: createGPU
GPU* createGPU()
{
    GPU* gpu = (GPU*)malloc(sizeof(GPU));
    gpu->active = 1;
    gpu->bytesPerPixel = 3; // From SDL_PIXELFORMAT_RGB24 in display.c
    gpu->pitch = SCREEN_WIDTH * gpu->bytesPerPixel;
    gpu->pixels = (uint8_t *) malloc(sizeof(uint8_t) * gpu->bytesPerPixel * SCREEN_WIDTH * SCREEN_HEIGHT);
    return gpu;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0xc18, %edi            # imm = 0xC18
callq 0x1180
movq %rax, %rbx
orb $0x1, 0xc10(%rax)
movabsq $0x300000300, %rax      # imm = 0x300000300
movq %rax, 0xc08(%rbx)
movl $0x24000, %edi          # imm = 0x24000
callq 0x1180
movq %rax, 0xc00(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/gpu.c
// Function: updateGPU
void updateGPU(GPU* gpu, uint8_t memory[MEMORY_SEGMENT_COUNT][MEMORY_SEGMENT_SIZE])
{
    gpu->active = memory[GPU_FLAG_SEG][GPU_FLAG_OFFSET] & 0x1;
    if (gpu->active)
    {
        // Preserve other bits, only change the second bit
        gpu->refreshed = !gpu->refreshed;
        memory[GPU_FLAG_SEG][GPU_FLAG_OFFSET] &= 0xFD; // Clear the second bit
        memory[GPU_FLAG_SEG][GPU_FLAG_OFFSET] |= (gpu->refreshed << 1); // Set the second bit according to gpu->refreshed
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0x7f11(%rsi), %dl
andb $0x1, %dl
movb 0xc10(%rdi), %cl
movl %ecx, %eax
andb $-0x2, %al
orb %dl, %al
movb %al, 0xc10(%rdi)
testb %dl, %dl
je 0x1df6
andb $0x2, %cl
andb $-0x3, %al
orb %cl, %al
xorb $0x2, %al
movb %al, 0xc10(%rdi)
movb 0x7f11(%rsi), %al
andb $-0x3, %al
movb %al, 0x7f11(%rsi)
movb 0xc10(%rdi), %cl
andb $0x2, %cl
orb %al, %cl
movb %cl, 0x7f11(%rsi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/gpu.c
// Function: readSpritesFromMem
void readSpritesFromMem(GPU* gpu, uint8_t memory[MEMORY_SEGMENT_COUNT][MEMORY_SEGMENT_SIZE])
{
    int i;
    for (i = 0; i < NUM_SPRITES; i++)
    {
        uint8_t flags = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH];
        gpu->sprAttrs[i].active = flags >> 7;
        gpu->sprAttrs[i].flipHor = flags >> 6 & 0x1;
        gpu->sprAttrs[i].flipVer = flags >> 5 & 0x1;
        gpu->sprAttrs[i].color4Alpha = flags >> 4 & 0x1;
        gpu->sprAttrs[i].fullWidth = flags >> 3 & 0x1;
        gpu->sprAttrs[i].fullHeight = flags >> 2 & 0x1;
        gpu->sprAttrs[i].x = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 1];
        gpu->sprAttrs[i].y = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 2];
        gpu->sprAttrs[i].width = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 3];
        gpu->sprAttrs[i].height = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 4];
        gpu->sprAttrs[i].segmentAddr = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 5];
        gpu->sprAttrs[i].byteAddr = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 6];
        gpu->sprAttrs[i].colors[0] = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 7];
        gpu->sprAttrs[i].colors[1] = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 8];
        gpu->sprAttrs[i].colors[2] = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 9];
        gpu->sprAttrs[i].colors[3] = memory[SPRITE_ATTR_SEG][i * SPRITE_ATTR_LENGTH + 10];
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
addq $0x400a, %rsi           # imm = 0x400A
xorl %eax, %eax
movb -0xa(%rsi), %cl
movl %ecx, %edx
shrb $0x7, %dl
movb (%rdi,%rax), %r8b
andb $-0x40, %r8b
orb %dl, %r8b
movl %ecx, %edx
shrb $0x5, %dl
andb $0x2, %dl
orb %r8b, %dl
movl %ecx, %r8d
shrb $0x3, %r8b
andb $0x4, %r8b
orb %dl, %r8b
movl %ecx, %edx
shrb %dl
andb $0x8, %dl
orb %r8b, %dl
leal (%rcx,%rcx), %r8d
andb $0x10, %r8b
orb %dl, %r8b
shlb $0x3, %cl
andb $0x20, %cl
orb %r8b, %cl
movb %cl, (%rdi,%rax)
movb -0x9(%rsi), %cl
movb %cl, 0x1(%rdi,%rax)
movb -0x8(%rsi), %cl
movb %cl, 0x2(%rdi,%rax)
movb -0x7(%rsi), %cl
movb %cl, 0x3(%rdi,%rax)
movb -0x6(%rsi), %cl
movb %cl, 0x4(%rdi,%rax)
movb -0x5(%rsi), %cl
movb %cl, 0x5(%rdi,%rax)
movb -0x4(%rsi), %cl
movb %cl, 0x6(%rdi,%rax)
movb -0x3(%rsi), %cl
movb %cl, 0x7(%rdi,%rax)
movb -0x2(%rsi), %cl
movb %cl, 0x8(%rdi,%rax)
movb -0x1(%rsi), %cl
movb %cl, 0x9(%rdi,%rax)
movb (%rsi), %cl
movb %cl, 0xa(%rdi,%rax)
addq $0x10, %rsi
addq $0xc, %rax
cmpq $0xc00, %rax            # imm = 0xC00
jne 0x1e05
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/ipu.c
// Function: createIPU
IPU* createIPU()
{
    IPU* ipu = (IPU*)malloc(sizeof(IPU));
    JOYSTICK* js1 = (JOYSTICK*)malloc(sizeof(JOYSTICK));
    js1->buttons[0] = SDLK_UP;
    js1->buttons[1] = SDLK_DOWN;
    js1->buttons[2] = SDLK_LEFT;
    js1->buttons[3] = SDLK_RIGHT;
    js1->buttons[4] = SDLK_o;
    js1->buttons[5] = SDLK_u;
    js1->buttons[6] = SDLK_y;
    js1->buttons[7] = SDLK_h;
    js1->keysAsBits = 0;
    ipu->js1 = js1;

    JOYSTICK* js2 = (JOYSTICK*)malloc(sizeof(JOYSTICK));
    js2->buttons[0] = SDLK_w;
    js2->buttons[1] = SDLK_s;
    js2->buttons[2] = SDLK_a;
    js2->buttons[3] = SDLK_d;
    js2->buttons[4] = SDLK_q;
    js2->buttons[5] = SDLK_e;
    js2->buttons[6] = SDLK_r;
    js2->buttons[7] = SDLK_f;
    js2->keysAsBits = 0;
    ipu->js2 = js2;

    return ipu;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl $0x10, %edi
callq 0x1180
movq %rax, %rbx
movl $0x24, %edi
callq 0x1180
movaps 0xd9b(%rip), %xmm0      # 0x3170
movups %xmm0, (%rax)
movaps 0xda1(%rip), %xmm0      # 0x3180
movups %xmm0, 0x10(%rax)
xorl %r14d, %r14d
movb %r14b, 0x20(%rax)
movq %rax, (%rbx)
movl $0x24, %edi
callq 0x1180
movaps 0xd92(%rip), %xmm0      # 0x3190
movups %xmm0, (%rax)
movaps 0xd98(%rip), %xmm0      # 0x31a0
movups %xmm0, 0x10(%rax)
movb %r14b, 0x20(%rax)
movq %rax, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/ipu.c
// Function: destroyIPU
void destroyIPU(IPU* ipu)
{
    free(ipu->js1);
    ipu->js1 = NULL;
    free(ipu->js2);
    ipu->js2 = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x1160
xorl %r14d, %r14d
movq %r14, (%rbx)
movq 0x8(%rbx), %rdi
callq 0x1160
movq %r14, 0x8(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/ipu.c
// Function: updateIPU
void updateIPU(IPU* ipu, SDL_KeyboardEvent kEvent, 
        uint8_t memory[MEMORY_SEGMENT_COUNT][MEMORY_SEGMENT_SIZE])
{
    updateJoystick(ipu->js1, kEvent);
    updateJoystick(ipu->js2, kEvent);
    memory[JOYSTICK_SEG][JOYSTICK_1_OFFSET] = ipu->js1->keysAsBits;
    memory[JOYSTICK_SEG][JOYSTICK_2_OFFSET] = ipu->js2->keysAsBits;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movl 0x10(%rbp), %edx
movl 0x24(%rbp), %r8d
xorl %ecx, %ecx
cmpl (%rax,%rcx,4), %r8d
jne 0x248f
cmpl $0x301, %edx            # imm = 0x301
je 0x247b
cmpl $0x300, %edx            # imm = 0x300
jne 0x248f
movl $0x1, %r9d
shll %cl, %r9d
orb 0x20(%rax), %r9b
jmp 0x248b
movl $0x1, %r9d
shll %cl, %r9d
notb %r9b
andb 0x20(%rax), %r9b
movb %r9b, 0x20(%rax)
incq %rcx
cmpq $0x8, %rcx
jne 0x2456
movq 0x8(%rdi), %r9
xorl %ecx, %ecx
cmpl (%r9,%rcx,4), %r8d
jne 0x24d7
cmpl $0x301, %edx            # imm = 0x301
je 0x24c3
cmpl $0x300, %edx            # imm = 0x300
jne 0x24d7
movl $0x1, %r10d
shll %cl, %r10d
orb 0x20(%r9), %r10b
jmp 0x24d3
movl $0x1, %r10d
shll %cl, %r10d
notb %r10b
andb 0x20(%r9), %r10b
movb %r10b, 0x20(%r9)
incq %rcx
cmpq $0x8, %rcx
jne 0x249e
movb 0x20(%rax), %al
movb %al, 0x7f00(%rsi)
movq 0x8(%rdi), %rax
movb 0x20(%rax), %al
movb %al, 0x7f01(%rsi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/ipu.c
// Function: updateJoystick
void updateJoystick(JOYSTICK* js, SDL_KeyboardEvent kEvent)
{
    int i;
    uint8_t bit = 1;
    for (i = 0; i < NUM_JOYSTICK_BUTTONS; i++)
    {
        if (kEvent.keysym.sym == js->buttons[i])
        {
            if (kEvent.type == SDL_KEYDOWN)
            {
                // Leave the other bits but ensure the ith bit is 1
                js->keysAsBits |= (bit << i);
            }
            else if (kEvent.type == SDL_KEYUP)
            {
                // Leave the other bits but ensure the ith bit is 0
                js->keysAsBits &= (~(bit << i)); // Bitwise inversion
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x10(%rbp), %eax
movl 0x24(%rbp), %edx
xorl %ecx, %ecx
cmpl (%rdi,%rcx,4), %edx
jne 0x2532
cmpl $0x301, %eax            # imm = 0x301
je 0x2524
cmpl $0x300, %eax            # imm = 0x300
jne 0x2532
movl $0x1, %esi
shll %cl, %esi
orb %sil, 0x20(%rdi)
jmp 0x2532
movl $0x1, %esi
shll %cl, %esi
notb %sil
andb %sil, 0x20(%rdi)
incq %rcx
cmpq $0x8, %rcx
jne 0x2504
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/cpu.c
// Function: decode
void decode(uint16_t instr, Instruction* decoded)
{
    uint16_t clean = 0x000F;
    decoded->opcode = instr >> 12 & clean;
    decoded->arg0 = instr >> 8 & clean;
    decoded->arg1 = instr >> 4 & clean;
    decoded->arg2 = instr & clean;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, %eax
shrl $0xc, %eax
movl %edi, %ecx
shrl $0x4, %ecx
andl $0xf0, %ecx
movl %edi, %edx
shll $0x4, %edx
andl $0xf00, %edx            # imm = 0xF00
shll $0xc, %edi
orl %eax, %edi
orl %ecx, %edi
orl %edx, %edi
movw %di, (%rsi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/minkcv[P]vm/machine/cpu.c
// Function: print_disasm_block
void print_disasm_block(CPU *cpu) {
    // Disassemble next 16 instructions
    int i;
    for (i = 0; i < 16; i++)
    {
	int instructionCount = cpu->pc - cpu->code + i;
	if (instructionCount > JUMP_SEGMENT_SIZE * JUMP_SEGMENT_SIZE)
	  continue; // End of program, can't keep reading instructions.
	int instructionSegment = instructionCount / JUMP_SEGMENT_SIZE;
	int instructionOffset = instructionCount % JUMP_SEGMENT_SIZE;
	char assembly[256];
	memset(assembly, 0, sizeof(char) * 256);
	Instruction decoded;
	decode(*(cpu->pc + i), &decoded);
	disassemble(&decoded, assembly);
	// Print star for current instruction
	if (i == 0)
	  printf("*");
	else
	  printf(" ");

	// Print disassembly with segment.offset address
	printf(" %-30s ; %03d.%03d 0x%02X.0x%02X\n", assembly,
	       instructionSegment, instructionOffset,
	       instructionSegment, instructionOffset);
      }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
xorl %r12d, %r12d
movq 0x10(%rbx), %r14
movq %r14, %r13
subq 0x18(%rbx), %r13
shrq %r13
addq %r12, %r13
cmpl $0x10000, %r13d         # imm = 0x10000
jg 0x2aa8
leal 0xff(%r13), %r15d
testl %r13d, %r13d
cmovnsl %r13d, %r15d
movl %r15d, %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
subl %eax, %r13d
sarl $0x8, %r15d
movl $0x100, %edx            # imm = 0x100
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
callq 0x10a0
movzwl (%r14,%r12,2), %eax
movl %eax, %ecx
shrl $0xc, %ecx
movl %eax, %edx
shrl $0x4, %edx
andl $0xf0, %edx
movl %eax, %esi
shll $0x4, %esi
andl $0xf00, %esi            # imm = 0xF00
shll $0xc, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movw %ax, -0x2c(%rbp)
leaq -0x2c(%rbp), %rdi
leaq -0x130(%rbp), %r14
movq %r14, %rsi
callq 0x2540
testq %r12, %r12
movl $0x20, %edi
movl $0x2a, %eax
cmovel %eax, %edi
callq 0x11a0
leaq 0x994(%rip), %rdi       # 0x3426
movq %r14, %rsi
movl %r15d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
movl %r13d, %r9d
xorl %eax, %eax
callq 0x1040
incq %r12
cmpq $0x10, %r12
jne 0x29e8
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq