// File: /workspace/github_c_makefile_star2_O2/stfwi[P]duktape-cc/build/duktape/mod/ext/app_attachment/app_attachment.cc
// Function: main
int main(int argc, const char** argv)
{
  using namespace std;
  auto args = deque<string>();
  for(int i=1; (i<argc) && (argv[i]); ++i) args.push_back(argv[i]);
  const auto verbose = (args.size() > 0) && (args.front() == "-v");
  if(verbose) args.pop_front();
  const auto binary_path = ((args.size() >= 2) && (args[0] == "-p")) ? string(args[1]) : string();
  const auto script_path = ((args.size() == 4) && (args[2] == "-a")) ? string(args[3]) : string();
  auto script_contents = string();
  if(binary_path.empty() || (args.size() & 0x1)) {
    cerr << "Expected -p <path-to-binary> [-a <path-to-attachment>]\n";
    return 1;
  }
  if(!script_path.empty()) {
    std::ifstream fis(script_path.c_str(), std::ios::in|std::ios::binary);
    if(!fis.good()) { cerr << "Failed to open data file: '" << script_path << "'\n"; return 1; }
    script_contents.assign((std::istreambuf_iterator<char>(fis)), std::istreambuf_iterator<char>());
    if(!fis.good() && !fis.eof()) { cerr << "Failed to read data: '" << script_path << "'\n"; return 1; }
    fis.close();
  }
  return sw::util::detail::basic_executable_attachment<>::patch_application(binary_path, verbose, move(script_contents));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rsi, %rbx
movl %edi, %r15d
xorps %xmm0, %xmm0
leaq -0x100(%rbp), %r14
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
movq %r14, %rdi
callq 0x3378
movslq %r15d, %r13
pushq $0x1
popq %r12
leaq -0x328(%rbp), %r15
cmpq %r13, %r12
jge 0x24c3
movq (%rbx,%r12,8), %rsi
testq %rsi, %rsi
je 0x24c3
movq %r15, %rdi
leaq -0x88(%rbp), %rdx
callq 0x2090
movq %r14, %rdi
movq %r15, %rsi
callq 0x36ce
movq %r15, %rdi
callq 0x20b0
incq %r12
jmp 0x248e
leaq -0x100(%rbp), %rdi
callq 0x2818
testq %rax, %rax
je 0x24fc
movq -0xf0(%rbp), %rdi
leaq 0x2b22(%rip), %rsi      # 0x5004
callq 0x282d
testb %al, %al
je 0x24fc
leaq -0x100(%rbp), %rdi
callq 0x283e
movb $0x1, %r14b
jmp 0x24ff
xorl %r14d, %r14d
leaq -0x100(%rbp), %rdi
callq 0x2818
cmpq $0x2, %rax
jb 0x2551
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x396e
leaq 0x2ade(%rip), %rsi      # 0x5007
movq %rax, %rdi
callq 0x282d
testb %al, %al
je 0x2551
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x396e
leaq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
jmp 0x2561
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x100(%rbp), %rdi
callq 0x2818
cmpq $0x4, %rax
jne 0x25b1
leaq -0xf0(%rbp), %rbx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x396e
leaq 0x2a7e(%rip), %rsi      # 0x500a
movq %rax, %rdi
callq 0x282d
testb %al, %al
je 0x25b1
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x396e
leaq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
jmp 0x25c1
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
andq $0x0, -0x8(%r15)
movb $0x0, (%r15)
cmpq $0x0, -0x80(%rbp)
je 0x2625
leaq -0x100(%rbp), %rdi
callq 0x2818
testb $0x1, %al
jne 0x2625
cmpq $0x0, -0x60(%rbp)
je 0x26d5
movq -0x68(%rbp), %rsi
leaq -0x328(%rbp), %rdi
pushq $0xc
popq %rdx
callq 0x22d0
movq -0x328(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x308(%rbp,%rax)
je 0x2640
leaq 0x2a22(%rip), %rsi      # 0x5045
jmp 0x2693
movq 0x59c4(%rip), %rdi      # 0x7ff0
leaq 0x29da(%rip), %rsi      # 0x500d
callq 0x2160
pushq $0x1
popq %rbx
jmp 0x275d
movq -0x240(%rbp,%rax), %rsi
leaq -0x48(%rbp), %rdi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
movl %edx, %r8d
callq 0x2878
movq -0x328(%rbp), %rax
movq -0x18(%rax), %rax
movl -0x308(%rbp,%rax), %eax
testl %eax, %eax
sete %cl
andl $0x2, %eax
shrl %eax
orb %cl, %al
je 0x268c
leaq -0x328(%rbp), %rdi
callq 0x2040
xorl %ebx, %ebx
movb $0x1, %r12b
jmp 0x26c0
leaq 0x29d1(%rip), %rsi      # 0x5064
movq 0x5956(%rip), %rdi      # 0x7ff0
callq 0x2160
leaq -0x68(%rbp), %rsi
movq %rax, %rdi
callq 0x2130
leaq 0x29af(%rip), %rsi      # 0x5061
movq %rax, %rdi
callq 0x2160
pushq $0x1
popq %rbx
xorl %r12d, %r12d
leaq -0x328(%rbp), %rdi
callq 0x2050
testb %r12b, %r12b
je 0x275d
leaq -0x120(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x21f0
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
movq -0x48(%rbp), %rcx
cmpq %r15, %rcx
je 0x2710
movq %rcx, -0xa8(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x2717
movups (%r15), %xmm0
movups %xmm0, (%rax)
movq -0x40(%rbp), %rax
leaq -0xa8(%rbp), %rdx
movq %rax, 0x8(%rdx)
movq %r15, -0x48(%rbp)
andq $0x0, -0x40(%rbp)
movb $0x0, -0x38(%rbp)
movzbl %r14b, %esi
leaq -0x120(%rbp), %rdi
callq 0x28b0
movl %eax, %ebx
leaq -0xa8(%rbp), %rdi
callq 0x20b0
leaq -0x120(%rbp), %rdi
callq 0x20b0
leaq -0x48(%rbp), %rdi
callq 0x20b0
leaq -0x68(%rbp), %rdi
callq 0x20b0
leaq -0x88(%rbp), %rdi
callq 0x20b0
leaq -0x100(%rbp), %rdi
callq 0x3306
movl %ebx, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x27d2
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x20b0
leaq -0x120(%rbp), %rdi
callq 0x20b0
jmp 0x27d5
movq %rax, %rbx
jmp 0x27e7
jmp 0x27f0
movq %rax, %rbx
leaq -0x328(%rbp), %rdi
callq 0x2050
jmp 0x27d5
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20b0
leaq -0x68(%rbp), %rdi
callq 0x20b0
leaq -0x88(%rbp), %rdi
jmp 0x27ff
movq %rax, %rbx
jmp 0x2804
movq %rax, %rbx
leaq -0x328(%rbp), %rdi
callq 0x20b0
leaq -0x100(%rbp), %rdi
callq 0x3306
movq %rbx, %rdi
callq 0x22b0