// File: /workspace/github_cpp_makefile_star2_O1/Vanuan[P]pocketbook_free_swupdate/PocketBookUpdate.cpp
// Function: PocketBookUpdate::extract(char const*)
void PocketBookUpdate::extract(const char * outputDir)
{
  struct stat st;
  if(stat(outputDir,&st) != 0)
  {
    cout << "Directory " << outputDir << " doesn't exist" << endl;
    return;
  }
  ifstream infile(mFilename.c_str(), ifstream::binary);
  map<string, FWPart>::const_iterator it;
  for ( it=parts.begin(); it != parts.end(); it++ )
  {
    infile.seekg(it->second.offset);
    string outputFilename = string(outputDir) + string("/") + it->first;
    ofstream outfile(outputFilename.c_str(), ofstream::binary);
    long unsigned int size = it->second.size;
    char*buf = new char[size];
    infile.read(buf, size);
    outfile.write(buf, size);
    delete[] buf;
    outfile.close();
  }
  infile.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x518, %rsp            # imm = 0x518
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x488(%rsp), %rsi
movq %rbx, %rdi
callq 0x21a0
testl %eax, %eax
je 0x2cb2
movq 0x3362(%rip), %r14      # 0x5fd8
leaq 0x13ec(%rip), %rsi      # 0x4069
movl $0xa, %edx
movq %r14, %rdi
callq 0x2230
testq %rbx, %rbx
je 0x2f96
movq %rbx, %rdi
callq 0x20f0
movq 0x3336(%rip), %rdi      # 0x5fd8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x2fae
movq %rbx, 0x78(%rsp)
movq 0x18(%r14), %rsi
leaq 0x280(%rsp), %rdi
movl $0x4, %edx
callq 0x2370
movq 0x80(%r14), %r15
addq $0x70, %r14
cmpq %r14, %r15
je 0x2f6a
leaq 0x40(%rsp), %r12
movq 0x32e3(%rip), %rax      # 0x5fd0
movq (%rax), %rbx
movq 0x18(%rax), %rax
movq %rax, 0x70(%rsp)
leaq 0x80(%rsp), %r13
movl 0x48(%r15), %esi
leaq 0x280(%rsp), %rdi
xorl %edx, %edx
callq 0x2280
leaq 0x30(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x31d2
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x1345(%rip), %rsi      # 0x4083
leaq 0x133f(%rip), %rdx      # 0x4084
callq 0x33d8
movq 0x30(%rsp), %rcx
movl $0xf, %esi
cmpq %r12, %rcx
je 0x2d5e
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %r8
movq 0x18(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x2d8c
movl $0xf, %esi
leaq 0x20(%rsp), %rdi
cmpq %rdi, 0x10(%rsp)
je 0x2d87
movq 0x20(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x2d9d
movq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x20c0
jmp 0x2dab
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
leaq 0x90(%rsp), %rsi
movq %rsi, 0x80(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2ddc
movq %rdx, 0x80(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x90(%rsp)
jmp 0x2de2
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x88(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
movq %r13, %rdi
callq 0x20c0
leaq 0x60(%rsp), %rsi
movq %rsi, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2e3a
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x2e40
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2e7d
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2e99
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x2eb0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x50(%rsp), %rsi
movq %r13, %rdi
movl $0x4, %edx
callq 0x2210
movl 0x4c(%r15), %r12d
movq %r12, %rdi
callq 0x2030
movq %rax, %rbp
leaq 0x280(%rsp), %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x2270
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x22a0
movq %rbp, %rdi
callq 0x2290
movq %r13, %rdi
callq 0x22c0
movq %rbx, 0x80(%rsp)
movq -0x18(%rbx), %rax
movq 0x70(%rsp), %rcx
movq %rcx, 0x80(%rsp,%rax)
leaq 0x88(%rsp), %rdi
callq 0x2180
leaq 0x178(%rsp), %rdi
callq 0x20d0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
leaq 0x40(%rsp), %r12
je 0x2f56
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %r15, %rdi
callq 0x2240
movq %rax, %r15
cmpq %r14, %rax
jne 0x2d01
leaq 0x280(%rsp), %rdi
callq 0x2080
leaq 0x280(%rsp), %rdi
callq 0x20a0
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2330
leaq 0x10bf(%rip), %rsi      # 0x4074
movl $0xe, %edx
movq %r14, %rdi
callq 0x2230
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2120
jmp 0x2ffe
jmp 0x2ffe
movq %rax, %rbx
jmp 0x309b
movq %rax, %rbx
jmp 0x3054
movq %rax, %rbx
jmp 0x3038
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x3038
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3054
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x309b
movq 0x40(%rsp), %rsi
jmp 0x3093
movq %rax, %rbx
jmp 0x307f
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x22e0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x309b
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x280(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2350