// File: /workspace/github_c_makefile_star2_O3/aap[P]pdp11/xgp11.c
// Function: main
int
main(int argc, char *argv[])
{
	uint32 sleep;

	memset(&cpu, 0, sizeof(cpu));
	memset(&bus, 0, sizeof(Bus));
	cpu.bus = &bus;
	busadddev(&bus, &membusdev);
#ifndef KD11Bp
	busadddev(&bus, &kwbusdev);
	busadddev(&bus, &klbusdev);
#endif
	busadddev(&bus, &kebusdev);
	busadddev(&bus, &xgpbusdev);
	busadddev(&bus, &ten11busdev);

	port = 1110;
	sleep = 0;
	debug = quiet;
	ARGBEGIN{
	case 'p':
		port = atoi(EARGF(usage()));
		break;
	case 's':
		sleep = atoi(EARGF(usage()));
		break;
	case 'd':
		logfile = stderr;
		debug = log;
		break;
	}ARGEND;

	if(argc < 1)
		usage();

	host = argv[0];
	ten11.cycle = 0;
	ten11.fd = -1;
	loadmem("mem.txt");

//	if(loadpt("maindec/MAINDEC-11-D0NA-PB.ptap"))
//	if(loadpt("maindec/MAINDEC-11-D2AA-PB.ptap"))
//		return 0;

//	cpu.r[7] = 0200;
//	cpu.sw = 0104000;

	//void eaetest(KE11 *ke);
	//eaetest(&ke11);

	initxgp(&xgp);

	reset(&cpu);

	ttyopen(&TTYDEV.tty);

	/* wait until we get some data from the 10 */
	cpu.r[7] = 0;
	cpu.throttle = sleep;
	memory[0] = 0777;
	run(&cpu);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x29736(%rip), %rdi     # 0x2c450
movl $0x90, %edx
xorl %esi, %esi
callq 0x20f0
xorps %xmm0, %xmm0
movups %xmm0, 0x297b8(%rip)    # 0x2c4e8
leaq 0x297a9(%rip), %rax     # 0x2c4e0
movq %rax, 0x2973a(%rip)     # 0x2c478
leaq 0x1b47b(%rip), %rcx     # 0x1e1c0
movq %rcx, 0x29794(%rip)     # 0x2c4e0
movq $0x0, 0x1b469(%rip) # 0x1e1c0
movq %rcx, %rdx
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2d57
leaq 0x1b517(%rip), %rcx     # 0x1e280
movq %rcx, (%rdx)
movq $0x0, 0x1b509(%rip) # 0x1e280
movq %rax, %rcx
movq (%rax), %rax
testq %rax, %rax
jne 0x2d77
leaq 0x1b4b7(%rip), %rax     # 0x1e240
movq %rax, (%rcx)
movq $0x0, 0x1b4a9(%rip) # 0x1e240
leaq 0x29742(%rip), %rcx     # 0x2c4e0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2d9e
leaq 0x1b450(%rip), %rcx     # 0x1e200
movq %rcx, (%rax)
movq $0x0, 0x1b442(%rip) # 0x1e200
leaq 0x2971b(%rip), %rcx     # 0x2c4e0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2dc5
leaq 0x1b4e9(%rip), %rcx     # 0x1e2c0
movq %rcx, (%rax)
movq $0x0, 0x1b4db(%rip) # 0x1e2c0
leaq 0x296f4(%rip), %rcx     # 0x2c4e0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2dec
leaq 0x1b502(%rip), %rcx     # 0x1e300
movq %rcx, (%rax)
movq $0x0, 0x1b4f4(%rip) # 0x1e300
movl $0x456, 0x1b55a(%rip)   # imm = 0x456
leaq -0x834(%rip), %rax      # 0x25e9
movq %rax, 0x1b554(%rip)     # 0x1e378
cmpq $0x0, 0x2961c(%rip)     # 0x2c448
jne 0x2e38
movq (%rbx), %rax
movq %rax, 0x29610(%rip)     # 0x2c448
leaq 0x8(%rbx), %rax
leal -0x1(%r14), %ecx
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x2f27
movq 0x1b1a4(%rip), %rdx     # 0x1dff8
movq (%rdx), %r15
xorl %ebp, %ebp
leaq -0x876(%rip), %r12      # 0x25ea
leaq 0x121b3(%rip), %r13     # 0x1501a
cmpb $0x2d, (%rsi)
jne 0x2f39
leaq 0x1(%rsi), %rdi
movzbl 0x1(%rsi), %edx
cmpl $0x2d, %edx
je 0x2e8c
movq %rax, %rbx
movl %ecx, %r14d
testl %edx, %edx
jne 0x2e9c
jmp 0x2f39
cmpb $0x0, 0x2(%rsi)
je 0x2f2b
movq %rax, %rbx
movl %ecx, %r14d
incq %rdi
cmpb $0x64, %dl
je 0x2efc
movzbl %dl, %eax
cmpl $0x73, %eax
je 0x2ed7
cmpl $0x70, %eax
jne 0x2f0a
cmpb $0x0, (%rdi)
jne 0x2eca
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x2fbc
addq $0x8, %rbx
decl %r14d
callq 0x2290
movl %eax, 0x1b49b(%rip)     # 0x1e370
jmp 0x2ef7
cmpb $0x0, (%rdi)
jne 0x2ef0
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x2fbc
addq $0x8, %rbx
decl %r14d
callq 0x2290
movl %eax, %ebp
movq %r13, %rdi
jmp 0x2f0a
movq %r15, 0x1b45d(%rip)     # 0x1e360
movq %r12, 0x1b46e(%rip)     # 0x1e378
movb (%rdi), %dl
testb %dl, %dl
jne 0x2e9c
leaq 0x8(%rbx), %rax
leal -0x1(%r14), %ecx
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
jne 0x2e67
jmp 0x2f39
xorl %ebp, %ebp
jmp 0x2f39
addl $-0x2, %r14d
addq $0x10, %rbx
movl %r14d, %ecx
movq %rbx, %rax
testl %ecx, %ecx
jle 0x2fbc
movq (%rax), %rax
movq %rax, 0x1b421(%rip)     # 0x1e368
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x294e8(%rip)     # 0x2c440
leaq 0x12205(%rip), %rdi     # 0x15164
callq 0x28ec
leaq 0x29485(%rip), %rdi     # 0x2c3f0
callq 0x3383
leaq 0x294d9(%rip), %rbx     # 0x2c450
movq %rbx, %rdi
callq 0x376f
leaq 0x2942e(%rip), %rdi     # 0x2c3b4
callq 0x6483
movw $0x0, 0x294ca(%rip)     # 0x2c45e
movl %ebp, 0x294f6(%rip)     # 0x2c490
movw $0x1ff, 0x1b3dd(%rip)   # imm = 0x1FF
movq %rbx, %rdi
callq 0x5877
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2c77
nopl (%rax)