// File: /workspace/github_c_makefile_star2_O1/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, %r14
movl %edi, %r15d
leaq 0x295d8(%rip), %rdi     # 0x2c440
movl $0x90, %edx
xorl %esi, %esi
callq 0x20f0
xorps %xmm0, %xmm0
movups %xmm0, 0x29652(%rip)    # 0x2c4d0
movq $0x0, 0x29657(%rip) # 0x2c4e0
leaq 0x29640(%rip), %rax     # 0x2c4d0
movq %rax, 0x295d1(%rip)     # 0x2c468
movq %rax, %rcx
movq (%rax), %rax
testq %rax, %rax
jne 0x2e97
leaq 0x1b30f(%rip), %rax     # 0x1e1b8
movq %rax, (%rcx)
movq $0x0, 0x1b301(%rip) # 0x1e1b8
leaq 0x29612(%rip), %rcx     # 0x2c4d0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2ebe
leaq 0x1b3a8(%rip), %rcx     # 0x1e278
movq %rcx, (%rax)
movq $0x0, 0x1b39a(%rip) # 0x1e278
leaq 0x295eb(%rip), %rcx     # 0x2c4d0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2ee5
leaq 0x1b341(%rip), %rcx     # 0x1e238
movq %rcx, (%rax)
movq $0x0, 0x1b333(%rip) # 0x1e238
leaq 0x295c4(%rip), %rcx     # 0x2c4d0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2f0c
leaq 0x1b2da(%rip), %rcx     # 0x1e1f8
movq %rcx, (%rax)
movq $0x0, 0x1b2cc(%rip) # 0x1e1f8
leaq 0x2959d(%rip), %rcx     # 0x2c4d0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2f33
leaq 0x1b373(%rip), %rcx     # 0x1e2b8
movq %rcx, (%rax)
movq $0x0, 0x1b365(%rip) # 0x1e2b8
leaq 0x29576(%rip), %rcx     # 0x2c4d0
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x2f5a
leaq 0x1b38c(%rip), %rcx     # 0x1e2f8
movq %rcx, (%rax)
movq $0x0, 0x1b37e(%rip) # 0x1e2f8
movl $0x456, 0x1b3dc(%rip)   # imm = 0x456
leaq -0x862(%rip), %rax      # 0x2729
movq %rax, 0x1b3d6(%rip)     # 0x1e368
cmpq $0x0, 0x2949e(%rip)     # 0x2c438
jne 0x2fa6
movq (%r14), %rax
movq %rax, 0x29492(%rip)     # 0x2c438
movq 0x1b04b(%rip), %rax     # 0x1dff8
movq (%rax), %r13
movl $0x0, 0x4(%rsp)
leaq 0x1205b(%rip), %rbx     # 0x1501a
leaq 0x8(%r14), %r12
leal -0x1(%r15), %ebp
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x30ab
cmpb $0x2d, (%rdi)
jne 0x30ab
movzbl 0x1(%rdi), %eax
cmpl $0x2d, %eax
je 0x2fef
testl %eax, %eax
jne 0x2ff9
jmp 0x30ab
cmpb $0x0, 0x2(%rdi)
je 0x3099
incq %rdi
movb (%rdi), %al
testb %al, %al
movl 0x4(%rsp), %r14d
leaq -0x8e2(%rip), %r15      # 0x272a
je 0x3087
incq %rdi
cmpb $0x64, %al
je 0x306e
movzbl %al, %eax
cmpl $0x73, %eax
je 0x3048
cmpl $0x70, %eax
jne 0x307c
cmpb $0x0, (%rdi)
jne 0x303b
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x3137
addq $0x8, %r12
decl %ebp
callq 0x2280
movl %eax, 0x1b31a(%rip)     # 0x1e360
jmp 0x3069
cmpb $0x0, (%rdi)
jne 0x3061
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x3137
addq $0x8, %r12
decl %ebp
callq 0x2280
movl %eax, %r14d
movq %rbx, %rdi
jmp 0x307c
movq %r13, 0x1b2db(%rip)     # 0x1e350
movq %r15, 0x1b2ec(%rip)     # 0x1e368
movb (%rdi), %al
testb %al, %al
jne 0x300e
movl %r14d, 0x4(%rsp)
movb $0x1, %al
movl %ebp, %r15d
movq %r12, %r14
testb %al, %al
jne 0x2fbf
jmp 0x30ab
addl $-0x2, %r15d
addq $0x10, %r14
xorl %eax, %eax
movl %r15d, %ebp
movq %r14, %r12
jmp 0x3089
testl %ebp, %ebp
jle 0x3137
movq (%r12), %rax
movq %rax, 0x1b29a(%rip)     # 0x1e358
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x29361(%rip)     # 0x2c430
leaq 0x1208e(%rip), %rdi     # 0x15164
callq 0x2a39
leaq 0x292fe(%rip), %rdi     # 0x2c3e0
callq 0x34e2
leaq 0x29352(%rip), %r14     # 0x2c440
movq %r14, %rdi
callq 0x3883
leaq 0x292a7(%rip), %rdi     # 0x2c3a4
callq 0x6477
movw $0x0, 0x29343(%rip)     # 0x2c44e
movl 0x4(%rsp), %eax
movl %eax, 0x2936b(%rip)     # 0x2c480
movw $0x1ff, 0x1b252(%rip)   # imm = 0x1FF
movq %r14, %rdi
callq 0x5870
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2dc5