// File: /workspace/github_c_makefile_star2_O1/otrtool[P]otrtool/src/main.c
// Function: decryptFileWorker
void *decryptFileWorker(void *w_) {
  struct worker_info *w = w_;
  char buffer[65536];
  unsigned long long length = w->length;
  unsigned long long position;
  size_t readsize, writesize;

  waitSemaphore(&w->read_sema);
  while ((position = *w->pposition) < length) {
    showProgress(position, length);
    readsize = MIN(length - position, sizeof(buffer));
    if (fread(buffer, 1, readsize, w->file) < readsize) {
      if (feof(w->file))
        ERROR("Input file is too short");
      PERROR("Error reading input file");
    }
    *w->pposition = position + readsize;
    postSemaphore(&w->next->read_sema);

    waitSemaphore(&w->ivfy_sema);
    verifyFile_data(w->vfy_inp, buffer, readsize);
    postSemaphore(&w->next->ivfy_sema);

    /* If the payload length is not a multiple of eight,
     * the last few bytes are stored unencrypted */
    bf_ecb_decrypt(w->blowfishp, buffer, readsize - readsize % 8);

    waitSemaphore(&w->ovfy_sema);
    verifyFile_data(w->vfy_outp, buffer, readsize);
    postSemaphore(&w->next->ovfy_sema);

    waitSemaphore(&w->write_sema);
    writesize = fwrite(buffer, 1, readsize, w->destfile);
    if (writesize != readsize)
      PERROR("Error writing to destination file");
    postSemaphore(&w->next->write_sema);

    waitSemaphore(&w->read_sema);
  }
  postSemaphore(&w->next->read_sema);

  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10028, %rsp          # imm = 0x10028
movq %rdi, %rbx
movq 0x88(%rdi), %r13
leaq 0x8(%rdi), %r15
movq %r15, %rdi
callq 0x50fc
movq 0x90(%rbx), %rax
movq (%rax), %rbp
cmpq %r13, %rbp
jae 0x61fa
leaq 0x28(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x48(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x68(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %r12
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4f42
movq %r13, %r14
subq %rbp, %r14
movl $0x10000, %eax          # imm = 0x10000
cmpq %rax, %r14
cmovaeq %rax, %r14
movq 0x98(%rbx), %rcx
movl $0x1, %esi
movq %r12, %rdi
movq %r14, %rdx
callq 0x2360
cmpq %r14, %rax
jb 0x621a
addq %r14, %rbp
movq 0x90(%rbx), %rax
movq %rbp, (%rax)
movq (%rbx), %rdi
addq $0x8, %rdi
callq 0x512b
movq 0x18(%rsp), %rdi
callq 0x50fc
movq 0xa8(%rbx), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x39ff
movq (%rbx), %rdi
addq $0x28, %rdi
callq 0x512b
movq 0xb8(%rbx), %rdi
movl %r14d, %edx
andl $0x1fff8, %edx          # imm = 0x1FFF8
movq %r12, %rsi
callq 0x46a7
movq 0x10(%rsp), %rdi
callq 0x50fc
movq 0xb0(%rbx), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x39ff
movq (%rbx), %rdi
addq $0x48, %rdi
callq 0x512b
movq 0x8(%rsp), %rdi
callq 0x50fc
movq 0xa0(%rbx), %rcx
movl $0x1, %esi
movq %r12, %rdi
movq %r14, %rdx
callq 0x2470
cmpq %r14, %rax
jne 0x6248
movq (%rbx), %rdi
addq $0x68, %rdi
callq 0x512b
movq %r15, %rdi
callq 0x50fc
movq 0x90(%rbx), %rax
movq (%rax), %rbp
cmpq %r13, %rbp
jb 0x60ef
movq (%rbx), %rdi
addq $0x8, %rdi
callq 0x512b
xorl %eax, %eax
addq $0x10028, %rsp          # imm = 0x10028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x98(%rbx), %rdi
callq 0x2370
movl %eax, %ebx
movq 0x5da9(%rip), %r14      # 0xbfd8
movq (%r14), %rsi
movl $0xa, %edi
callq 0x22c0
movq (%r14), %rdi
testl %ebx, %ebx
jne 0x624d
callq 0x3698
callq 0x3616
callq 0x3668