// File: textbrowser[P]zepeto/zepeto_main.cc
// Function: main
int main(int argc, char *argv[])
{
  if(argc <= 1 || !argv)
    return EXIT_FAILURE;

  auto rc = EXIT_SUCCESS;
  zepeto *z = nullptr;

  try
    {
      for(int i = 1; i < argc; i++)
	if(argv[i] && strcmp(argv[i], "-p") == 0)
	  {
	    z = new zepeto(false);
	    z->purge();
	    delete z;
	    z = nullptr;
	    break;
	  }

      for(int i = 1; i < argc; i++)
	if(argv[i] && strcmp(argv[i], "-t") == 0)
	  {
	    i += 1;

	    if(i < argc && argv[i])
	      {
		z = new zepeto(true);
		z->set_product_file(argv[i]);
		break;
	      }
	    else
	      /*
	      ** Assume the default zepeto.table file.
	      */

	      rc = EXIT_FAILURE;
	  }

      if(!z)
	z = new zepeto(true);

      for(int i = 1; i < argc; i++)
      	if(argv[i] && strcmp(argv[i], "-i") == 0)
	  {
	    z->print_about();
	    goto done_label;
	  }
	else if(argv[i] && strcmp(argv[i], "-l") == 0)
	  {
	    z->print_products();
	    goto done_label;
	  }

      for(int i = 1; i < argc; i++)
	if(argv[i] && strcmp(argv[i], "-a") == 0)
	  {
	    i += 1;

	    if(i < argc && argv[i])
	      z->add_attach_product(argv[i]);
	    else
	      rc = EXIT_FAILURE;
	  }
	else if(argv[i] && strcmp(argv[i], "-d") == 0)
	  {
	    i += 1;

	    if(i < argc && argv[i])
	      z->add_detach_product(argv[i]);
	    else
	      rc = EXIT_FAILURE;
	  }
	else if(argv[i] && strcmp(argv[i], "-i") == 0)
	  {
	  }
	else if(argv[i] && strcmp(argv[i], "-l") == 0)
	  {
	  }
	else if(argv[i] && strcmp(argv[i], "-p") == 0)
	  {
	  }
	else if(argv[i] && strcmp(argv[i], "-s") == 0)
	  {
	    i += 1;

	    if(i < argc && argv[i])
	      z->add_print_product(argv[i]);
	    else
	      rc = EXIT_FAILURE;
	  }
	else if(argv[i] && strcmp(argv[i], "-t") == 0)
	  i += 1;
	else
	  rc = EXIT_FAILURE;

      z->final();
    }
  catch(const std::bad_alloc &exception)
    {
      rc = EXIT_FAILURE;

      if(!z)
	return rc;
    }
  catch(const std::runtime_error &exception)
    {
      rc = EXIT_FAILURE;
      std::cerr << exception.what();
    }
  catch(...)
    {
    }

 done_label:

  auto remove_temporary_file = false;

  try
    {
      if(z && z->has_error())
	{
	  rc = EXIT_FAILURE;
	  z->print_error();
	}
    }
  catch(const std::runtime_error &exception)
    {
      rc = EXIT_FAILURE;
      remove_temporary_file = true;
      std::cerr << exception.what();
    }
  catch(...)
    {
      rc = EXIT_FAILURE;
      remove_temporary_file = true;
    }

  if(remove_temporary_file && z)
    z->remove_temporary_file();

  delete z;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %fs:0x28, %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl %edi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpl $0x1, -0x10(%rbp)
jle 0x102b3
cmpq $0x0, -0x18(%rbp)
jne 0x102bf
movl $0x1, -0xc(%rbp)
jmp 0x109d7
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x103b4
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x103a4
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1011(%rip), %rsi      # 0x11318
callq 0x34e0
cmpl $0x0, %eax
jne 0x103a4
movl $0x160, %edi            # imm = 0x160
callq 0x3360
movq %rax, -0x70(%rbp)
jmp 0x10325
movq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x3930
jmp 0x10332
movq -0x70(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x71d0
jmp 0x10345
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x1036a
movq -0x78(%rbp), %rdi
callq 0x3ec0
movq -0x78(%rbp), %rdi
movl $0x160, %esi            # imm = 0x160
callq 0x3370
movq $0x0, -0x28(%rbp)
jmp 0x103b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x104ef
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x160, %esi            # imm = 0x160
callq 0x3370
jmp 0x104ef
jmp 0x103a6
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x102d5
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x10491
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10481
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xf2e(%rip), %rsi       # 0x1131b
callq 0x34e0
cmpl $0x0, %eax
jne 0x10481
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x10478
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10478
movl $0x160, %edi            # imm = 0x160
callq 0x3360
movq %rax, -0x80(%rbp)
jmp 0x1042b
movq -0x80(%rbp), %rdi
movl $0x1, %esi
callq 0x3930
jmp 0x1043b
movq -0x80(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x7480
jmp 0x1045a
jmp 0x10491
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x160, %esi            # imm = 0x160
callq 0x3370
jmp 0x104ef
movl $0x1, -0x1c(%rbp)
jmp 0x10481
jmp 0x10483
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x103bb
cmpq $0x0, -0x28(%rbp)
jne 0x10590
movl $0x160, %edi            # imm = 0x160
callq 0x3360
movq %rax, -0x88(%rbp)
jmp 0x104af
movq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x3930
jmp 0x104c2
movq -0x88(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x10590
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x160, %esi            # imm = 0x160
callq 0x3370
movl -0x3c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl $0x3, %ecx
cmpl %ecx, %eax
jne 0x10532
movq -0x38(%rbp), %rdi
callq 0x3150
movq %rax, -0x58(%rbp)
movl $0x1, -0x1c(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x108a2
movl -0x1c(%rbp), %eax
movl %eax, -0xc(%rbp)
movl $0x1, -0x5c(%rbp)
jmp 0x108a9
movl -0x8c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1057d
movq -0x38(%rbp), %rdi
callq 0x3150
movq %rax, -0x50(%rbp)
movl $0x1, -0x1c(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x6a7c(%rip), %rdi      # 0x16fe8
callq 0x3350
jmp 0x10573
callq 0x35a0
jmp 0x108be
movq -0x38(%rbp), %rdi
callq 0x3150
callq 0x35a0
jmp 0x108be
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x1062d
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x105df
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xd59(%rip), %rsi       # 0x1131e
callq 0x34e0
cmpl $0x0, %eax
jne 0x105df
movq -0x28(%rbp), %rdi
callq 0x65e0
jmp 0x105da
jmp 0x108c0
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x1061b
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xd20(%rip), %rsi       # 0x11321
callq 0x34e0
cmpl $0x0, %eax
jne 0x1061b
movq -0x28(%rbp), %rdi
callq 0x6aa0
jmp 0x10616
jmp 0x108c0
jmp 0x1061d
jmp 0x1061f
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x10597
movl $0x1, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x1087d
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x106b1
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xcc2(%rip), %rsi       # 0x11324
callq 0x34e0
cmpl $0x0, %eax
jne 0x106b1
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x106a5
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x106a5
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4e20
jmp 0x106a3
jmp 0x106ac
movl $0x1, -0x1c(%rbp)
jmp 0x1086d
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10722
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc54(%rip), %rsi       # 0x11327
callq 0x34e0
cmpl $0x0, %eax
jne 0x10722
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x10716
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10716
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x5140
jmp 0x10714
jmp 0x1071d
movl $0x1, -0x1c(%rbp)
jmp 0x1086b
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10753
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xbda(%rip), %rsi       # 0x1131e
callq 0x34e0
cmpl $0x0, %eax
jne 0x10753
jmp 0x10869
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10784
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xbac(%rip), %rsi       # 0x11321
callq 0x34e0
cmpl $0x0, %eax
jne 0x10784
jmp 0x10867
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x107b5
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xb72(%rip), %rsi       # 0x11318
callq 0x34e0
cmpl $0x0, %eax
jne 0x107b5
jmp 0x10865
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x10823
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xb53(%rip), %rsi       # 0x1132a
callq 0x34e0
cmpl $0x0, %eax
jne 0x10823
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x1081a
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x1081a
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x5460
jmp 0x10818
jmp 0x10821
movl $0x1, -0x1c(%rbp)
jmp 0x10863
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x1085a
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xad6(%rip), %rsi       # 0x1131b
callq 0x34e0
cmpl $0x0, %eax
jne 0x1085a
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x10861
movl $0x1, -0x1c(%rbp)
jmp 0x10863
jmp 0x10865
jmp 0x10867
jmp 0x10869
jmp 0x1086b
jmp 0x1086d
jmp 0x1086f
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x10634
movq -0x28(%rbp), %rdi
callq 0x5780
jmp 0x10888
jmp 0x108be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x35a0
jmp 0x1089d
jmp 0x10a01
movl $0x0, -0x5c(%rbp)
callq 0x35a0
movl -0x5c(%rbp), %eax
testl %eax, %eax
je 0x108bc
jmp 0x108b7
jmp 0x109d7
jmp 0x108be
jmp 0x108c0
movb $0x0, -0x5d(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1098c
movq -0x28(%rbp), %rdi
callq 0x3fe0
movb %al, -0x8d(%rbp)
jmp 0x108e0
movb -0x8d(%rbp), %al
testb $0x1, %al
jne 0x108ef
jmp 0x1098c
movl $0x1, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x68d0
jmp 0x10901
jmp 0x1098c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x10971
movq -0x38(%rbp), %rdi
callq 0x3150
movq %rax, -0x68(%rbp)
movl $0x1, -0x1c(%rbp)
movb $0x1, -0x5d(%rbp)
movq -0x68(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x669b(%rip), %rdi      # 0x16fe8
callq 0x3350
jmp 0x10954
callq 0x35a0
testb $0x1, -0x5d(%rbp)
je 0x109a3
cmpq $0x0, -0x28(%rbp)
je 0x109a3
movq -0x28(%rbp), %rdi
callq 0x7420
jmp 0x109a3
movq -0x38(%rbp), %rdi
callq 0x3150
movl $0x1, -0x1c(%rbp)
movb $0x1, -0x5d(%rbp)
callq 0x35a0
jmp 0x10959
jmp 0x10959
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x35a0
jmp 0x109a1
jmp 0x10a01
movq -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x109d1
movq -0x98(%rbp), %rdi
callq 0x3ec0
movq -0x98(%rbp), %rdi
movl $0x160, %esi            # imm = 0x160
callq 0x3370
movl -0x1c(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq %fs:0x28, %rax
movq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x10a32
movl -0x9c(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq %fs:0x28, %rax
movq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x10a32
movq -0xa8(%rbp), %rdi
callq 0x35f0
movq %rax, %rdi
callq 0x7810
callq 0x33f0