// File: textbrowser[P]zepeto/zepeto.cc
// Function: zepeto::zepeto(bool)
zepeto::zepeto(const bool create_temporary_file):
  m_product_file("/usr/local/share/zepeto.table")
{
  m_buffer = m_pwd_buffer = m_tempfilename = nullptr;
  m_buffer = new char[s_maximum_buffer_length];
  m_fd = -1;

  auto const pwd_length = sysconf(_SC_GETPW_R_SIZE_MAX);
  size_t buffer_size = 0;
  struct passwd pwd = {};
  struct passwd *result;

  if(pwd_length <= 0)
    buffer_size = 16384;
  else
    buffer_size = static_cast<size_t> (pwd_length);

  m_pwd_buffer = new char[buffer_size];

  if(getpwuid_r(getuid(), &pwd, m_pwd_buffer, buffer_size, &result) == 0 &&
     result)
    m_tempdir = pwd.pw_dir;
  else
    m_tempdir = "/tmp";

  m_tempfilename = nullptr;

  if(create_temporary_file)
    {
      std::ostringstream stream;

      stream << m_tempdir
	     << "/.zepeto.sourceme."
	     << getuid()
	     << "."
	     << getpid()
	     << "XXXXXX";

      auto const length = stream.str().length() + 1;

      m_tempfilename = new char[length];
      memset(m_tempfilename, 0, length);
      strncpy(m_tempfilename, stream.str().c_str(), length - 1);

      if((m_fd = mkstemp(m_tempfilename)) == -1)
	m_error.append("echo \"mkstemp() failure.\"\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movb %sil, %al
movq %fs:0x28, %rcx
movq %rcx, -0x8(%rbp)
movq %rdi, -0x208(%rbp)
andb $0x1, %al
movb %al, -0x209(%rbp)
movq -0x208(%rbp), %rdi
movq %rdi, -0x250(%rbp)
addq $0x20, %rdi
movq %rdi, -0x280(%rbp)
callq 0x7620
movq -0x250(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x278(%rbp)
callq 0x7660
movq -0x250(%rbp), %rdi
subq $-0x80, %rdi
movq %rdi, -0x270(%rbp)
callq 0x7660
movq -0x250(%rbp), %rdi
addq $0xb0, %rdi
movq %rdi, -0x268(%rbp)
callq 0x7660
movq -0x250(%rbp), %rdi
addq $0xe0, %rdi
movq %rdi, -0x260(%rbp)
callq 0x34d0
movq -0x250(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq %rdi, -0x258(%rbp)
callq 0x34d0
movq -0x250(%rbp), %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, -0x248(%rbp)
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x3600
movq -0x248(%rbp), %rdi
movq -0x240(%rbp), %rdx
leaq 0xd5d4(%rip), %rsi      # 0x11004
callq 0x76a0
jmp 0x3a37
leaq -0x1c1(%rbp), %rdi
callq 0x33c0
movq -0x250(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movq %rdi, -0x290(%rbp)
callq 0x34d0
movq -0x250(%rbp), %rax
movq $0x0, 0x10(%rax)
movq $0x0, 0x8(%rax)
movq $0x0, (%rax)
movq 0x138e6(%rip), %rdi     # 0x17368
callq 0x3030
movq %rax, -0x288(%rbp)
jmp 0x3a90
movq -0x250(%rbp), %rax
movq -0x288(%rbp), %rcx
movq %rcx, (%rax)
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movl $0x46, %edi
callq 0x3270
movq %rax, -0x228(%rbp)
movq $0x0, -0x230(%rbp)
leaq -0x1f8(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x31e0
cmpq $0x0, -0x228(%rbp)
jg 0x3b28
movq $0x4000, -0x230(%rbp) # imm = 0x4000
jmp 0x3b36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x1c1(%rbp), %rdi
callq 0x33c0
jmp 0x3e46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x3e2e
movq -0x228(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rdi
callq 0x3030
movq %rax, -0x298(%rbp)
jmp 0x3b4b
movq -0x250(%rbp), %rax
movq -0x298(%rbp), %rcx
movq %rcx, 0x8(%rax)
callq 0x31c0
movl %eax, %edi
movq -0x250(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x230(%rbp), %rcx
leaq -0x1f8(%rbp), %rsi
leaq -0x200(%rbp), %r8
callq 0x36a0
movl %eax, -0x29c(%rbp)
jmp 0x3b91
movl -0x29c(%rbp), %eax
cmpl $0x0, %eax
jne 0x3bc4
cmpq $0x0, -0x200(%rbp)
je 0x3bc4
movq -0x250(%rbp), %rdi
movq -0x1d8(%rbp), %rsi
addq $0x140, %rdi            # imm = 0x140
callq 0x34c0
jmp 0x3bc2
jmp 0x3be2
movq -0x250(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
leaq 0xd449(%rip), %rsi      # 0x11022
callq 0x34c0
jmp 0x3be0
jmp 0x3be2
movq -0x250(%rbp), %rax
movq $0x0, 0x10(%rax)
testb $0x1, -0x209(%rbp)
je 0x3e0f
leaq -0x180(%rbp), %rdi
callq 0x34b0
jmp 0x3c0c
movq -0x250(%rbp), %rsi
addq $0x140, %rsi            # imm = 0x140
leaq -0x180(%rbp), %rdi
callq 0x3320
movq %rax, -0x2a8(%rbp)
jmp 0x3c2f
movq -0x2a8(%rbp), %rdi
leaq 0xd3ea(%rip), %rsi      # 0x11027
callq 0x3350
movq %rax, -0x2b0(%rbp)
jmp 0x3c4b
callq 0x31c0
movq -0x2b0(%rbp), %rdi
movl %eax, %esi
callq 0x34a0
movq %rax, -0x2b8(%rbp)
jmp 0x3c67
movq -0x2b8(%rbp), %rdi
leaq 0xd3c3(%rip), %rsi      # 0x11038
callq 0x3350
movq %rax, -0x2c0(%rbp)
jmp 0x3c83
callq 0x3500
movq -0x2c0(%rbp), %rdi
movl %eax, %esi
callq 0x35e0
movq %rax, -0x2c8(%rbp)
jmp 0x3c9f
movq -0x2c8(%rbp), %rdi
leaq 0xd38d(%rip), %rsi      # 0x1103a
callq 0x3350
jmp 0x3cb4
leaq -0x1a0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x3380
jmp 0x3cc9
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x3510
movq -0x2e0(%rbp), %rdi
incq %rax
movq %rax, -0x2d8(%rbp)
callq 0x3250
movq -0x2d8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rdi
callq 0x3030
movq %rax, -0x2d0(%rbp)
jmp 0x3d15
movq -0x250(%rbp), %rax
movq -0x2d0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rax), %rdi
movq -0x238(%rbp), %rdx
xorl %esi, %esi
callq 0x31e0
movq -0x250(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x3380
jmp 0x3d60
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x3160
movq -0x2e8(%rbp), %rdi
movq %rax, %rsi
movq -0x238(%rbp), %rdx
decq %rdx
callq 0x31d0
movq -0x2f8(%rbp), %rdi
callq 0x3250
movq -0x250(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3100
movl %eax, -0x2ec(%rbp)
jmp 0x3db0
movl -0x2ec(%rbp), %eax
movq -0x250(%rbp), %rcx
movl %eax, 0x18(%rcx)
cmpl $-0x1, %eax
jne 0x3e03
movq -0x250(%rbp), %rdi
addq $0xe0, %rdi
leaq 0xd267(%rip), %rsi      # 0x11041
callq 0x3640
jmp 0x3de1
jmp 0x3e03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x30b0
jmp 0x3e2e
leaq -0x180(%rbp), %rdi
callq 0x30b0
movq %fs:0x28, %rax
movq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x3eba
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq -0x290(%rbp), %rdi
callq 0x3250
movq -0x248(%rbp), %rdi
callq 0x3250
movq -0x258(%rbp), %rdi
callq 0x3250
movq -0x260(%rbp), %rdi
callq 0x3250
movq -0x268(%rbp), %rdi
callq 0x7790
movq -0x270(%rbp), %rdi
callq 0x7790
movq -0x278(%rbp), %rdi
callq 0x7790
movq -0x280(%rbp), %rdi
callq 0x77d0
movq -0x218(%rbp), %rax
movq %rax, -0x300(%rbp)
movq %fs:0x28, %rax
movq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x3eba
movq -0x300(%rbp), %rdi
callq 0x35f0
callq 0x33f0
nop