// File: /workspace/github_c_makefile_star2_O0/otrtool[P]otrtool/src/main.c
// Function: getHeader
char * getHeader() {
  unsigned char *header = malloc(sizeof(char) * 513);
  if (fread(header, 512, 1, file) < 1 && !feof(file))
    PERROR("Error reading file");
  if (feof(file))
    ERROR("Error: unexpected end of file");
  unsigned char hardKey[] = {
      0xEF, 0x3A, 0xB2, 0x9C, 0xD1, 0x9F, 0x0C, 0xAC,
      0x57, 0x59, 0xC7, 0xAB, 0xD1, 0x2C, 0xC9, 0x2B,
      0xA3, 0xFE, 0x0A, 0xFE, 0xBF, 0x96, 0x0D, 0x63,
      0xFE, 0xBD, 0x0F, 0x45};
  bf_state_t blowfish;
  bf_init(&blowfish, hardKey, 28);
  bf_ecb_decrypt(&blowfish, header, 512);
  header[512] = 0;
  
  char *padding = strstr((char*)header, "&PD=");
  if (padding == NULL)
    ERROR("Corrupted header: could not find padding");
  *padding = 0;
  
  if (opts.verbosity >= VERB_DEBUG) {
    fputs("\nDumping decrypted header:\n", stderr);
    dumpQuerystring((char*)header);
    fputs("\n", stderr);
  }
  return (char*)header;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1080, %rsp           # imm = 0x1080
movl $0x201, %edi            # imm = 0x201
callq 0x2300
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq 0x7d1c(%rip), %rcx      # 0xd2e0
movl $0x200, %esi            # imm = 0x200
movl $0x1, %edx
callq 0x2360
cmpq $0x1, %rax
jae 0x5647
movq 0x7d00(%rip), %rdi      # 0xd2e0
callq 0x2370
cmpl $0x0, %eax
jne 0x5647
jmp 0x55ec
movq 0x79e5(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x5219(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x79cd(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x4d96(%rip), %rsi      # 0xa3ab
movb $0x0, %al
callq 0x2330
movq 0x79b5(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x517c(%rip), %rsi      # 0xa7a9
movb $0x0, %al
callq 0x2330
xorl %eax, %eax
movl %eax, %edi
callq 0x2180
movl $0x1, %edi
callq 0x2290
movq 0x7c92(%rip), %rdi      # 0xd2e0
callq 0x2370
cmpl $0x0, %eax
je 0x56ac
jmp 0x565a
movq 0x7977(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x51ab(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x795f(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x4d3b(%rip), %rsi      # 0xa3be
movb $0x0, %al
callq 0x2330
movq 0x7947(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x517b(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq 0x4b9d(%rip), %rax      # 0xa250
movq %rax, -0x30(%rbp)
movq 0x4b9a(%rip), %rax      # 0xa258
movq %rax, -0x28(%rbp)
movq 0x4b97(%rip), %rax      # 0xa260
movq %rax, -0x20(%rbp)
movl 0x4b95(%rip), %eax      # 0xa268
movl %eax, -0x18(%rbp)
leaq -0x30(%rbp), %rsi
leaq -0x1078(%rbp), %rdi
movl $0x1c, %edx
callq 0x3a50
movq -0x8(%rbp), %rsi
leaq -0x1078(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
callq 0x3db0
movq -0x8(%rbp), %rax
movb $0x0, 0x200(%rax)
movq -0x8(%rbp), %rdi
leaq 0x4cc6(%rip), %rsi      # 0xa3dc
callq 0x2060
movq %rax, -0x1080(%rbp)
cmpq $0x0, -0x1080(%rbp)
jne 0x5780
jmp 0x572e
movq 0x78a3(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x50d7(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x788b(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x4c8a(%rip), %rsi      # 0xa3e1
movb $0x0, %al
callq 0x2330
movq 0x7873(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x50a7(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq -0x1080(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x1, 0x7b13(%rip)      # 0xd2a4
jb 0x57c8
movq 0x783e(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x4c66(%rip), %rdi      # 0xa40a
callq 0x2240
movq -0x8(%rbp), %rdi
callq 0x4c20
movq 0x781f(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x5053(%rip), %rdi      # 0xa816
callq 0x2240
movq -0x8(%rbp), %rax
addq $0x1080, %rsp           # imm = 0x1080
popq %rbp
retq
nopw %cs:(%rax,%rax)