// File: mitchblank[P]qiksolve/qiksolve.cpp
// Function: main
int main(int argn, char const * const *argv)
{
	if (argn < 2)
		return usage(argv[0]);
	unsigned a = 1;
	enum {
		INTERACTIVE,
		SOLUTION_TREE,
		BATCH
	} mode = INTERACTIVE;
	if (0 == strcmp(argv[1], "-t")) {
		mode = SOLUTION_TREE;
		a = 2;
		argn--;
	} else if (0 == strcmp(argv[1], "-b")) {
		mode = BATCH;
		a = 2;
		argn--;
	}
	if (argn < 2 || argn > 3)
		return usage(argv[0]);
	FILE *fp = fopen(argv[a], "r");
	if (fp == NULL) {
		perror("open");
		return 4;
	}
	Dictionary dict(fp, (argn == 2) ? 4 : static_cast<unsigned>(atoi(argv[a + 1])));
	if (dict.empty()) {
		fprintf(stderr, "%s: No words found!\n", argv[0]);
		return 1;
	}
	switch (mode) {
	case INTERACTIVE:
		dict.interactive();
		break;
	case BATCH:
		dict.batch(stdin, stdout);
		break;
	default:
		assert(mode == SOLUTION_TREE);
		dict.printSolutions(stdout);
		break;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x41b3
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x4400
movl %eax, -0x4(%rbp)
jmp 0x43e6
movl $0x1, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x922e(%rip), %rsi      # 0xd3fe
callq 0x21f0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x41f6
movl $0x1, -0x18(%rbp)
movl $0x2, -0x14(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x422b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x91fc(%rip), %rsi      # 0xd401
callq 0x21f0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x4229
movl $0x2, -0x18(%rbp)
movl $0x2, -0x14(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x422b
cmpl $0x2, -0x8(%rbp)
jl 0x4237
cmpl $0x3, -0x8(%rbp)
jle 0x424b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x4400
movl %eax, -0x4(%rbp)
jmp 0x43e6
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x91a7(%rip), %rsi      # 0xd404
callq 0x21b0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4285
leaq 0x9192(%rip), %rdi      # 0xd406
callq 0x2120
movl $0x4, -0x4(%rbp)
jmp 0x43e6
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x42a3
movl $0x4, %eax
movl %eax, -0x8c(%rbp)
jmp 0x42be
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x2230
movl %eax, -0x8c(%rbp)
movq -0x88(%rbp), %rsi
movl -0x8c(%rbp), %edx
leaq -0x70(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x2630
movq -0x98(%rbp), %rdi
callq 0x56c0
movb %al, -0x8d(%rbp)
jmp 0x42ef
movb -0x8d(%rbp), %al
testb $0x1, %al
jne 0x42fb
jmp 0x4347
movq 0x10cde(%rip), %rax     # 0x14fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x90f8(%rip), %rsi      # 0xd40b
movb $0x0, %al
callq 0x2200
movl $0x1, -0x4(%rbp)
movl $0x1, -0x80(%rbp)
jmp 0x43dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x56e0
jmp 0x43f2
movl -0x18(%rbp), %eax
movl %eax, -0x9c(%rbp)
testl %eax, %eax
je 0x4363
jmp 0x4356
movl -0x9c(%rbp), %eax
subl $0x2, %eax
je 0x4370
jmp 0x4391
leaq -0x70(%rbp), %rdi
callq 0x4150
jmp 0x436e
jmp 0x43cf
movq 0x10c61(%rip), %rax     # 0x14fd8
movq (%rax), %rsi
movq 0x10c3f(%rip), %rax     # 0x14fc0
movq (%rax), %rdx
leaq -0x70(%rbp), %rdi
callq 0x3560
jmp 0x438f
jmp 0x43cf
cmpl $0x1, -0x18(%rbp)
jne 0x4399
jmp 0x43b8
leaq 0x9080(%rip), %rdi      # 0xd420
leaq 0x8cb2(%rip), %rsi      # 0xd059
movl $0x2bc, %edx            # imm = 0x2BC
leaq 0x9083(%rip), %rcx      # 0xd436
callq 0x20e0
movq 0x10c01(%rip), %rax     # 0x14fc0
movq (%rax), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3300
jmp 0x43cd
jmp 0x43cf
movl $0x0, -0x4(%rbp)
movl $0x1, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x56e0
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x2290
nopl (%rax,%rax)