LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/fe.c
// Function: praddr
void
praddr(int mode, Addr a)
{
	switch(mode){
	case MODE_SYM:
		typestr(symaddr(a));
		break;

	default:
		typenum(a);
	}
}

// Assembly:
cmpl $0x2, %edi
jne 0x2c9e
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movzwl %si, %edi
callq 0x2bc6
movb 0xa7c5(%rip), %al       # 0xd440
testb %al, %al
je 0x2c97
leaq 0xa7bb(%rip), %rbx      # 0xd441
movsbl %al, %edi
callq 0x26ee
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0x2c86
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movzwl %si, %edi
jmp 0x276a
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/fe.c
// Function: aclose
void
aclose(int ins)
{
	// this is a bit ugly...
	// we don't want ^M to set Q if no location is open
	Word t;
	t = q;
	if(endword(&q) && ins){
		if(opened)
			deposit(addr, q);
		else if(regopened)
			depositreg(addr, q);
	}
	addr = q & ADDRMASK;
	if(!opened && !regopened)
		q = t;
	opened = 0;
	regopened = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
movl 0xa773(%rip), %r14d     # 0xd4a4
leaq 0xa76c(%rip), %rdi      # 0xd4a4
callq 0x2b2e
testl %ebx, %ebx
je 0x2d7d
testl %eax, %eax
je 0x2d7d
cmpl $0x0, 0xa760(%rip)      # 0xd4ac
je 0x2d62
movzwl 0xa75b(%rip), %edi      # 0xd4b0
movl 0xa749(%rip), %esi      # 0xd4a4
callq 0x417c
jmp 0x2d7d
cmpl $0x0, 0xa74b(%rip)      # 0xd4b4
je 0x2d7d
movzwl 0xa73e(%rip), %edi      # 0xd4b0
movl 0xa72c(%rip), %esi      # 0xd4a4
callq 0x41a2
movzwl 0xa720(%rip), %eax      # 0xd4a4
movw %ax, 0xa725(%rip)       # 0xd4b0
movl 0xa723(%rip), %eax      # 0xd4b4
orl 0xa715(%rip), %eax      # 0xd4ac
jne 0x2da0
movl %r14d, 0xa704(%rip)     # 0xd4a4
xorl %eax, %eax
movl %eax, 0xa704(%rip)      # 0xd4ac
movl %eax, 0xa706(%rip)      # 0xd4b4
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/fe.c
// Function: aopen
void
aopen(int mode)
{
	opened = 1;
	q = examine(addr);
	typestr("   ");
	if(mode != MODE_NONE)
		typeout(mode);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x1, 0xa6e3(%rip)      # 0xd4ac
movzwl 0xa6e0(%rip), %edi      # 0xd4b0
callq 0x418f
movl %eax, 0xa6c9(%rip)      # 0xd4a4
movb $0x20, %al
movl $0x1, %r14d
leaq 0x238e(%rip), %r15      # 0x5178
movsbl %al, %edi
callq 0x26ee
movb (%r14,%r15), %al
incq %r14
cmpq $0x4, %r14
jne 0x2dea
testl %ebx, %ebx
je 0x2e14
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2ca6
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/fe.c
// Function: aropen
void
aropen(int mode)
{
	regopened = 1;
	q = examinereg(addr);
	typestr("   ");
	if(mode != MODE_NONE)
		typeout(mode);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x1, 0xa67f(%rip)      # 0xd4b4
movzwl 0xa674(%rip), %edi      # 0xd4b0
callq 0x41db
movl %eax, 0xa65d(%rip)      # 0xd4a4
movb $0x20, %al
movl $0x1, %r14d
leaq 0x2322(%rip), %r15      # 0x5178
movsbl %al, %edi
callq 0x26ee
movb (%r14,%r15), %al
incq %r14
cmpq $0x4, %r14
jne 0x2e56
testl %ebx, %ebx
je 0x2e80
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2ca6
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/util.c
// Function: serve1
int
serve1(int port)
{
	int sockfd, confd;
	socklen_t len;
	struct sockaddr_in server, client;
	int x;

	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	if(sockfd < 0){
		perror("error: socket");
		return -1;
	}

	x = 1;
	setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, (void *)&x, sizeof x);
	
	memset(&server, 0, sizeof(server));
	server.sin_family = AF_INET;
	server.sin_addr.s_addr = INADDR_ANY;
	server.sin_port = htons(port);
	if(bind(sockfd, (struct sockaddr*)&server, sizeof(server)) < 0){
		perror("error: bind");
		return -1;
	}
	listen(sockfd, 5);
	len = sizeof(client);
	while(confd = accept(sockfd, (struct sockaddr*)&client, &len),
	      confd >= 0)
		return confd;
	perror("error: accept");
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movl %edi, %r14d
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2400
testl %eax, %eax
js 0x39e2
movl %eax, %ebx
leaq -0x14(%rbp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x20c0
leaq -0x38(%rbp), %rsi
movq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
movl $0x0, 0x4(%rsi)
rolw $0x8, %r14w
movw %r14w, 0x2(%rsi)
movl %ebx, %edi
movl $0x10, %edx
callq 0x2260
testl %eax, %eax
js 0x39eb
movl %ebx, %edi
movl $0x5, %esi
callq 0x2220
leaq -0x18(%rbp), %rdx
movl $0x10, (%rdx)
leaq -0x28(%rbp), %rsi
movl %ebx, %edi
callq 0x2310
testl %eax, %eax
js 0x39f4
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x17be(%rip), %rdi      # 0x51a7
jmp 0x39fb
leaq 0x17c3(%rip), %rdi      # 0x51b5
jmp 0x39fb
leaq 0x17c6(%rip), %rdi      # 0x51c1
callq 0x22f0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x39d9
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: lock
void
lock(Lock *lk)
{
	if(!lk->init)
		lockinit(lk);
	if(pthread_mutex_lock(&lk->mutex) != 0)
		abort();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, (%rdi)
jne 0x3a4a
movq %rbx, %rdi
callq 0x3a66
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x23b0
testl %eax, %eax
jne 0x3a61
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: lockinit
static void
lockinit(Lock *lk)
{
	pthread_mutexattr_t attr;

	pthread_mutex_lock(&initmutex);
	if(lk->init == 0){
		pthread_mutexattr_init(&attr);
		pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
		pthread_mutex_init(&lk->mutex, &attr);
		pthread_mutexattr_destroy(&attr);
		lk->init = 1;
	}
	pthread_mutex_unlock(&initmutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x9afd(%rip), %rdi      # 0xd578
callq 0x23b0
cmpl $0x0, (%rbx)
jne 0x3ab5
leaq -0x14(%rbp), %r14
movq %r14, %rdi
callq 0x2350
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
leaq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x2390
movq %r14, %rdi
callq 0x23a0
movl $0x1, (%rbx)
leaq 0x9abc(%rip), %rdi      # 0xd578
callq 0x21f0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: canlock
int
canlock(Lock *lk)
{
	int r;

	if(!lk->init)
		lockinit(lk);
	r = pthread_mutex_trylock(&lk->mutex);
	if(r == 0)
		return 1;
	if(r == EBUSY)
		return 0;
	abort();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, (%rdi)
jne 0x3ae0
movq %rbx, %rdi
callq 0x3a66
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x2170
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
je 0x3afe
cmpl $0x10, %ecx
jne 0x3b05
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: rsleep
void
rsleep(Rendez *r)
{
	if(!r->init)
		rendinit(r);
	if(pthread_cond_wait(&r->cond, &r->l->mutex) != 0)
		abort();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x0, (%rdi)
jne 0x3b78
leaq 0x9a3c(%rip), %rdi      # 0xd578
callq 0x23b0
cmpl $0x0, (%rbx)
jne 0x3b6c
leaq -0x14(%rbp), %r14
movq %r14, %rdi
callq 0x2250
leaq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x21e0
movq %r14, %rdi
callq 0x2140
movl $0x1, (%rbx)
leaq 0x9a05(%rip), %rdi      # 0xd578
callq 0x21f0
movq 0x8(%rbx), %rsi
addq $0x10, %rbx
addq $0x8, %rsi
movq %rbx, %rdi
callq 0x20e0
testl %eax, %eax
jne 0x3b99
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: threadcreate
int
threadcreate(void *(*f)(void*), void *arg)
{
	struct ThreadArg *args;
	int id;

	lock(&idlock);
	id = addthreadid();
	args = malloc(sizeof(*args));
	args->id = id;
	args->f = f;
	args->arg = arg;
	pthread_create(&threads[id], nil, trampoline, args);
	unlock(&idlock);
	return id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
leaq 0x9949(%rip), %rdi      # 0xd538
callq 0x3a34
callq 0x3c50
movl %eax, %ebx
movl $0x18, %edi
callq 0x2210
movl %ebx, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movslq %ebx, %rdi
shlq $0x3, %rdi
addq 0x994b(%rip), %rdi      # 0xd568
leaq 0x86(%rip), %rdx        # 0x3caa
xorl %esi, %esi
movq %rax, %rcx
callq 0x2270
leaq 0x990b(%rip), %rdi      # 0xd540
callq 0x21f0
testl %eax, %eax
jne 0x3c4b
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: addthreadid
static int
addthreadid(void)
{
	int id;

	if(numthreads >= maxthreads){
		maxthreads += 64;
		threads = realloc(threads, maxthreads*sizeof(*threads));
	}
	id = numthreads++;
	threads[id] = 0;
	return id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movslq 0x9913(%rip), %rbx      # 0xd570
movslq 0x993c(%rip), %rcx      # 0xd5a0
movq 0x98fd(%rip), %rax      # 0xd568
cmpl %ecx, %ebx
jl 0x3c90
leaq 0x40(%rcx), %rdx
movl %edx, 0x9927(%rip)      # 0xd5a0
leaq 0x200(,%rcx,8), %rsi
movq %rax, %rdi
callq 0x2230
movq %rax, 0x98d8(%rip)      # 0xd568
leal 0x1(%rbx), %ecx
movl %ecx, 0x98d7(%rip)      # 0xd570
movq $0x0, (%rax,%rbx,8)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: gethandle
static pthread_t
gethandle(int id)
{
	pthread_t th;
	lock(&idlock);
	th = threads[id];
	unlock(&idlock);
	return th;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x97eb(%rip), %rdi      # 0xd538
callq 0x3a34
movq 0x980f(%rip), %rax      # 0xd568
movslq %ebx, %rcx
movq (%rax,%rcx,8), %rbx
leaq 0x97d9(%rip), %rdi      # 0xd540
callq 0x21f0
testl %eax, %eax
jne 0x3d7a
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: chanclose
void
chanclose(Channel *c)
{
	lock(&c->lock);
	c->closed = 1;
	rwakeupall(&c->full);
	rwakeupall(&c->empty);
	unlock(&c->lock);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
addq $0x20, %rdi
callq 0x3a34
movl $0x1, 0x18(%rbx)
leaq 0x50(%rbx), %rdi
callq 0x3bbb
leaq 0x90(%rbx), %rdi
callq 0x3bbb
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
testl %eax, %eax
jne 0x3e85
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: chansend
int
chansend(Channel *c, void *p)
{
	lock(&c->lock);
	while(!(c->closed || cansend(c)))
		rsleep(&c->full);
	/* closed or can send */
	if(c->closed){
		/* can never send to closed chan */
		unlock(&c->lock);
		return -1;
	}
	chansend_(c, p);
	rwakeup(&c->empty);
	unlock(&c->lock);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
addq $0x20, %rdi
callq 0x3a34
cmpl $0x0, 0x18(%rbx)
jne 0x3ecc
leaq 0x50(%rbx), %r15
movl 0x10(%rbx), %eax
cmpl (%rbx), %eax
jl 0x3eee
movq %r15, %rdi
callq 0x3b22
cmpl $0x0, 0x18(%rbx)
je 0x3eb7
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x3f1a
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f1f
leaq 0x90(%rbx), %rdi
callq 0x3b9e
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0x1, %eax
jmp 0x3edf
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: chansend_
static void
chansend_(Channel *c, void *p)
{
	uchar *pp;

	assert(cansend(c));
	pp = c->buf + (c->off+c->nbuf)%c->bufsize * c->elemsize;
	memmove(pp, p, c->elemsize);
	c->nbuf++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl (%rdi), %ecx
movl 0x10(%rdi), %eax
cmpl %ecx, %eax
jge 0x3f58
movq %rdi, %rbx
addl 0x14(%rdi), %eax
cltd
idivl %ecx
movslq 0x4(%rdi), %rax
movslq %edx, %rdi
imulq %rax, %rdi
addq 0x8(%rbx), %rdi
movq %rax, %rdx
callq 0x2290
incl 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x12b3(%rip), %rdi      # 0x5212
leaq 0x1284(%rip), %rsi      # 0x51ea
leaq 0x12b0(%rip), %rcx      # 0x521d
movl $0x10e, %edx            # imm = 0x10E
callq 0x2120
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: chanrecv
int
chanrecv(Channel *c, void *p)
{
	lock(&c->lock);
	while(!(c->closed || canrecv(c)))
		rsleep(&c->empty);
	/* closed or can receive */
	if(canrecv(c)){
		/* can still receive from closed chan */
		chanrecv_(c, p);
		rwakeup(&c->full);
		unlock(&c->lock);
		return 1;
	}
	unlock(&c->lock);
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
addq $0x20, %rdi
callq 0x3a34
cmpl $0x0, 0x18(%rbx)
jne 0x3fb1
leaq 0x90(%rbx), %r15
cmpl $0x0, 0x10(%rbx)
jg 0x3fb7
movq %r15, %rdi
callq 0x3b22
cmpl $0x0, 0x18(%rbx)
je 0x3f9d
cmpl $0x0, 0x10(%rbx)
jle 0x3fe0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4007
leaq 0x50(%rbx), %rdi
callq 0x3b9e
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0x1, %eax
jmp 0x3ff3
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4002
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: chanrecv_
static void
chanrecv_(Channel *c, void *p)
{
	uchar *pp;

	assert(canrecv(c));
	pp = c->buf + c->off*c->elemsize;
	memmove(p, pp, c->elemsize);
	c->nbuf--;
	if(++c->off == c->bufsize)
		c->off = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl $0x0, 0x10(%rdi)
jle 0x404a
movq %rdi, %rbx
movslq 0x14(%rdi), %rax
movslq 0x4(%rdi), %rdx
imulq %rdx, %rax
addq 0x8(%rdi), %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2290
decl 0x10(%rbx)
movl 0x14(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl (%rbx), %eax
cmovnel %eax, %ecx
movl %ecx, 0x14(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x11ee(%rip), %rdi      # 0x523f
leaq 0x1192(%rip), %rsi      # 0x51ea
leaq 0x11eb(%rip), %rcx      # 0x524a
movl $0x119, %edx            # imm = 0x119
callq 0x2120
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: channbsend
int
channbsend(Channel *c, void *p)
{
	lock(&c->lock);
	if(c->closed){
		/* can never send to closed chan */
		unlock(&c->lock);
		return -1;
	}
	if(cansend(c)){
		chansend_(c, p);
		rwakeup(&c->empty);
		unlock(&c->lock);
		return 1;
	}
	unlock(&c->lock);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
addq $0x20, %rdi
callq 0x3a34
cmpl $0x0, 0x18(%rbx)
je 0x409a
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x40dd
movl 0x10(%rbx), %eax
cmpl (%rbx), %eax
jge 0x40cd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f1f
leaq 0x90(%rbx), %rdi
callq 0x3b9e
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0x1, %eax
jmp 0x40dd
addq $0x28, %rbx
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x40e6
popq %rbx
popq %r14
popq %rbp
retq
callq 0x2070
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/common/threading.c
// Function: channbrecv
int
channbrecv(Channel *c, void *p)
{
	lock(&c->lock);
	if(canrecv(c)){
		/* can still receive from closed chan */
		chanrecv_(c, p);
		rwakeup(&c->full);
		unlock(&c->lock);
		return 1;
	}
	if(c->closed){
		unlock(&c->lock);
		return -1;
	}
	unlock(&c->lock);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
addq $0x20, %rdi
callq 0x3a34
leaq 0x28(%r14), %rbx
cmpl $0x0, 0x10(%r14)
jle 0x4137
movq %r14, %rdi
movq %r15, %rsi
callq 0x4007
addq $0x50, %r14
movq %r14, %rdi
callq 0x3b9e
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
movl $0x1, %eax
jmp 0x4153
movl 0x18(%r14), %r14d
movq %rbx, %rdi
callq 0x21f0
movl %eax, %ecx
testl %r14d, %r14d
je 0x4151
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4153
xorl %eax, %eax
testl %ecx, %ecx
jne 0x4162
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x2070
nop
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: depositreg
void
depositreg(int a, Word w)
{
	switch(a){
	case REG_PC: tx0.pc = w & ADDRMASK; break;
	case REG_AC: tx0.ac = w & WORDMASK; break;
	case REG_LR: tx0.lr = w & WORDMASK; break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x2, %edi
je 0x41cd
cmpl $0x1, %edi
je 0x41bf
testl %edi, %edi
jne 0x41d9
movzwl %si, %eax
movl %eax, 0x9413(%rip)      # 0xd5d0
jmp 0x41d9
andl $0x3ffff, %esi          # imm = 0x3FFFF
movl %esi, 0x93f5(%rip)      # 0xd5c0
jmp 0x41d9
andl $0x3ffff, %esi          # imm = 0x3FFFF
movl %esi, 0x93eb(%rip)      # 0xd5c4
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: examinereg
Word
examinereg(int a)
{
	switch(a){
	case REG_PC: return tx0.pc;
	case REG_AC: return tx0.ac;
	case REG_LR: return tx0.lr;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x2, %edi
je 0x41ff
cmpl $0x1, %edi
je 0x41f7
xorl %eax, %eax
testl %edi, %edi
jne 0x4205
movl 0x93db(%rip), %eax      # 0xd5d0
jmp 0x4205
movl 0x93c3(%rip), %eax      # 0xd5c0
jmp 0x4205
movl 0x93bf(%rip), %eax      # 0xd5c4
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: disasm
char*
disasm(Word w)
{
	static char s[100];
	char *p;
	int op, x;
	char *opstr, *sym;;

	op = w>>16 & 3;
	x = w & ADDRMASK;
	p = s;
	memset(s, 0, 100);
	switch(op){
	case 00: opstr = "sto"; goto symop;
	case 01: opstr = "add"; goto symop;
	case 02: opstr = "trn"; goto symop;
	case 03: opstr = "opr";
		for(op = 0; oprgroup[op].sym; op++)
			if(oprgroup[op].value == w){
				p += sprintf(p, "%s", oprgroup[op].sym);
				return s;
			}
		p += sprintf(p, "%s %o", opstr, x);
		break;

	symop:
		p += sprintf(p, "%s ", opstr);
		sym = x == 0 ? nil : findsym(x);
		if(sym)
			p += sprintf(p, "%s", sym);
		else
			p += sprintf(p, "%o", x);
		break;
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %eax
shrl $0x10, %eax
andl $0x3, %eax
movzwl %di, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, 0x4943a(%rip)    # 0x4d660
movaps %xmm0, 0x49423(%rip)    # 0x4d650
movaps %xmm0, 0x4940c(%rip)    # 0x4d640
movaps %xmm0, 0x493f5(%rip)    # 0x4d630
movaps %xmm0, 0x493de(%rip)    # 0x4d620
movaps %xmm0, 0x493c7(%rip)    # 0x4d610
movl $0x0, 0x4941d(%rip)     # 0x4d670
leaq 0x1012(%rip), %rcx      # 0x526c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1022(%rip), %rdx      # 0x528c
jmp 0x4290
leaq 0x1021(%rip), %rdx      # 0x5294
jmp 0x4290
cmpl $0x38000, %edi          # imm = 0x38000
jne 0x42f0
leaq 0x104f(%rip), %rsi      # 0x52d3
jmp 0x4316
leaq 0x1000(%rip), %rdx      # 0x5290
leaq 0x49379(%rip), %r15     # 0x4d610
leaq 0x1004(%rip), %rsi      # 0x52a2
movq %r15, %rdi
xorl %eax, %eax
callq 0x2320
movslq %eax, %r14
addq %r15, %r14
testl %ebx, %ebx
je 0x42cb
movl %ebx, %edi
callq 0x298d
testq %rax, %rax
je 0x42cb
movq %r14, %rdi
movq %rax, %rsi
callq 0x2090
jmp 0x42de
leaq 0xfcd(%rip), %rsi       # 0x529f
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2320
leaq 0x4932b(%rip), %rax     # 0x4d610
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x18, %ecx
leaq 0x3844(%rip), %rax      # 0x7b40
leaq 0x10(%rcx), %rdx
cmpq $0x2b8, %rdx            # imm = 0x2B8
je 0x432c
cmpl %edi, (%rcx,%rax)
movq %rdx, %rcx
jne 0x42fc
movq -0x18(%rdx,%rax), %rsi
leaq 0x492f3(%rip), %rdi     # 0x4d610
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2090
leaq 0x492dd(%rip), %rdi     # 0x4d610
leaq 0xf62(%rip), %rsi       # 0x529c
leaq 0xf57(%rip), %rdx       # 0x5298
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2320
jmp 0x42de
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: handleio
void
handleio(TX0 *tx)
{
	int c;

	if(tx->fl->dly == 0){
		if(hasinput(tx->fl->in)){
			c = getfl(tx->fl);
			tx->lr = 0400000;
	// this is correct:
			tx->lr |= (c&077) << 11;
	// this is not:
	//if(c & 001) tx->lr |= 0000001;
	//if(c & 002) tx->lr |= 0000010;
	//if(c & 004) tx->lr |= 0000100;
	//if(c & 010) tx->lr |= 0001000;
	//if(c & 020) tx->lr |= 0010000;
	//if(c & 040) tx->lr |= 0100000;
		}
		// don't wanna poll this all the time
		// around 16cps max
		tx->fl->dly = 10000;
	}else
		tx->fl->dly--;
	if(tx->fl_printing){
		c = 0;
		if(tx->ac & 0000001) c |= 1;
		if(tx->ac & 0000010) c |= 2;
		if(tx->ac & 0000100) c |= 4;
		if(tx->ac & 0001000) c |= 010;
		if(tx->ac & 0010000) c |= 020;
		if(tx->ac & 0100000) c |= 040;
		putfl(tx->fl, c);
		tx->fl_printing = 0;
		iorestart(tx);
	}
	if(tx->displaying){
		if(tx->scope_fd >= 0){
			u32 cmd = 0;
			int x = (tx->ac>>9)&0777;
			int y = tx->ac&0777;
			// Convert [-1.0,+1.0] to [0,1023]
			if(x & 0400) x++;
			if(y & 0400) y++;
			x += 0400;
			y += 0400;
			x &= 0777;
			y &= 0777;
			x <<= 1;
			y <<= 1;
			cmd = x;
			cmd |= y<<10;
			cmd |= 7<<20;
			write(tx->scope_fd, &cmd, 4);
//	usleep(1000);
		}
		tx->displaying = 0;
		iorestart(tx);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x40040(%rdi), %rax
movl 0x8(%rax), %ecx
testl %ecx, %ecx
je 0x43d1
decl %ecx
movl %ecx, 0x8(%rax)
jmp 0x4404
movl (%rax), %edi
callq 0x363b
testl %eax, %eax
je 0x43f6
movq 0x40040(%rbx), %rdi
callq 0x4375
andl $0x3f, %eax
shll $0xb, %eax
orl $0x20000, %eax          # imm = 0x20000
movl %eax, 0x14(%rbx)
movq 0x40040(%rbx), %rax
movl $0x2710, 0x8(%rax)      # imm = 0x2710
cmpl $0x0, 0x40048(%rbx)
je 0x4469
movl 0x10(%rbx), %ecx
movl %ecx, %edx
andl $0x1, %edx
movl %ecx, %esi
shrl $0x2, %esi
andl $0x2, %esi
orl %edx, %esi
movl %ecx, %edx
shrl $0x4, %edx
andl $0x4, %edx
orl %esi, %edx
movl %ecx, %esi
shrl $0x6, %esi
andl $0x8, %esi
orl %edx, %esi
movl %ecx, %edx
shrl $0x8, %edx
andl $0x10, %edx
orl %esi, %edx
shrl $0xa, %ecx
andl $0x20, %ecx
orl %edx, %ecx
leaq -0x9(%rbp), %rsi
movb %cl, (%rsi)
movl 0x4(%rax), %edi
movl $0x1, %edx
callq 0x20d0
movl $0x0, 0x40048(%rbx)
movl $0x1, 0x4(%rbx)
cmpl $0x0, 0x4004c(%rbx)
je 0x44c9
movl 0x40050(%rbx), %edi
testl %edi, %edi
js 0x44b8
movl 0x10(%rbx), %eax
movl %eax, %ecx
shrl $0x9, %ecx
btl $0x11, %eax
adcl $0x0, %ecx
btl $0x8, %eax
adcl $0x0, %eax
andl $0x1ff, %ecx            # imm = 0x1FF
shll $0xb, %eax
andl $0xff800, %eax          # imm = 0xFF800
leal (%rax,%rcx,2), %eax
xorl $0x780200, %eax         # imm = 0x780200
leaq -0x10(%rbp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
callq 0x20d0
movl $0x0, 0x4004c(%rbx)
movl $0x1, 0x4(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: handlemsg
void
handlemsg(TX0 *tx, Msg msg)
{
	switch(msg.cmd){
	case CMD_NONE:
		break;
	case CMD_SET_PC:
		tx->mar = tx->pc = msg.arg & ADDRMASK;
		break;
	case CMD_STEP:
		tx->sw_stop_c0 = 1;
		tx->sw_stop_c1 = 1;
		tx->pbs = 1;
		break;
	case CMD_RUN:
		tx->sw_stop_c0 = 0;
		tx->sw_stop_c1 = 0;
		tx->pbs = 1;
		break;
	case CMD_STOP:
		tx->pbs = 0;
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leal -0x1(%rsi), %eax
cmpl $0x3, %eax
ja 0x4529
leaq 0xd99(%rip), %rcx       # 0x527c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrq $0x20, %rsi
movzwl %si, %eax
movl %eax, 0x20(%rdi)
movl %eax, 0x1c(%rdi)
jmp 0x4529
movq $0x0, 0x40034(%rdi)
jmp 0x4522
movl $0x0, 0x8(%rdi)
jmp 0x4529
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x40034(%rdi)
movl $0x1, 0x8(%rdi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: readmem
void
readmem(TX0 *tx, FILE *f)
{
	char buf[100], *s;
	Word a, w;

	a = 0;
	while(s = fgets(buf, 100, f)){
		while(*s){
			if(*s == ';')
				break;
			else if('0' <= *s && *s <= '7'){
				w = strtol(s, &s, 8);
				if(*s == ':'){
					a = w;
					s++;
				}else if(a < MAXMEM)
					tx->core[a++] = w & 0777777;
			}else
				s++;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq -0xa0(%rbp), %rdi
movl $0x64, %esi
movq %rbx, %rdx
callq 0x2190
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x48b0
xorl %r13d, %r13d
leaq -0xa0(%rbp), %r15
leaq -0x30(%rbp), %r12
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x4840
cmpl $0x3b, %ecx
jne 0x485b
movq %r15, %rdi
movl $0x64, %esi
movq %rbx, %rdx
callq 0x2190
movq %rax, -0x30(%rbp)
testq %rax, %rax
jne 0x4834
jmp 0x48b0
andb $-0x8, %cl
cmpb $0x30, %cl
jne 0x489b
movq %rax, %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x21c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpb $0x3a, (%rax)
je 0x48a4
cmpl $0xffff, %r13d          # imm = 0xFFFF
ja 0x4834
andl $0x3ffff, %ecx          # imm = 0x3FFFF
movl %r13d, %edx
incl %r13d
movl %ecx, 0x2c(%r14,%rdx,4)
jmp 0x4834
incq %rax
movq %rax, -0x30(%rbp)
jmp 0x4834
incq %rax
movq %rax, -0x30(%rbp)
movl %ecx, %r13d
jmp 0x4834
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: readsyms
void
readsyms(FILE *f)
{
	char buf[100], *s;
	Word w;

	while(s = fgets(buf, 100, f)){
		while(isspace(*s)) s++;
		while(!isspace(*s)) s++;
		*s++ = '\0';
		w = strtol(s, &s, 8);
		defsym(buf, w);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq -0xa0(%rbp), %rdi
movl $0x64, %esi
movq %rbx, %rdx
callq 0x2190
testq %rax, %rax
je 0x4965
movq %rax, %r13
callq 0x23d0
movq %rax, %r14
leaq -0x30(%rbp), %r15
leaq -0xa0(%rbp), %r12
movq (%r14), %rax
decq %r13
movsbq 0x1(%r13), %rcx
incq %r13
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x4908
movsbq (%r13), %rcx
incq %r13
testb $0x20, 0x1(%rax,%rcx,2)
je 0x4917
movq %r13, -0x30(%rbp)
movb $0x0, -0x1(%r13)
movq %r13, %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x21c0
movq %r12, %rdi
movl %eax, %esi
callq 0x2922
movq %r12, %rdi
movl $0x64, %esi
movq %rbx, %rdx
callq 0x2190
movq %rax, %r13
movq %rax, -0x30(%rbp)
testq %rax, %rax
jne 0x4902
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: cpu_start
void
cpu_start(Addr a)
{
	Msg msg;
	msg.cmd = CMD_SET_PC;
	msg.arg = a;
	chansend(cmdchan, &msg);
	msg.cmd = CMD_RUN;
	chansend(cmdchan, &msg);
	dly();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq -0x10(%rbp), %rbx
movl $0x1, (%rbx)
movl %edi, 0x4(%rbx)
movq 0x48cea(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
movl $0x3, (%rbx)
movq 0x48cd5(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
callq 0x49b7
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: dly
static void
dly(void)
{
	// force a few cycles to happen
	chansend(cmdchan, &msg_none);
	chansend(cmdchan, &msg_none);
	chansend(cmdchan, &msg_none);
	chansend(cmdchan, &msg_none);
	chansend(cmdchan, &msg_none);
	chansend(cmdchan, &msg_none);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq 0x48cb4(%rip), %rdi     # 0x4d678
leaq 0x48cc1(%rip), %rbx     # 0x4d68c
movq %rbx, %rsi
callq 0x3e94
movq 0x48c9e(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
movq 0x48c8f(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
movq 0x48c80(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
movq 0x48c71(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
movq 0x48c62(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x3e94
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: cpu_nextinst
void
cpu_nextinst(void)
{
	Msg msg;
	msg.cmd = CMD_STEP;
	chansend(cmdchan, &msg);
	dly();
	while(tx0.c){
		chansend(cmdchan, &msg);
		dly();
	}
	// make sure we see the correct PC
	tx0.pc = tx0.mar;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq -0x10(%rbp), %rsi
movl $0x2, (%rsi)
movq 0x48bdb(%rip), %rdi     # 0x4d678
callq 0x3e94
callq 0x49b7
cmpl $0x0, 0x8b0e(%rip)      # 0xd5bc
je 0x4ad1
leaq -0x10(%rbp), %rbx
movq 0x48bbd(%rip), %rdi     # 0x4d678
movq %rbx, %rsi
callq 0x3e94
callq 0x49b7
cmpl $0x0, 0x8aed(%rip)      # 0xd5bc
jne 0x4ab4
movl 0x8af5(%rip), %eax      # 0xd5cc
movl %eax, 0x8af3(%rip)      # 0xd5d0
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/tx0/mach.c
// Function: initmach
void
initmach(void)
{
	memset(&fl, 0, sizeof(fl));
	fl.in = open("/tmp/fl", O_RDWR);
	if(fl.in < 0)
		panic("can't open /tmp/fl");
	fl.out = fl.in;

	memset(&tx0, 0, sizeof(tx0));
	tx0.pbs = 0;
	tx0.ios = 1;
	tx0.fl = &fl;
	tx0.mar = tx0.pc = 040;

	FILE *mf;
	mf = mustopen("out.mem", "r");
	if(mf){
		readmem(&tx0, mf);
		fclose(mf);
	}
	mf = fopen("out.sym", "r");
	if(mf){
		readsyms(mf);
		fclose(mf);
	}

	tx0.scope_fd = dial("localhost", 3400);

	cmdchan = chancreate(sizeof(Msg), 1);
	threadcreate(simthread, &tx0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0x0, 0x48b8e(%rip)     # 0x4d688
movq $0x0, 0x48b7b(%rip) # 0x4d680
leaq 0x7a5(%rip), %rdi       # 0x52b1
movl $0x2, %esi
xorl %eax, %eax
callq 0x22d0
movl %eax, 0x48b62(%rip)     # 0x4d680
testl %eax, %eax
jns 0x4b36
leaq 0x77d(%rip), %rdi       # 0x52a6
xorl %eax, %eax
callq 0x250c
movl 0x48b4a(%rip), %eax     # 0x4d680
movl %eax, 0x48b48(%rip)     # 0x4d684
leaq 0x48b3d(%rip), %rbx     # 0x4d680
leaq 0x8a66(%rip), %rdi      # 0xd5b0
movl $0x40058, %edx          # imm = 0x40058
xorl %esi, %esi
callq 0x2130
movl $0x1, 0x8a54(%rip)      # 0xd5b4
movq %rbx, 0x48a89(%rip)     # 0x4d5f0
movabsq $0x2000000020, %rax     # imm = 0x2000000020
movq %rax, 0x8a54(%rip)      # 0xd5cc
leaq 0x73a(%rip), %rdi       # 0x52b9
leaq 0x7bf(%rip), %rsi       # 0x5345
callq 0x25c0
testq %rax, %rax
je 0x4baa
movq %rax, %rbx
leaq 0x8a16(%rip), %rdi      # 0xd5b0
movq %rax, %rsi
callq 0x47ee
movq %rbx, %rdi
callq 0x20f0
leaq 0x710(%rip), %rdi       # 0x52c1
leaq 0x78d(%rip), %rsi       # 0x5345
callq 0x22e0
testq %rax, %rax
je 0x4bd5
movq %rax, %rbx
movq %rax, %rdi
callq 0x48bf
movq %rbx, %rdi
callq 0x20f0
leaq 0x6ed(%rip), %rdi       # 0x52c9
movl $0xd48, %esi            # imm = 0xD48
callq 0x374a
movl %eax, 0x48a14(%rip)     # 0x4d600
leaq 0x89bd(%rip), %rbx      # 0xd5b0
movl $0x8, %edi
movl $0x1, %esi
callq 0x3dd3
movq %rax, 0x48a6f(%rip)     # 0x4d678
leaq -0x6e5(%rip), %rdi      # 0x452b
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x3bd8
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq1.c
// Function: any_bc
boolean any_bc(tteam team, int starnum)
{
    boolean any;
    int tf_number;
    any = false;
    if (tf_stars[starnum][team] > 0) {
        tf_number = 1;
        while ((!any) && (tf_number < 27)) {
            any = (tf[team][tf_number].dest == starnum) &&
                (tf[team][tf_number].eta == 0) &&
                ((tf[team][tf_number].c > 0) ||
                 (tf[team][tf_number].b > 0));
            tf_number = tf_number + 1;
        };
    };
    return (any);
}

// Assembly:
movslq %esi, %rcx
movslq %edi, %rax
shlq $0x3, %rcx
addq 0xad93(%rip), %rcx      # 0xcfe0
cmpl $0x0, (%rcx,%rax,4)
jle 0x229e
imulq $0x57c, %rax, %rax      # imm = 0x57C
leaq 0xc72f(%rip), %rcx      # 0xe990
addq %rax, %rcx
addq $0x58, %rcx
movl $0x1, %edx
xorl %eax, %eax
cmpl %esi, -0x4(%rcx)
jne 0x2288
cmpl $0x0, (%rcx)
jne 0x2288
cmpl $0x0, -0xc(%rcx)
jg 0x22a1
xorl %eax, %eax
cmpl $0x0, -0x8(%rcx)
setg %al
testl %eax, %eax
jne 0x229d
leaq 0x1(%rdx), %rdi
addq $0x34, %rcx
cmpq $0x1a, %rdx
movq %rdi, %rdx
jb 0x226d
retq
xorl %eax, %eax
retq
movl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq1.c
// Function: best_plan
void best_plan(int *St9rnum, int *S9ze, tteam *T9am)
{
    tplanet *pplanet;
    int starnum, size;
    tteam team;
    team = none;
    starnum = *St9rnum;
    size = 0;
    pplanet = stars[starnum].first_planet;
    while (pplanet != nil) {
        if (pplanet->capacity > size) {
            size = pplanet->capacity;
            team = pplanet->team;
        };
        pplanet = pplanet->next;
    };
    *T9am = team;
    *St9rnum = starnum;
    *S9ze = size;
}

// Assembly:
movslq (%rdi), %rax
leaq (%rax,%rax,2), %rcx
leaq 0xd1db(%rip), %r8       # 0xf490
movq 0x8(%r8,%rcx,8), %r9
testq %r9, %r9
je 0x22e2
xorl %ecx, %ecx
movl $0x2, %r8d
movl 0x4(%r9), %r10d
cmpl %ecx, %r10d
jle 0x22d7
movl 0xc(%r9), %r8d
movl %r10d, %ecx
movq 0x38(%r9), %r9
testq %r9, %r9
jne 0x22c7
jmp 0x22ea
movl $0x2, %r8d
xorl %ecx, %ecx
movl %r8d, (%rdx)
movl %eax, (%rdi)
movl %ecx, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq1.c
// Function: disp_tf
void disp_tf(struct sttf *taskf)
{
    if (taskf->t != 0)
        printw("%2dt", taskf->t);
    else
        printw("   ");
    if (taskf->s != 0)
        printw("%2ds", taskf->s);
    else
        printw("   ");
    if (taskf->c != 0)
        printw("%2dc", taskf->c);
    else
        printw("   ");
    if (taskf->b != 0)
        printw("%2db", taskf->b);
    else
        printw("   ");
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x14(%rdi), %esi
testl %esi, %esi
je 0x27cf
leaq 0x69c5(%rip), %rdi      # 0x918b
xorl %eax, %eax
callq 0x2030
jmp 0x27dd
leaq 0x6e4f(%rip), %rdi      # 0x9625
xorl %eax, %eax
callq 0x2030
movl 0x10(%rbx), %esi
testl %esi, %esi
je 0x27f4
leaq 0x69a5(%rip), %rdi      # 0x9190
xorl %eax, %eax
callq 0x2030
jmp 0x2802
leaq 0x6e2a(%rip), %rdi      # 0x9625
xorl %eax, %eax
callq 0x2030
movl 0x18(%rbx), %esi
testl %esi, %esi
je 0x2819
leaq 0x6985(%rip), %rdi      # 0x9195
xorl %eax, %eax
callq 0x2030
jmp 0x2827
leaq 0x6e05(%rip), %rdi      # 0x9625
xorl %eax, %eax
callq 0x2030
movl 0x1c(%rbx), %esi
testl %esi, %esi
je 0x283d
leaq 0x6965(%rip), %rdi      # 0x919a
xorl %eax, %eax
popq %rbx
jmp 0x2030
leaq 0x6de1(%rip), %rdi      # 0x9625
xorl %eax, %eax
popq %rbx
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq2.c
// Function: get_tf
void get_tf(tteam tm, int *I0, int starnum)
{
    int i;
    i = 1;
    while ((tf[tm][i].dest != 0) && (i < 27))
        i = i + 1;
    if (i == 27)
        i = 0;
    else {
        tf[tm][i].s = 0;
        tf[tm][i].t = 0;
        tf[tm][i].c = 0;
        tf[tm][i].b = 0;
        tf[tm][i].eta = 0;
        tf[tm][i].x = stars[starnum].x;
        tf[tm][i].y = stars[starnum].y;
        tf[tm][i].xf = tf[tm][i].x;
        tf[tm][i].yf = tf[tm][i].y;
        tf[tm][i].dest = starnum;
        tf[tm][i].origeta = 0;
        tf[tm][i].blasting = false;
    };
    *I0 = i;
}

// Assembly:
movslq %edi, %rax
imulq $0x57c, %rax, %rdi      # imm = 0x57C
addq 0xa4db(%rip), %rdi      # 0xcfb0
movl $0x1, %eax
movq %rax, %r8
incq %rax
leaq 0x34(%rdi), %rcx
cmpq $0x1a, %r8
ja 0x2af3
cmpl $0x0, 0x54(%rdi)
movq %rcx, %rdi
jne 0x2ada
xorl %edi, %edi
cmpq $0x1c, %rax
je 0x2b35
decl %eax
movl $0x0, 0x24(%rcx)
movslq %edx, %rdx
leaq (%rdx,%rdx,2), %rdi
leaq 0xc97e(%rip), %r8       # 0xf490
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rcx)
movq (%r8,%rdi,8), %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqu %xmm0, (%rcx)
movl %edx, 0x20(%rcx)
movq $0x0, 0x28(%rcx)
movl %eax, %edi
movl %edi, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq2.c
// Function: joinsilent
void joinsilent(tteam team, struct sttf *parent, struct sttf *child)
{
    parent->t = parent->t + child->t;
    parent->s = parent->s + child->s;
    parent->c = parent->c + child->c;
    parent->b = parent->b + child->b;
    if ((parent->dest != 0) && (child->dest != 0))
        tf_stars[parent->dest][team]--;
    child->dest = 0;
}

// Assembly:
movdqu 0x10(%rsi), %xmm0
movdqu 0x10(%rdx), %xmm1
paddd %xmm0, %xmm1
movdqu %xmm1, 0x10(%rsi)
movslq 0x20(%rsi), %rax
testq %rax, %rax
je 0x2b6b
cmpl $0x0, 0x20(%rdx)
je 0x2b6b
shlq $0x3, %rax
addq 0xa47b(%rip), %rax      # 0xcfe0
movslq %edi, %rcx
decl (%rax,%rcx,4)
movl $0x0, 0x20(%rdx)
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq2.c
// Function: lose
void lose(int *Ship9s, boolean *L0se_none, char typ, float percent)
{
    int i, sleft;
    int ships;
    boolean lose_none;
    ships = *Ship9s;
    lose_none = *L0se_none;
    if (ships > 0) {
        sleft = ships;
        for (i = 1; i <= ships; i++) {
            if (((float) (rand() & 0x7fff) / (float) (0x7fff)) > percent) {
                lose_none = false;
                sleft = sleft - 1;
            };
        };
        if (sleft < ships) {
            printw(" %2d%c", ships - sleft, typ);
            ships = sleft;
        };
    };
    *Ship9s = ships;
    *L0se_none = lose_none;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movl (%rdi), %ebx
movl (%rsi), %r15d
testl %ebx, %ebx
jle 0x2bef
movl %edx, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
xorl %ebp, %ebp
movl %ebx, %r13d
movl %ebx, %r12d
movss %xmm0, 0xc(%rsp)
callq 0x2100
andl $0x7fff, %eax           # imm = 0x7FFF
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x65f7(%rip), %xmm0     # 0x91b4
xorl %eax, %eax
ucomiss 0xc(%rsp), %xmm0
cmoval %ebp, %r15d
seta %al
subl %eax, %r12d
decl %r13d
jne 0x2ba4
movl %ebx, %esi
subl %r12d, %esi
jle 0x2bf4
movsbl 0x8(%rsp), %edx
leaq 0x65d2(%rip), %rdi      # 0x91b8
xorl %eax, %eax
callq 0x2030
jmp 0x2bf7
movl %ebx, %r12d
jmp 0x2bfc
movl %ebx, %r12d
movq 0x10(%rsp), %rsi
movl %r12d, (%r14)
movl %r15d, (%rsi)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq4.c
// Function: update_board
void update_board(int x, int y, toption option)
{
    int scren_x, screen_y;
    scren_x = 3 * x + 1;
    screen_y = 16 - y;
    switch (option) {
    case left:
        point(scren_x, screen_y);
        addch(board[x][y].enemy);
        break;

    case right:
        point(scren_x + 2, screen_y);
        addch(board[x][y].tf);
        break;

    case both:
        point(scren_x, screen_y);
        printw("%c%c%c", board[x][y].enemy, board[x][y].star,
               board[x][y].tf);
        break;
    };                          /*switch ( */
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r14d
movl $0x10, %esi
subl %ebx, %esi
testl %edx, %edx
je 0x2e8b
leal (%r14,%r14,2), %edi
incl %edi
cmpl $0x2, %edx
je 0x2e4d
cmpl $0x1, %edx
jne 0x2eca
callq 0x4f79
movq 0xa1bc(%rip), %rax      # 0xcfe8
movq (%rax), %rdi
movslq %r14d, %rax
movslq %ebx, %rcx
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
addq 0xa15c(%rip), %rax      # 0xcfa0
leaq (%rcx,%rcx,2), %rcx
movl (%rax,%rcx,4), %esi
jmp 0x2ebe
callq 0x4f79
movslq %r14d, %rax
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
addq 0xa135(%rip), %rax      # 0xcfa0
movl (%rax,%rcx,4), %esi
movl 0x4(%rax,%rcx,4), %edx
movl 0x8(%rax,%rcx,4), %ecx
leaq 0x6493(%rip), %rdi      # 0x9310
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2030
leal (%r14,%r14,2), %edi
addl $0x3, %edi
callq 0x4f79
movq 0xa14a(%rip), %rax      # 0xcfe8
movq (%rax), %rdi
movslq %r14d, %rax
movslq %ebx, %rcx
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
addq 0xa0ea(%rip), %rax      # 0xcfa0
leaq (%rcx,%rcx,2), %rcx
movl 0x8(%rax,%rcx,4), %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20a0
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq4.c
// Function: withdraw
void withdraw(int starnum, int plnum)
{
    int withnum;
    boolean error;
    printw("ithdraw ");
    cle3r_left();
    point(1, 19);
    split_tf(&plnum, &withnum);
    if (tf[player][withnum].dest != 0) {
        point(1, 20);
        set_des(withnum, &error);
        if (error) {
            tf[player][plnum].dest = starnum;
            joinsilent(player, &tf[player][plnum], &tf[player][withnum]);
            tf_stars[starnum][player] = 1;
        } else
            tf[player][withnum].withdrew = true;
    };
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
leaq 0x8(%rsp), %r14
movl %esi, (%r14)
leaq 0x5d8b(%rip), %rdi      # 0x93a7
xorl %eax, %eax
callq 0x2030
callq 0x7322
movl $0x1, %edi
movl $0x13, %esi
callq 0x4f79
leaq 0x4(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x7eea
movslq (%r15), %rax
imulq $0x34, %rax, %rax
leaq 0xb33b(%rip), %r15      # 0xe990
cmpl $0x0, 0x59c(%r15,%rax)
je 0x36eb
movl $0x1, %edi
movl $0x14, %esi
callq 0x4f79
movl 0x4(%rsp), %edi
leaq 0xc(%rsp), %r14
movq %r14, %rsi
callq 0x6eb8
cmpl $0x0, (%r14)
je 0x36d3
movslq 0x8(%rsp), %rax
imulq $0x34, %rax, %rax
leaq (%r15,%rax), %rsi
addq $0x57c, %rsi            # imm = 0x57C
movl %ebx, 0x20(%rsi)
movslq 0x4(%rsp), %rax
imulq $0x34, %rax, %rax
leaq (%r15,%rax), %rdx
addq $0x57c, %rdx            # imm = 0x57C
movl $0x1, %edi
callq 0x2b38
movslq %ebx, %rax
leaq 0xa557(%rip), %rcx      # 0xdc20
leaq (%rcx,%rax,8), %rax
addq $0x4, %rax
jmp 0x36e5
movslq 0x4(%rsp), %rax
imulq $0x34, %rax, %rax
addq %r15, %rax
addq $0x5ac, %rax            # imm = 0x5AC
movl $0x1, (%rax)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq4.c
// Function: zero_tf
void zero_tf(tteam tm, int tf_num)
{
    int x, y, i;
    if (tf[tm][tf_num].dest != 0) {
        x = tf[tm][tf_num].x;
        y = tf[tm][tf_num].y;
        if ((tf[tm][tf_num].s + tf[tm][tf_num].t + tf[tm][tf_num].c +
             tf[tm][tf_num].b) == 0) {
            if (tf[tm][tf_num].eta == 0) {
                tf_stars[tf[tm][tf_num].dest][tm]--;
            };
            tf[tm][tf_num].dest = 0;
            if (tm == player) {
                board[x][y].tf = ' ';
                for (i = 1; i <= 26; i++) {
                    if ((tf[player][i].dest != 0) &&
                        (tf[player][i].x == x) && (tf[player][i].y == y)) {
                        if (board[x][y].tf == ' ')
                            board[x][y].tf = i + 'a' - 1;
                        else
                            board[x][y].tf = '*';
                    };
                }
                update_board(x, y, right);
            }

        };
    };
}

// Assembly:
movl %edi, %eax
movslq %edi, %rdx
movslq %esi, %rcx
imulq $0x34, %rcx, %rdi
imulq $0x57c, %rdx, %rcx      # imm = 0x57C
addq 0x98a1(%rip), %rcx      # 0xcfb0
movslq 0x20(%rdi,%rcx), %rsi
testq %rsi, %rsi
je 0x37e2
addq %rdi, %rcx
movl 0x14(%rcx), %edi
addl 0x10(%rcx), %edi
addl 0x18(%rcx), %edi
addl 0x1c(%rcx), %edi
jne 0x37e2
cmpl $0x0, 0x24(%rcx)
jne 0x3746
shlq $0x3, %rsi
addq 0x989d(%rip), %rsi      # 0xcfe0
decl (%rsi,%rdx,4)
movslq (%rcx), %rdi
movslq 0x4(%rcx), %rsi
movl $0x0, 0x20(%rcx)
cmpl $0x1, %eax
jne 0x37e2
leaq (%rdi,%rdi,2), %rax
shlq $0x6, %rax
addq 0x9834(%rip), %rax      # 0xcfa0
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,4), %rax
addq $0x8, %rax
movl $0x20, (%rax)
movl $0x20, %r8d
movl $0x1, %ecx
xorl %edx, %edx
leaq 0xb1fe(%rip), %r9       # 0xe990
movl $0x2a, %r10d
cmpl $0x0, 0x5d0(%r9,%rdx)
je 0x37cc
cmpl %edi, 0x5b0(%r9,%rdx)
jne 0x37cc
cmpl %esi, 0x5b4(%r9,%rdx)
jne 0x37cc
movl %ecx, %r11d
orl $0x60, %r11d
cmpl $0x20, %r8d
cmovnel %r10d, %r11d
movl %r11d, (%rax)
movl %r11d, %r8d
incl %ecx
addq $0x34, %rdx
cmpq $0x548, %rdx            # imm = 0x548
jne 0x3798
xorl %edx, %edx
jmp 0x2df8
retq
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq4.c
// Function: up_year
void up_year(void)
{
    point(39, 18);
    turn = turn + 1;
    printw("%3d", turn);
    point(48, 19);
    production_year = production_year + 1;
    printw("%d", production_year);
}

// Assembly:
pushq %rax
movl $0x27, %edi
movl $0x12, %esi
callq 0x4f79
leaq 0xbf8a(%rip), %rax      # 0xf784
movl (%rax), %esi
incl %esi
movl %esi, (%rax)
leaq 0x6055(%rip), %rdi      # 0x985c
xorl %eax, %eax
callq 0x2030
movl $0x30, %edi
movl $0x13, %esi
callq 0x4f79
leaq 0xbf64(%rip), %rax      # 0xf788
movl (%rax), %esi
incl %esi
movl %esi, (%rax)
leaq 0x603e(%rip), %rdi      # 0x986f
xorl %eax, %eax
popq %rcx
jmp 0x2030
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conqb2.c
// Function: battle
void battle(void)
{
    boolean first;
    int starnum;
    first = true;
    for (starnum = 1; starnum <= nstars; starnum++) {
        if (tf_stars[starnum][ENEMY] > 0
            && tf_stars[starnum][player] > 0
            && (any_bc(ENEMY, starnum) || any_bc(player, starnum))
            ) {
            if (first) {
                point(33, 20);
                printw("* Tf battle *   ");
                first = false;
            };
            tf_battle(starnum);
        };
        if ((any_bc(ENEMY, starnum)) && (col_stars[starnum][player]
                                         > 0))
            EN2MY_attack(starnum);
        else if ((tf_stars[starnum][player] > 0)
                 && (col_stars[starnum][ENEMY] > 0))
            pl2yerattack(starnum);
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0x1, %ebp
movl $0x1, %ebx
leaq 0xa3cb(%rip), %r15      # 0xdc20
leaq 0x5b54(%rip), %r14      # 0x93b0
leaq 0xa46d(%rip), %r12      # 0xdcd0
cmpl $0x0, (%r15,%rbx,8)
jle 0x38b5
cmpl $0x0, 0x4(%r15,%rbx,8)
jle 0x38b5
xorl %edi, %edi
movl %ebx, %esi
callq 0x223c
testl %eax, %eax
jne 0x388f
movl $0x1, %edi
movl %ebx, %esi
callq 0x223c
testl %eax, %eax
je 0x38b5
testl %ebp, %ebp
je 0x38ac
movl $0x21, %edi
movl $0x14, %esi
callq 0x4f79
movq %r14, %rdi
xorl %eax, %eax
callq 0x2030
movl %ebx, %edi
callq 0x2ed2
xorl %ebp, %ebp
xorl %edi, %edi
movl %ebx, %esi
callq 0x223c
testl %eax, %eax
je 0x38d3
cmpl $0x0, 0x4(%r12,%rbx,8)
jle 0x38d3
movl %ebx, %edi
callq 0x284c
jmp 0x38e9
cmpl $0x0, 0x4(%r15,%rbx,8)
jle 0x38e9
cmpl $0x0, (%r12,%rbx,8)
jle 0x38e9
movl %ebx, %edi
callq 0x2c50
incq %rbx
cmpq $0x16, %rbx
jne 0x3863
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conqbat.c
// Function: blast
void blast(tplanet *planet, int factors)
{
    int killed;

    killed = MIN(planet->capacity, factors / 4);
    planet->inhabitants =
        MIN(planet->inhabitants, planet->capacity) - killed;
    planet->iu = MIN(planet->iu - killed, planet->inhabitants * iu_ratio);
    planet->capacity = planet->capacity - killed;
    if (planet->inhabitants <= 0) {
        planet->inhabitants = 0;
        planet->iu = 0;
        planet->mb = 0;
        planet->amb = 0;
        if (planet->team != none) {
            col_stars[planet->pstar][planet->team]--;
            planet->team = none;
            planet->esee_team = none;
            planet->conquered = false;
            on_board(stars[planet->pstar].x, stars[planet->pstar].y);
        };
    };
}

// Assembly:
leal 0x3(%rsi), %eax
testl %esi, %esi
cmovnsl %esi, %eax
sarl $0x2, %eax
movl 0x4(%rdi), %ecx
movl 0x10(%rdi), %edx
cmpl %eax, %ecx
cmovll %ecx, %eax
movl %ecx, %esi
subl %eax, %esi
cmpl %ecx, %edx
cmovgel %esi, %edx
movl %edx, 0x10(%rdi)
movl 0x14(%rdi), %ecx
subl %eax, %ecx
leal (%rdx,%rdx), %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x14(%rdi)
movl %esi, 0x4(%rdi)
testl %edx, %edx
jg 0x394d
leaq 0x10(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movslq 0xc(%rdi), %rax
cmpq $0x2, %rax
jne 0x394e
retq
movslq 0x30(%rdi), %rcx
shlq $0x3, %rcx
addq 0x965b(%rip), %rcx      # 0xcfb8
decl (%rcx,%rax,4)
movl $0x2, %eax
movl %eax, 0xc(%rdi)
movl %eax, 0x28(%rdi)
movl $0x0, 0x20(%rdi)
movslq 0x30(%rdi), %rax
leaq (%rax,%rax,2), %rax
leaq 0xbb0f(%rip), %rcx      # 0xf490
movl (%rcx,%rax,8), %edi
movl 0x4(%rcx,%rax,8), %esi
jmp 0x752b