LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/meaning-matters[P]Except/List.c
// Function: ListConcat
List * ListConcat(
        List *      pListDst,       /* pointer to destination list */
        List *      pListAdd)       /* pointer to list to be added at tail */
    {
        assert(pListDst != NULL);
        assert(pListAdd != NULL);

        switch (((pListAdd->count > 0) << 1) | (pListDst->count > 0))
        {
        case 0:
            /* both lists empty */

            break;

        case 1:
            /* destination list not empty and add list empty */

            break;

        case 2:
            /* destination list empty and add list not empty */

            pListDst->pHead->pNext = pListAdd->pHead->pNext;
            pListDst->pHead->pNext->pPrev = pListDst->pHead;
            pListDst->pHead->pPrev = pListAdd->pHead->pPrev;
            pListDst->pHead->pPrev->pNext = pListDst->pHead;
            break;

        case 3:
            /* both lists not empty */

            pListAdd->pHead->pPrev->pNext = pListDst->pHead;
            pListDst->pHead->pPrev->pNext = pListAdd->pHead->pNext;
            pListAdd->pHead->pNext->pPrev = pListDst->pHead->pPrev;
            pListDst->pHead->pPrev = pListAdd->pHead->pPrev;
            break;
        }

        pListDst->pNodeLast = NULL;
        pListDst->count += pListAdd->count;

        free(pListAdd->pHead);
        free(pListAdd);

        return pListDst;
    }

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x3675
leaq 0x3bd9(%rip), %rax      # 0x7230
movq (%rax), %rdi
leaq 0xdb5(%rip), %rdx       # 0x4416
leaq 0xd1a(%rip), %rcx       # 0x4382
xorl %esi, %esi
movl $0x372, %r8d            # imm = 0x372
callq 0x24a8
testq %r14, %r14
jne 0x369f
leaq 0x3baf(%rip), %rax      # 0x7230
movq (%rax), %rdi
leaq 0xd9c(%rip), %rdx       # 0x4427
leaq 0xcf0(%rip), %rcx       # 0x4382
xorl %esi, %esi
movl $0x373, %r8d            # imm = 0x373
callq 0x24a8
movl 0x10(%r14), %eax
xorl %edx, %edx
testl %eax, %eax
setg %dl
movl 0x10(%rbx), %ecx
xorl %esi, %esi
testl %ecx, %ecx
setg %sil
leal (%rsi,%rdx,2), %edx
cmpl $0x2, %edx
je 0x36e7
cmpl $0x3, %edx
jne 0x3704
movq (%rbx), %rdx
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
movq %rdx, (%rsi)
movq (%rdi), %rsi
movq 0x8(%rdx), %r8
movq %rsi, (%r8)
movq %r8, 0x8(%rsi)
movq 0x8(%rdi), %rsi
movq %rsi, 0x8(%rdx)
jmp 0x3707
movq (%r14), %rdi
movq (%rdi), %rdx
movq (%rbx), %rsi
movq %rdx, (%rsi)
movq %rsi, 0x8(%rdx)
movq 0x8(%rdi), %rdx
movq %rdx, 0x8(%rsi)
movq %rsi, (%rdx)
jmp 0x3707
movq (%r14), %rdi
movq $0x0, 0x8(%rbx)
addl %eax, %ecx
movl %ecx, 0x10(%rbx)
callq 0x1040
movq %r14, %rdi
callq 0x1040
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/cirocosta[P]stress/src/locks.c
// Function: create_file
void
create_file(const char* base, const int i)
{
	FILE* fp;
	char* filename;

	_STRESS_MUST(asprintf(&filename, "%s/file%d", base, i) > 0,
	             "Couldn't create name for file %d",
	             i);
	_STRESS_MUST(
	  (fp = fopen(filename, "a")), "Couldn't create file %s", filename);

	_STRESS_MUST_P(!flock(fileno(fp), LOCK_EX),
	               "flock",
	               "Couldn't acquire lock on %s",
	               filename);

	fprintf(fp, "dummy");
	free(filename);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %rdx
leaq 0x57e(%rip), %rsi       # 0x210d
leaq 0x8(%rsp), %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1140
testl %eax, %eax
jle 0x1bfb
movq 0x8(%rsp), %rdi
leaq 0x597(%rip), %rsi       # 0x2144
callq 0x1150
testq %rax, %rax
je 0x1c02
movq %rax, %rbx
movq %rax, %rdi
callq 0x1130
movl %eax, %edi
movl $0x2, %esi
callq 0x1180
testl %eax, %eax
jne 0x1c0c
leaq 0x5b8(%rip), %rdi       # 0x2191
movl $0x5, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
movq 0x8(%rsp), %rdi
callq 0x1030
addq $0x10, %rsp
popq %rbx
retq
movl %ebx, %edi
callq 0x141c
leaq 0x8(%rsp), %rdi
callq 0x15d3
leaq 0x8(%rsp), %rdi
callq 0x14d2
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit.c
// Function: shoit_init_synch
void shoit_init_synch(shoit_core_t *shoit)
{
    sem_init(&shoit->progSem,0,0);
    sem_init(&shoit->dataSem,0,0);
    if(pipe(shoit->pipe)==-1) perror("pipe");
    pthread_mutex_init(&shoit->sendBlockLock, NULL);
    pthread_cond_init(&shoit->sendBlockCond, NULL);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x100, %rdi            # imm = 0x100
xorl %esi, %esi
xorl %edx, %edx
callq 0x2320
leaq 0x120(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2320
leaq 0x140(%rbx), %rdi
callq 0x21c0
cmpl $-0x1, %eax
je 0x2b72
leaq 0x178(%rbx), %rdi
xorl %esi, %esi
callq 0x2460
addq $0x148, %rbx            # imm = 0x148
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
jmp 0x22b0
leaq 0x41de(%rip), %rdi      # 0x6d57
callq 0x2390
jmp 0x2b52
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit.c
// Function: shoit_init_error_bitmap
void shoit_init_error_bitmap(shoit_core_t *shoit)
{
    uint64_t i;
    char *errorBitmap = (char*)(shoit->errorBitmap + sizeof(shoit_control_t));

    memset(shoit->errorBitmap,0,sizeof(shoit_control_t));
    // the first byte is 0 if there is error.  1 if all done.
    uint64_t startOfLastByte = shoit->totalNumberOfPackets - (shoit->sizeofErrorBitmap-2)*8;
    char bits[8] = {0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080};

    /* The first byte is for judging all_done */
    for (i=0;i<shoit->sizeofErrorBitmap;i++)
        errorBitmap[i] = 0;

    /* Preset those bits unused */
    for (i=startOfLastByte;i<8;i++)
        errorBitmap[shoit->sizeofErrorBitmap-1] |= bits[i];
}

// Assembly:
movq 0xd0(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xe(%rax)
movups %xmm0, (%rax)
movq 0x38(%rdi), %rcx
movq 0xd8(%rdi), %rsi
leaq (,%rsi,8), %rdx
subq %rdx, %rcx
leaq 0x10(%rcx), %rdx
testq %rsi, %rsi
je 0x2c11
xorl %esi, %esi
movb $0x0, 0x1e(%rax,%rsi)
incq %rsi
cmpq 0xd8(%rdi), %rsi
jb 0x2c00
cmpq $0x7, %rdx
ja 0x2c38
leaq 0x374b(%rip), %rdx      # 0x6369
movb 0x10(%rcx,%rdx), %sil
movq 0xd8(%rdi), %r8
orb %sil, 0x1d(%rax,%r8)
incq %rcx
cmpq $-0x8, %rcx
jne 0x2c1e
retq
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit.c
// Function: shoit_update_error_bitmap
bool shoit_update_error_bitmap(shoit_core_t *shoit,uint64_t seq)
{
    char *errorBitmap = (char*)(shoit->errorBitmap + sizeof(shoit_control_t));
    uint64_t index_in_list, offset_in_index;

    char bits[8] = {0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080};
    if(seq < 0 || (seq >> 3) >= shoit->sizeofErrorBitmap-1) {
        if(shoit->verbose) {
            fprintf(stderr, "seqno <%ld> wrong,out of range:0 ... %ld\n",seq,shoit->sizeofErrorBitmap);
            exit(0);
        }
        return false;
    }
    // seq starts with 0
    index_in_list = seq >> 3; /*8bit*/
    index_in_list ++;
    offset_in_index = seq%8;
    errorBitmap[index_in_list] |= bits[offset_in_index];

    return true;
}

// Assembly:
movq %rsi, %rax
shrq $0x3, %rax
movq 0xd8(%rdi), %rcx
leaq -0x1(%rcx), %rdx
cmpq %rdx, %rax
jae 0x2c6e
movq 0xd0(%rdi), %rcx
andl $0x7, %esi
leaq 0x3708(%rip), %rdx      # 0x6369
movb (%rsi,%rdx), %dl
orb %dl, 0x1f(%rcx,%rax)
movl $0x1, %eax
retq
xorl %eax, %eax
cmpl $0x0, 0x5c(%rdi)
jne 0x2c77
retq
pushq %rax
movq %rsi, %rdi
movq %rcx, %rsi
callq 0x25a4
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit.c
// Function: shoit_update_hash_table
uint64_t shoit_update_hash_table(shoit_core_t *shoit,bool update)
{
    uint64_t count = 0;
    uint64_t i,j;
    char bits[8] = {0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080};
    char *errorBitmap = (char*)(shoit->errorBitmap + sizeof(shoit_control_t));

    for (i=1;i<shoit->sizeofErrorBitmap; i++)
    {
        for (j=0;j<8;j++)
        {
            if ((errorBitmap[i] & bits[j]) == 0)
            {
                if(update)
                    shoit->hashTable[count] = (i-1)*8+j;
                count ++;
            }
        }
    }
    // set the first byte to let the sender know "all done"
    if (count == 0 && update)
        errorBitmap[0] = 1;

    return count;
}

// Assembly:
pushq %rbx
movq 0xd0(%rdi), %rcx
cmpq $0x2, 0xd8(%rdi)
jb 0x2ce5
movl $0x1, %edx
xorl %r8d, %r8d
leaq 0x36c5(%rip), %r9       # 0x6369
xorl %eax, %eax
xorl %r10d, %r10d
movb (%r10,%r9), %r11b
testb %r11b, 0x1e(%rcx,%rdx)
jne 0x2cca
testl %esi, %esi
je 0x2cc7
leaq (%r8,%r10), %r11
movq 0xc8(%rdi), %rbx
movq %r11, (%rbx,%rax,8)
incq %rax
incq %r10
cmpq $0x8, %r10
jne 0x2ca9
incq %rdx
addq $0x8, %r8
cmpq 0xd8(%rdi), %rdx
jb 0x2ca6
jmp 0x2ce7
xorl %eax, %eax
testl %esi, %esi
je 0x2cf4
testq %rax, %rax
jne 0x2cf4
movb $0x1, 0x1e(%rcx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_resolve_address
int shoit_network_resolve_address(struct sockaddr *sa, socklen_t *salen, const char *host, const int port, int family, int type,int proto)
{
    struct addrinfo hints, *res;
    int err;
    char sport[8]={0};

    memset(sport,0,8);
    snprintf(sport,7,"%d",port);

    memset(&hints, 0, sizeof(hints));
    hints.ai_family = family;
    hints.ai_socktype = type;
    hints.ai_protocol = proto;
    hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV | AI_PASSIVE;
    if ((err = getaddrinfo(host, sport, &hints, &res)) != 0 || res == NULL) {
        fprintf(stderr, "failed to resolve address:%s:%s:%s\n", host, sport,
                err != 0 ? gai_strerror(err) : "getaddrinfo returned NULL");
        return -1;
    }
    memcpy(sa, res->ai_addr, res->ai_addrlen);
    *salen = res->ai_addrlen;                                                                                                        
    freeaddrinfo(res);                                                                                                               
    return 0;                                                                                                                        
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %ebp
movl %r8d, %r12d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %r13
movq $0x0, (%r13)
leaq 0x4187(%rip), %rdx      # 0x6eb4
movl $0x7, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x2130
xorps %xmm0, %xmm0
leaq 0x18(%rsp), %rdx
movups %xmm0, 0x10(%rdx)
movups %xmm0, 0x20(%rdx)
movl %r12d, 0x4(%rdx)
movl %ebp, 0x8(%rdx)
movl 0x80(%rsp), %eax
movl %eax, 0xc(%rdx)
movl $0x421, (%rdx)          # imm = 0x421
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2420
testl %eax, %eax
jne 0x2db4
movq 0x10(%rsp), %r12
testq %r12, %r12
je 0x2db4
movq 0x18(%r12), %rsi
movl 0x10(%r12), %edx
movq %r15, %rdi
callq 0x2280
movl 0x10(%r12), %eax
movl %eax, (%r14)
movq %r12, %rdi
callq 0x24b0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x623d(%rip), %rcx      # 0x8ff8
movq (%rcx), %r14
testl %eax, %eax
je 0x2dce
movl %eax, %edi
callq 0x2140
movq %rax, %r8
jmp 0x2dd5
leaq 0x35c0(%rip), %r8       # 0x6395
leaq 0x3595(%rip), %rsi      # 0x6371
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2250
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x2da5
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_set_socket_buffer
void shoit_network_set_socket_buffer(int udpSockfd, int sockbufsize, int verbose )
{
    int oldsend = -1, oldrecv = -1;
    int newsend = -1, newrecv = -1;
    socklen_t olen = sizeof(int);

    if(getsockopt(udpSockfd,SOL_SOCKET,SO_SNDBUF,&oldsend,&olen) < 0)
        perror("getsockopt: SO_SNDBUF");

    if(getsockopt(udpSockfd,SOL_SOCKET,SO_RCVBUF,&oldrecv,&olen) < 0)
        perror("getsockopt: SO_RCVBUF");

    if(sockbufsize > 0) {
        if(setsockopt(udpSockfd,SOL_SOCKET,SO_SNDBUF,&sockbufsize,sizeof(sockbufsize)) < 0)
            perror("setsockopt: SO_SNDBUF");
        if(setsockopt(udpSockfd,SOL_SOCKET,SO_RCVBUF,&sockbufsize,sizeof(sockbufsize)) < 0)
            perror("setsockopt: SO_RCVBUF");
        if(getsockopt(udpSockfd,SOL_SOCKET,SO_SNDBUF,&newsend,&olen) < 0)
            perror("getsockopt: SO_SNDBUF");
        if(getsockopt(udpSockfd,SOL_SOCKET,SO_RCVBUF,&newrecv,&olen) < 0)
            perror("getsockopt: SO_RCVBUF");
    }
    if(verbose>1) 
        fprintf(stderr, "UDP sockbufsize was %d/%d now %d/%d (send/recv)\n",oldsend, oldrecv, newsend, newrecv);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %edx, %ebx
movl %esi, %r14d
movl %edi, %ebp
movl %esi, 0x18(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1c(%rsp), %rcx
movl %eax, (%rcx)
movl %eax, 0x14(%rsp)
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
leaq 0x8(%rsp), %r8
movl $0x4, (%r8)
movl $0x1, %esi
movl $0x7, %edx
callq 0x2210
testl %eax, %eax
js 0x2f56
leaq 0x14(%rsp), %rcx
leaq 0x8(%rsp), %r8
movl %ebp, %edi
movl $0x1, %esi
movl $0x8, %edx
callq 0x2210
testl %eax, %eax
js 0x2f67
testl %r14d, %r14d
jle 0x2f48
leaq 0x18(%rsp), %rcx
movl %ebp, %edi
movl $0x1, %esi
movl $0x7, %edx
movl $0x4, %r8d
callq 0x2090
testl %eax, %eax
js 0x2fa4
leaq 0x18(%rsp), %rcx
movl %ebp, %edi
movl $0x1, %esi
movl $0x8, %edx
movl $0x4, %r8d
callq 0x2090
testl %eax, %eax
js 0x2fb5
leaq 0x10(%rsp), %rcx
leaq 0x8(%rsp), %r8
movl %ebp, %edi
movl $0x1, %esi
movl $0x7, %edx
callq 0x2210
testl %eax, %eax
js 0x2fc6
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movl %ebp, %edi
movl $0x1, %esi
movl $0x8, %edx
callq 0x2210
testl %eax, %eax
js 0x2fd7
cmpl $0x2, %ebx
jge 0x2f78
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x3452(%rip), %rdi      # 0x63af
callq 0x2390
jmp 0x2e8e
leaq 0x3457(%rip), %rdi      # 0x63c5
callq 0x2390
jmp 0x2eb1
movq 0x6079(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movl 0x1c(%rsp), %edx
movl 0x14(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
leaq 0x346c(%rip), %rsi      # 0x6407
xorl %eax, %eax
callq 0x2250
jmp 0x2f4d
leaq 0x3430(%rip), %rdi      # 0x63db
callq 0x2390
jmp 0x2ede
leaq 0x3435(%rip), %rdi      # 0x63f1
callq 0x2390
jmp 0x2f02
leaq 0x33e2(%rip), %rdi      # 0x63af
callq 0x2390
jmp 0x2f25
leaq 0x33e7(%rip), %rdi      # 0x63c5
callq 0x2390
jmp 0x2f48
// File: /workspace/github_c_makefile_star2_O3/pencode-lab[P]Shoit/shoit_network.c
// Function: shoit_network_connect_udp
int shoit_network_connect_udp(struct sockaddr_in *udpServerAddr,int localPort,char *remoteHost,int remoteHostPort)
{
    static struct sockaddr_in udpClientAddr;
    struct hostent *phe;
    int udpSockfd;

    // Fill in the structure whith the address of the server that we want to send to
    // udpServerAddr is class global variable, will be used to send data

    bzero(udpServerAddr, sizeof(struct sockaddr_in));
    udpServerAddr->sin_family = AF_INET;

    if ((phe = gethostbyname(remoteHost)))
        memcpy(&udpServerAddr->sin_addr, phe->h_addr, phe->h_length);
    else if ((udpServerAddr->sin_addr.s_addr = inet_addr(remoteHost)) == INADDR_NONE)
    {   
        perror("can't get host entry");
        return -1;
    }
    udpServerAddr->sin_port = htons(remoteHostPort);

    /* Open a UDP socket */
    if ((udpSockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
    {
        perror("socket error");
        return -1;
    }

    // Allow the port to be reused.
    int yes = 1;
    if (setsockopt(udpSockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
        perror("setsockopt");
        close(udpSockfd);
        return -1;
    } 

    /* Bind any local address for us */
    bzero(&udpClientAddr, sizeof(udpClientAddr));
    udpClientAddr.sin_family = AF_INET;
    udpClientAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    udpClientAddr.sin_port = htons(localPort);
    if((bind(udpSockfd, (struct sockaddr *)&udpClientAddr, sizeof(udpClientAddr))) < 0) {
        perror("UDP client bind error");
        close(udpSockfd);
        return -1;
    }

    return udpSockfd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movw $0x2, (%rdi)
movq %rdx, %rdi
callq 0x2240
testq %rax, %rax
je 0x3027
leaq 0x4(%r14), %rdi
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
callq 0x2280
jmp 0x303c
movq %r15, %rdi
callq 0x2220
movl %eax, 0x4(%r14)
cmpl $-0x1, %eax
je 0x30f7
rolw $0x8, %bp
movw %bp, 0x2(%r14)
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x24c0
testl %eax, %eax
js 0x30d0
movl %eax, %ebp
leaq 0x4(%rsp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x2090
cmpl $-0x1, %eax
je 0x30d9
movq $0x0, 0x61f6(%rip) # 0x9284
leaq 0x61e7(%rip), %rsi      # 0x927c
movw $0x2, 0x61de(%rip)      # 0x927c
movl $0x0, 0x61d8(%rip)      # 0x9280
rolw $0x8, %bx
movw %bx, 0x61cb(%rip)       # 0x927e
movl %ebp, %edi
movl $0x10, %edx
callq 0x2330
testl %eax, %eax
js 0x30e2
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3376(%rip), %rdi      # 0x644d
jmp 0x30fe
leaq 0x337a(%rip), %rdi      # 0x645a
jmp 0x30e9
leaq 0x337c(%rip), %rdi      # 0x6465
callq 0x2390
movl %ebp, %edi
callq 0x21b0
jmp 0x3103
leaq 0x333a(%rip), %rdi      # 0x6438
callq 0x2390
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x30c3
// File: /workspace/github_c_makefile_star2_O3/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 0x31e8
movq $0x0, 0x8(%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 0x31f6
movl $0x0, 0xc(%rsp)
movq $0x0, 0x4(%rsp)
movq %r14, %rdi
callq 0x2240
testq %rax, %rax
je 0x31a8
leaq 0x4(%rsp), %rdi
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
callq 0x2280
jmp 0x31b9
movq %r14, %rdi
callq 0x2220
movl %eax, 0x4(%rsp)
cmpl $-0x1, %eax
je 0x3208
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 0x31ff
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x325e(%rip), %rdi      # 0x644d
callq 0x2390
jmp 0x31d9
leaq 0x327e(%rip), %rdi      # 0x647b
jmp 0x320f
leaq 0x32a3(%rip), %rdi      # 0x64a9
jmp 0x320f
leaq 0x327b(%rip), %rdi      # 0x648a
callq 0x2390
movl %ebx, %edi
callq 0x21b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x31d9
// File: /workspace/github_c_makefile_star2_O3/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, 0x6053(%rip)     # 0x928c
movw $0x2, 0x604a(%rip)      # 0x928c
callq 0x2240
testq %rax, %rax
je 0x3265
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
leaq 0x6032(%rip), %rdi      # 0x9290
callq 0x2280
jmp 0x3278
movq %r14, %rdi
callq 0x2220
movl %eax, 0x601d(%rip)      # 0x9290
cmpl $-0x1, %eax
je 0x32e3
rolw $0x8, %bx
movw %bx, 0x600b(%rip)       # 0x928e
xorl %ebx, %ebx
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x24c0
testl %eax, %eax
js 0x32da
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x2170
leaq 0x5fdd(%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 0x316c(%rip), %rdi      # 0x644d
jmp 0x32ea
leaq 0x314e(%rip), %rdi      # 0x6438
callq 0x2390
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x32cf
// File: /workspace/github_c_makefile_star2_O3/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 0x34a3
movq %rsi, %r14
movl %edi, %ebp
movq %rbx, %r15
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2200
testq %rax, %rax
js 0x348f
jne 0x349b
jmp 0x34a3
callq 0x2060
cmpl $0x4, (%rax)
jne 0x34b4
xorl %eax, %eax
addq %rax, %r14
subq %rax, %r15
jg 0x3479
subq %r15, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq $-0x1, %rbx
jmp 0x34a6
// File: /workspace/github_c_makefile_star2_O3/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 0x3507
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 0x34ff
jns 0x350d
callq 0x2060
cmpl $0x4, (%rax)
jne 0x350d
xorl %eax, %eax
addq %rax, %r14
subq %rax, %r15
jg 0x34df
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_O3/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 0x3548
movabsq $0x100002401, %rdx      # imm = 0x100002401
movq %rax, %rcx
movzbl (%rcx), %esi
cmpq $0x20, %rsi
ja 0x3540
btq %rsi, %rdx
jb 0x3545
incq %rcx
jmp 0x3531
movb $0x0, (%rcx)
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x3635
leaq 0x28(%rsp), %r12
leaq 0x18(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
xorl %esi, %esi
callq 0x2170
movq 0x30(%rsp), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
leaq 0x989680(%rcx), %rdx
addq $-0x3b023380, %rcx      # imm = 0xC4FDCC80
xorl %esi, %esi
cmpq $0xf1b30, %rax          # imm = 0xF1B30
setge %sil
cmovlq %rdx, %rcx
addq 0x28(%rsp), %rsi
movq %rsi, 0x18(%rsp)
movq %rcx, 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 0x35b7
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x36fb
movq %rdi, %r15
cmpb $0x0, (%rdi)
je 0x36fb
movq %rdx, %rbx
movq %rsi, %r12
movq %r15, %rdi
movl $0x3a, %esi
callq 0x2100
testq %rax, %rax
je 0x36fb
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 0x36fb
testl %ecx, %ecx
setne %cl
testq %rax, %rax
sete %dl
testb %dl, %cl
jne 0x36fb
cmpq %r14, 0x8(%rsp)
je 0x370a
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 0x36fb
// File: /workspace/github_c_makefile_star2_O3/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 0x37a1
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 0x37e0
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_O3/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 0x3b10
movaps %xmm1, %xmm0
jp 0x3b10
movsd 0x2a10(%rip), %xmm0     # 0x6520
movq %rcx, %xmm2
punpckldq 0x2a13(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x2a1b(%rip), %xmm2     # 0x6540
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
mulsd 0x29ef(%rip), %xmm3     # 0x6528
divsd %xmm0, %xmm3
xorps %xmm0, %xmm0
cvtsd2ss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
shrq $0xa, %rcx
leaq 0x2a90(%rip), %rdx      # 0x65e3
movl $0x1ff, %esi            # imm = 0x1FF
movq %r14, %rdi
movb $0x2, %al
callq 0x2130
leaq 0x2a96(%rip), %rsi      # 0x65ff
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_O3/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
cmpl $0x0, 0x45586(%rip)     # 0x4ad60
je 0x59a0
movq %rdi, %rbx
movzwl (%rdi), %esi
movzwl 0x2(%rdi), %edx
movzwl 0x4(%rdi), %ecx
movzwl 0x6(%rdi), %r8d
movzwl 0x8(%rdi), %r9d
movzwl 0xa(%rdi), %eax
movq %rax, 0x10(%rsp)
movzwl 0xc(%rdi), %eax
movq %rax, 0x8(%rsp)
movzwl 0xe(%rdi), %eax
movq %rax, (%rsp)
movzwl 0x10(%rdi), %eax
movq %rax, 0x30(%rsp)
movzwl 0x12(%rdi), %eax
movq %rax, 0x28(%rsp)
movzwl 0x14(%rdi), %eax
movq %rax, 0x20(%rsp)
movzwl 0x16(%rdi), %eax
movq %rax, 0x18(%rsp)
movzwl 0x18(%rdi), %ebp
movzwl 0x86(%rdi), %eax
shll $0xe, %eax
movzwl 0x88(%rdi), %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 0x3d5d(%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, 0x454aa(%rip)     # 0x4ad60
je 0x59a0
movzwl 0x138(%rbx), %esi
movzwl 0x13a(%rbx), %edx
leaq 0x3da1(%rip), %rdi      # 0x9672
xorl %eax, %eax
callq 0x20a0
cmpl $0x0, 0x45481(%rip)     # 0x4ad60
je 0x59a0
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 0x3d10(%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 0x59a4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x59d4
movl %esi, %eax
shrl $0x2, %eax
andl $0x3, %eax
leaq 0x3788(%rip), %rcx      # 0x914c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x86, %eax
jmp 0x5a07
movw $0x0, 0x84(%rdi)
xorl %ecx, %ecx
jmp 0x5a2c
xorl %eax, %eax
cmpl $0x0, 0x144(%rdi)
jmp 0x59f5
xorl %eax, %eax
cmpl $0x0, 0x140(%rdi)
setne %al
leaq 0x86(,%rax,2), %rax
jmp 0x5a07
movl $0x8a, %eax
movzwl (%rdi,%rax), %eax
movw %ax, 0x84(%rdi)
movzwl 0x138(%rdi), %eax
movl $0x1, %ecx
testb $0x1, %al
jne 0x5a2c
shrl $0x8, %eax
andl %esi, %eax
andl $0x1, %eax
movl %eax, %ecx
movl %ecx, 0x13c(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x6a49
testl %esi, %esi
je 0x6a8c
movb 0x22(%rdi), %al
movb %al, 0x23(%rdi)
testb $0x8, 0x38(%rdi)
jne 0x6abd
movzwl 0x86(%rdi), %eax
movw %ax, 0x84(%rdi)
movzwl 0x138(%rdi), %eax
movl $0x1, %esi
testb $0x1, %al
jne 0x6aea
shrl $0x8, %eax
andl $0x1, %eax
jmp 0x6aef
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 0x6a7b
movb 0x86(%rdi), %al
andb $0x2, %al
shrb %al
movzbl %al, %eax
leal 0x6(,%rax,8), %eax
testl %esi, %esi
je 0x6acf
movl %eax, %eax
movb 0x22(%rdi), %cl
movb %cl, (%rdi,%rax,2)
jmp 0x6b0c
testb $0x8, 0x38(%rdi)
jne 0x6adb
movzwl 0x86(%rdi), %eax
movw %ax, 0x84(%rdi)
movzwl 0x138(%rdi), %ecx
xorl %esi, %esi
movl $0x1, %eax
testb $0x1, %cl
jne 0x6aef
shrl $0x8, %ecx
andl $0x1, %ecx
movl %ecx, %eax
jmp 0x6aef
movw $0x0, 0x84(%rdi)
movl $0x1, %esi
xorl %eax, %eax
jmp 0x6aef
movzwl 0x22(%rdi), %ecx
movl %eax, %eax
movw %cx, (%rdi,%rax,2)
jmp 0x6b0c
movw $0x0, 0x84(%rdi)
xorl %eax, %eax
xorl %esi, %esi
jmp 0x6aef
movl $0x1, %eax
pushq %rax
movl %eax, 0x13c(%rdi)
callq 0x6264
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
leaq 0x8(%rsp), %rsp
je 0x6b0c
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x744f
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 0x742e
xorl %r11d, %r11d
movl $0x6, %ebx
btl %r9d, %ebx
jae 0x7434
movl $0x8000, %r11d          # imm = 0x8000
movl %ecx, %ebx
andl $0x1fc0, %ebx           # imm = 0x1FC0
movl 0xec(%rdi,%rax,4), %ebp
testb $0x8, %r10b
jne 0x746d
cmpl %ebx, %ebp
jl 0x7471
jmp 0x7478
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 0x7537
cmpl %ebx, %ebp
jle 0x7478
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 0x74cd
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 0x7501
movl 0x38(%rdi), %r8d
testb $0x8, %r8b
jne 0x7501
movl %r8d, %r9d
andl $0x40, %r9d
shrl $0x6, %r9d
testl %r9d, %ecx
jne 0x7501
orl $0x200, %r8d            # imm = 0x200
movl %r8d, 0x38(%rdi)
movl $0x1, %eax
retq
testl %esi, %esi
je 0x7537
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 0x7537
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_O3/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 0x75bf
testb $0x2, 0x84(%rdi)
jne 0x75bf
movl 0x38(%rdi), %edx
testb $0x20, %dl
je 0x75bf
movl %ecx, %r8d
andl $-0x2, %r8d
movl %ecx, %esi
notl %esi
testl $0xfffc, %esi           # imm = 0xFFFC
setne %r9b
cmpl $0xff78, %r8d           # imm = 0xFF78
setne %r8b
testb %r8b, %r9b
je 0x7595
movl %ecx, %r8d
andl $0xff00, %r8d           # imm = 0xFF00
movzwl 0x82(%rdi), %r9d
cmpl %r9d, %r8d
jae 0x75f8
orl $0x10, %edx
movw $0x0, 0x84(%rdi)
movl $0x0, 0x13c(%rdi)
andl $0xffffff71, %edx       # imm = 0xFFFFFF71
orl $0x88, %edx
movl %edx, 0x38(%rdi)
movl $0x1, %eax
movl 0x38(%rdi), %edx
testb $0x40, %dl
je 0x75f7
andl $0x1, %ecx
je 0x75f7
testb $0x1, %dl
je 0x75ea
orl $0x108, %edx            # imm = 0x108
movw $0x0, 0x84(%rdi)
movl $0x0, 0x13c(%rdi)
andl $-0x8, %edx
incl %edx
movl %edx, 0x38(%rdi)
movl $0x1, %eax
retq
jne 0x75bf
orl $0x10, %edx
movl %edx, 0x38(%rdi)
testb $-0x20, %sil
jne 0x7598
jmp 0x75bf
// File: /workspace/github_c_makefile_star2_O3/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:
testl %edx, %edx
je 0x762b
movq 0x28(%rdi), %rax
movzwl 0xc(%rax), %eax
testb $0x1, 0x24(%rdi)
jne 0x7643
movzwl %ax, %eax
andl $0xe, %eax
movl %esi, %ecx
movl %eax, 0xac(%rdi,%rcx,4)
jmp 0x7654
movq 0x28(%rdi), %rax
movzwl 0xc(%rax), %eax
movl %eax, %edx
andl $0xe, %edx
movl %esi, %ecx
movl %edx, 0xac(%rdi,%rcx,4)
jmp 0x7645
movl %esi, %ecx
shrl $0x2, %eax
andl $0x1fc0, %eax           # imm = 0x1FC0
movl %eax, 0xec(%rdi,%rcx,4)
andb $-0x41, 0xac(%rdi,%rcx,4)
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x7669
testb $0x1, 0x24(%rdi)
jne 0x7697
movzwl 0x8c(%rdi,%rax,2), %r8d
andl $0xf00, %r8d            # imm = 0xF00
movq 0x28(%rdi), %rsi
movzbl 0xc(%rsi), %ecx
orl %ecx, %r8d
movw %r8w, 0x8c(%rdi,%rax,2)
testl %edx, %edx
je 0x76a3
testb $0x1, 0x24(%rdi)
je 0x76ba
movq 0x28(%rdi), %rsi
movzbl 0x8c(%rdi,%rax,2), %ecx
movzwl 0xc(%rsi), %edx
andl $0xf00, %edx            # imm = 0xF00
movzwl %cx, %ecx
orl %edx, %ecx
movw %cx, 0x8c(%rdi,%rax,2)
andb $-0x41, 0xac(%rdi,%rax,4)
retq
nop
// File: /workspace/github_c_makefile_star2_O3/minkcv[P]vm/main.c
// Function: main
int main (int argc, char** argv)
{
    char* programName = NULL;
    char* romName = NULL;
    int scale = 1;
    int debugMode = 0;
    int i;
    for (i = 1; i < argc; i++)
    {
        if (!strcmp(argv[i], "-f"))
        {
            if (i + 1 < argc)
                programName = argv[i + 1];
        }
        else if (!strcmp(argv[i], "-r"))
        {
            if (i + 1 < argc)
                romName = argv[i + 1];
        }
        else if (!strcmp(argv[i], "-s"))
        {
            if (i + 1 < argc)
                scale = atoi(argv[i + 1]);
        }
        else if (!strcmp(argv[i], "-d"))
            debugMode = 1;
    }
    if (programName == NULL)
    {
        printf("Usage: main -f program.vaporbin\n");
        exit(1);
    }

    Display* display = createDisplay(SCREEN_WIDTH, SCREEN_HEIGHT, scale, SCREEN_WIDTH / 4);
    uint8_t* rom = NULL;
    uint16_t* code = readBinary(programName, 0, &rom);
    if (romName != NULL) // ROM is optional
        rom = readRom(romName, 0);

    VM* vm = createVM(code, rom, display, debugMode);
    run(vm);
    destroyVM(vm);
    free(code);
    if (rom != NULL)
        free(rom);
    code = NULL;
    rom = NULL;
    quitDisplay(display);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0x2, %edi
jl 0x1464
movq %rsi, %r12
movl %edi, %r13d
movl $0x1, %esi
xorl %r15d, %r15d
movl $0x1, %eax
movq $0x0, -0x30(%rbp)
xorl %ebx, %ebx
movl $0x1, %edx
movq (%r12,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0x1372
cmpb $0x66, 0x1(%rcx)
jne 0x134d
cmpb $0x0, 0x2(%rcx)
je 0x1382
cmpb $0x72, 0x1(%rcx)
jne 0x1359
cmpb $0x0, 0x2(%rcx)
je 0x1392
cmpb $0x73, 0x1(%rcx)
jne 0x1365
cmpb $0x0, 0x2(%rcx)
je 0x13a6
cmpb $0x64, 0x1(%rcx)
jne 0x1372
cmpb $0x0, 0x2(%rcx)
cmovel %esi, %ebx
incq %rax
movq %rax, %r14
movq %r14, %rax
cmpq %r13, %r14
jne 0x1338
jmp 0x13c2
leaq 0x1(%rax), %r14
cmpq %r13, %r14
jge 0x1378
movq 0x8(%r12,%rax,8), %r15
jmp 0x1378
leaq 0x1(%rax), %r14
cmpq %r13, %r14
jge 0x1378
movq 0x8(%r12,%rax,8), %rax
movq %rax, -0x30(%rbp)
jmp 0x1378
leaq 0x1(%rax), %r14
cmpq %r13, %r14
jge 0x1378
movq 0x8(%r12,%rax,8), %rdi
callq 0x11e0
movl $0x1, %esi
movl %eax, %edx
jmp 0x1378
testq %r15, %r15
je 0x1464
movl $0x100, %edi            # imm = 0x100
movl $0xc0, %esi
movl $0x40, %ecx
callq 0x1b30
movq %rax, %r12
leaq -0x38(%rbp), %rdx
movq $0x0, (%rdx)
movq %r15, %rdi
xorl %esi, %esi
callq 0x147a
movq %rax, %r15
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x140f
xorl %esi, %esi
callq 0x161e
movq %rax, %r14
jmp 0x1413
movq -0x38(%rbp), %r14
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x16f4
movq %rax, %rbx
movq %rax, %rdi
callq 0x17cf
movq %rbx, %rdi
callq 0x1795
movq %r15, %rdi
callq 0x1170
testq %r14, %r14
je 0x144b
movq %r14, %rdi
callq 0x1170
movq %r12, %rdi
callq 0x1c75
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c19(%rip), %rdi      # 0x3084
callq 0x11d0
movl $0x1, %edi
callq 0x1180