// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/1105.c
// Function: main
int
xmain(int argc, char *argv[])
{
	memset(&cpu, 0, sizeof(KD11B));
	memset(&bus, 0, sizeof(Bus));
	cpu.bus = &bus;
	busadddev(&bus, &membusdev);
	busadddev(&bus, &kebusdev);

	ARGBEGIN{
	}ARGEND;

	if(argc < 0)
		usage();

	loadmem("mem.txt");

	reset(&cpu);

	ttyopen(&cpu.tty);

#ifdef AUTODIAG
	if(rundiag(&cpu, "maindec/ZKAAA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKABA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKACA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKADA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAEA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAFA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAGA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAHA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAIA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAJA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAKA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKALA0.BIN")) return 0;
	if(rundiag(&cpu, "maindec/ZKAMA0.BIN")) return 0;
//	if(rundiag(&cpu, "maindec/maindec-11-d0nc.pb.bin")) return 0;
	printf("passed all diagnostics\n");
		return 0;
#endif

	cpu.r[7] = 0200;
//	cpu.sw = 0104000;
	run(&cpu);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xe773(%rip), %rdi      # 0x101f0
xorl %esi, %esi
movl $0xe8, %edx
callq 0x10e0
leaq 0xe848(%rip), %rdi      # 0x102d8
xorl %esi, %esi
movl $0x18, %edx
callq 0x10e0
leaq 0xe835(%rip), %rax      # 0x102d8
movq %rax, 0xe76e(%rip)      # 0x10218
leaq 0xe827(%rip), %rdi      # 0x102d8
leaq 0x8688(%rip), %rsi      # 0xa140
callq 0x1330
leaq 0xe814(%rip), %rdi      # 0x102d8
leaq 0x86b5(%rip), %rsi      # 0xa180
callq 0x1330
movb $0x1, %al
cmpq $0x0, 0xe70e(%rip)      # 0x101e8
movb %al, -0x22(%rbp)
jne 0x1af7
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, 0xe6fb(%rip)      # 0x101e8
cmpq $0x0, %rax
setne %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x23(%rbp)
je 0x1b46
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2d, %ecx
movb %al, -0x23(%rbp)
jne 0x1b46
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x23(%rbp)
movb -0x23(%rbp), %al
testb $0x1, %al
jne 0x1b52
jmp 0x1bf3
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1b91
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x1b91
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x1bf3
movb $0x0, -0x21(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x24(%rbp)
je 0x1bc6
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb (%rax), %al
movb %al, -0x21(%rbp)
movsbl %al, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x24(%rbp)
movb -0x24(%rbp), %al
testb $0x1, %al
jne 0x1bcf
jmp 0x1bd1
jmp 0x1b95
movq $0x0, -0x20(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x1b0f
cmpl $0x0, -0x8(%rbp)
jge 0x1bfe
callq 0x1a30
leaq 0x543a(%rip), %rdi      # 0x703f
callq 0x1580
leaq 0xe5df(%rip), %rdi      # 0x101f0
callq 0x1da0
leaq 0xe5d3(%rip), %rdi      # 0x101f0
addq $0xbc, %rdi
callq 0x5f60
movw $0x80, 0xe5cc(%rip)     # 0x101fe
leaq 0xe5b7(%rip), %rdi      # 0x101f0
callq 0x49d0
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)