// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10040, %rsp          # imm = 0x10040
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x10018(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x5470
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movq (%rax), %rax
movq %rax, -0x10020(%rbp)
cmpq -0x10018(%rbp), %rax
jae 0x7ade
movq -0x10020(%rbp), %rdi
movq -0x10018(%rbp), %rsi
callq 0x5050
movq -0x10018(%rbp), %rax
subq -0x10020(%rbp), %rax
cmpq $0x10000, %rax          # imm = 0x10000
jae 0x7838
movq -0x10018(%rbp), %rax
subq -0x10020(%rbp), %rax
movq %rax, -0x10038(%rbp)
jmp 0x7846
movl $0x10000, %eax          # imm = 0x10000
movq %rax, -0x10038(%rbp)
jmp 0x7846
movq -0x10038(%rbp), %rax
movq %rax, -0x10028(%rbp)
leaq -0x10010(%rbp), %rdi
movq -0x10028(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rcx
movl $0x1, %esi
callq 0x2360
cmpq -0x10028(%rbp), %rax
jae 0x794a
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x2370
cmpl $0x0, %eax
je 0x78ed
jmp 0x789b
movq 0x5736(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x2f6a(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x571e(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x319e(%rip), %rsi      # 0xaa62
movb $0x0, %al
callq 0x2330
movq 0x5706(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x2f3a(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
jmp 0x78ef
movq 0x56e2(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x2f16(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x56ca(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3162(%rip), %rsi      # 0xaa7a
movb $0x0, %al
callq 0x2330
movq 0x56b2(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x2e79(%rip), %rsi      # 0xa7a9
movb $0x0, %al
callq 0x2330
xorl %eax, %eax
movl %eax, %edi
callq 0x2180
movl $0x1, %edi
callq 0x2290
movq -0x10020(%rbp), %rcx
addq -0x10028(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
callq 0x5520
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x5470
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rdi
leaq -0x10010(%rbp), %rsi
movq -0x10028(%rbp), %rdx
callq 0x7390
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x28, %rdi
callq 0x5520
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rdi
leaq -0x10010(%rbp), %rsi
movq -0x10028(%rbp), %rdx
movq -0x10028(%rbp), %rax
andq $0x7, %rax
subq %rax, %rdx
callq 0x3db0
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x5470
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rdi
leaq -0x10010(%rbp), %rsi
movq -0x10028(%rbp), %rdx
callq 0x7390
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x48, %rdi
callq 0x5520
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0x5470
leaq -0x10010(%rbp), %rdi
movq -0x10028(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rcx
movl $0x1, %esi
callq 0x2470
movq %rax, -0x10030(%rbp)
movq -0x10030(%rbp), %rax
cmpq -0x10028(%rbp), %rax
je 0x7abc
jmp 0x7a61
movq 0x5570(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x2da4(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x5558(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3009(%rip), %rsi      # 0xaa93
movb $0x0, %al
callq 0x2330
movq 0x5540(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x2d07(%rip), %rsi      # 0xa7a9
movb $0x0, %al
callq 0x2330
xorl %eax, %eax
movl %eax, %edi
callq 0x2180
movl $0x1, %edi
callq 0x2290
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x68, %rdi
callq 0x5520
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x5470
jmp 0x77d6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
callq 0x5520
xorl %eax, %eax
addq $0x10040, %rsp          # imm = 0x10040
popq %rbp
retq
nopl (%rax)