// File: /workspace/github_c_makefile_star2_O0/otrtool[P]otrtool/src/main.c
// Function: fetchKeyphrase
void fetchKeyphrase() {
  struct termios ios0, ios1;
  time_t time_ = time(NULL);
  char *date = malloc(9);
  strftime(date, 9, "%Y%m%d", gmtime(&time_));
  
  if (info) {
    free(info);
    info = NULL;
  }
  
  if (opts.email == NULL) {
    if (!interactive) ERROR("Email address not specified");
    opts.email = malloc(51);
    fputs("Enter your eMail-address: ", stderr);
    if (fscanf(ttyfile, "%50s", opts.email) < 1)
      ERROR("Email invalid");
    while (fgetc(ttyfile) != '\n');
  }
  email = strdup(opts.email);

  if (opts.password == NULL) {
    if (!interactive) ERROR("Password not specified");
    opts.password = malloc(51);
    fputs("Enter your password: ", stderr);
    tcgetattr(fileno(ttyfile), &ios0);
    ios1 = ios0;
    ios1.c_lflag &= ~ECHO;
    tcsetattr(fileno(ttyfile), TCSAFLUSH, &ios1);
    if (fscanf(ttyfile, "%50s", opts.password) < 1) {
      tcsetattr(0, TCSAFLUSH, &ios0);
      ERROR("Password invalid");
    }
    tcsetattr(fileno(ttyfile), TCSAFLUSH, &ios0);
    while (fgetc(ttyfile) != '\n');
    fputc('\n', stderr);
  }
  password = strdup(opts.password);
  
  char *bigkey = generateBigkey(date);
  char *request = generateRequest(bigkey, date);
  free(email);
  free(password);
  
  fputs("Trying to contact server...\n", stderr);
  struct MemoryStruct *response = contactServer(request);

  if (response->size == 0 || response->memory == NULL) {
    ERROR("Server sent an empty response, exiting");
  }
  fputs("Server responded.\n", stderr);
  
  // skip initial whitespace
  char *message = response->memory;
  message += strspn(message, " \t\n");
  
  if (isBase64(message) == 0) {
    if (memcmp(message,"MessageToBePrintedInDecoder",27) ==0) {
      fputs("Server sent us this sweet message:\n", stderr);
      quote(message + 27);
    } else {
      fputs("Server sent us this ugly crap:\n", stderr);
      dumpHex(response->memory, response->size);
    }
    ERROR("Server response is unuseable, exiting");
  }
  
  int info_len;
  char *info_crypted = base64Decode(message, &info_len);
  
  if (info_len % 8 != 0) {
    fputs("Length of response must be a multiple of 8.", stderr);
    dumpHex(info_crypted, info_len);
    ERROR("Server response is unuseable, exiting");
  }
  
  info = decryptResponse(info_crypted, info_len, bigkey);
  
  keyphrase = queryGetParam(info, "HP");
  if (keyphrase == NULL)
    ERROR("Response lacks keyphrase");
  
  if (strlen(keyphrase) != 56)
    ERROR("Keyphrase has wrong length");
  
  fprintf(stderr, "Keyphrase: %s\n", keyphrase);
  keycache_put(queryGetParam(header, "FH"), keyphrase);
  
  free(date);
  free(bigkey);
  free(request);
  free(response->memory);
  free(response);
  free(info_crypted);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
xorl %eax, %eax
movl %eax, %edi
callq 0x21d0
movq %rax, -0x80(%rbp)
movl $0x9, %edi
callq 0x2300
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x21a0
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl $0x9, %esi
leaq 0x3f08(%rip), %rdx      # 0xa72e
callq 0x2160
cmpq $0x0, 0x6ced(%rip)      # 0xd520
je 0x684c
movq 0x6ce4(%rip), %rdi      # 0xd520
callq 0x2280
movq $0x0, 0x6cd4(%rip) # 0xd520
cmpq $0x0, 0x6a5c(%rip)      # 0xd2b0
jne 0x696a
cmpl $0x0, 0x69ff(%rip)      # 0xd260
jne 0x68b7
jmp 0x6865
movq 0x676c(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3fa0(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x6754(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3ea7(%rip), %rsi      # 0xa735
movb $0x0, %al
callq 0x2330
movq 0x673c(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3f70(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movl $0x33, %edi
callq 0x2300
movq %rax, 0x69e8(%rip)      # 0xd2b0
movq 0x6709(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3e78(%rip), %rdi      # 0xa751
callq 0x2240
movq 0x6c43(%rip), %rdi      # 0xd528
movq 0x69c4(%rip), %rdx      # 0xd2b0
leaq 0x3e79(%rip), %rsi      # 0xa76c
movb $0x0, %al
callq 0x2450
cmpl $0x1, %eax
jge 0x6953
jmp 0x6901
movq 0x66d0(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3f04(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x66b8(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3e47(%rip), %rsi      # 0xa771
movb $0x0, %al
callq 0x2330
movq 0x66a0(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3ed4(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
jmp 0x6955
movq 0x6bcc(%rip), %rdi      # 0xd528
callq 0x23a0
cmpl $0xa, %eax
je 0x6968
jmp 0x6955
jmp 0x696a
movq 0x693f(%rip), %rdi      # 0xd2b0
callq 0x2440
movq %rax, 0x696b(%rip)      # 0xd2e8
cmpq $0x0, 0x6933(%rip)      # 0xd2b8
jne 0x6b23
cmpl $0x0, 0x68ce(%rip)      # 0xd260
jne 0x69e8
jmp 0x6996
movq 0x663b(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3e6f(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x6623(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3dc0(%rip), %rsi      # 0xa77f
movb $0x0, %al
callq 0x2330
movq 0x660b(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3e3f(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movl $0x33, %edi
callq 0x2300
movq %rax, 0x68bf(%rip)      # 0xd2b8
movq 0x65d8(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3d8c(%rip), %rdi      # 0xa796
callq 0x2240
movq 0x6b12(%rip), %rdi      # 0xd528
callq 0x2200
movl %eax, %edi
leaq -0x3c(%rbp), %rsi
callq 0x2230
leaq -0x78(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0x3c, %edx
callq 0x2170
movl -0x6c(%rbp), %eax
andl $-0x9, %eax
movl %eax, -0x6c(%rbp)
movq 0x6ae0(%rip), %rdi      # 0xd528
callq 0x2200
movl %eax, %edi
movl $0x2, %esi
leaq -0x78(%rbp), %rdx
callq 0x22d0
movq 0x6ac4(%rip), %rdi      # 0xd528
movq 0x684d(%rip), %rdx      # 0xd2b8
leaq 0x3cfa(%rip), %rsi      # 0xa76c
movb $0x0, %al
callq 0x2450
cmpl $0x1, %eax
jge 0x6ae0
xorl %edi, %edi
movl $0x2, %esi
leaq -0x3c(%rbp), %rdx
callq 0x22d0
movq 0x6543(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3d77(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x652b(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3cf5(%rip), %rsi      # 0xa7ac
movb $0x0, %al
callq 0x2330
movq 0x6513(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3d47(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq 0x6a41(%rip), %rdi      # 0xd528
callq 0x2200
movl %eax, %edi
movl $0x2, %esi
leaq -0x3c(%rbp), %rdx
callq 0x22d0
movq 0x6a25(%rip), %rdi      # 0xd528
callq 0x23a0
cmpl $0xa, %eax
je 0x6b0f
jmp 0x6afc
movq 0x64c2(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x22c0
movq 0x678e(%rip), %rdi      # 0xd2b8
callq 0x2440
movq %rax, 0x67ba(%rip)      # 0xd2f0
movq -0x88(%rbp), %rdi
callq 0x57e0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x59d0
movq %rax, -0x98(%rbp)
movq 0x677e(%rip), %rdi      # 0xd2e8
callq 0x2280
movq 0x677a(%rip), %rdi      # 0xd2f0
callq 0x2280
movq 0x6456(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3c31(%rip), %rdi      # 0xa7bd
callq 0x2240
movq -0x98(%rbp), %rdi
callq 0x5c10
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x6bbf
movq -0xa0(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x6c13
jmp 0x6bc1
movq 0x6410(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3c44(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x63f8(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3bf0(%rip), %rsi      # 0xa7da
movb $0x0, %al
callq 0x2330
movq 0x63e0(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3c14(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq 0x63be(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3bdd(%rip), %rdi      # 0xa801
callq 0x2240
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
leaq 0x3bcc(%rip), %rsi      # 0xa814
callq 0x20b0
addq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x4990
cmpl $0x0, %eax
jne 0x6d3b
movq -0xa8(%rbp), %rdi
leaq 0x3b9a(%rip), %rsi      # 0xa818
movl $0x1b, %edx
callq 0x20d0
cmpl $0x0, %eax
jne 0x6cb5
movq 0x6344(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3b96(%rip), %rdi      # 0xa834
callq 0x2240
movq -0xa8(%rbp), %rdi
addq $0x1b, %rdi
callq 0x4b20
jmp 0x6ce7
movq 0x631c(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3b92(%rip), %rdi      # 0xa858
callq 0x2240
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %esi
callq 0x4d40
jmp 0x6ce9
movq 0x62e8(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3b1c(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x62d0(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3b66(%rip), %rsi      # 0xa878
movb $0x0, %al
callq 0x2330
movq 0x62b8(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3aec(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq -0xa8(%rbp), %rdi
leaq -0xac(%rbp), %rsi
callq 0x47f0
movq %rax, -0xb8(%rbp)
movl -0xac(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x6de2
movq 0x6269(%rip), %rax      # 0xcfd8
movq (%rax), %rsi
leaq 0x3b25(%rip), %rdi      # 0xa89e
callq 0x2240
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %esi
callq 0x4d40
movq 0x6241(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3a75(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x6229(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3abf(%rip), %rsi      # 0xa878
movb $0x0, %al
callq 0x2330
movq 0x6211(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3a45(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %esi
movq -0x90(%rbp), %rdx
callq 0x5f90
movq %rax, 0x671e(%rip)      # 0xd520
movq 0x6717(%rip), %rdi      # 0xd520
leaq 0x3aba(%rip), %rsi      # 0xa8ca
callq 0x49e0
movq %rax, 0x6714(%rip)      # 0xd530
cmpq $0x0, 0x670c(%rip)      # 0xd530
jne 0x6e7a
jmp 0x6e28
movq 0x61a9(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x39dd(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x6191(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3a7c(%rip), %rsi      # 0xa8cd
movb $0x0, %al
callq 0x2330
movq 0x6179(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x39ad(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq 0x66af(%rip), %rdi      # 0xd530
callq 0x20c0
cmpq $0x38, %rax
je 0x6ee0
jmp 0x6e8e
movq 0x6143(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3977(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x612b(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3a2f(%rip), %rsi      # 0xa8e6
movb $0x0, %al
callq 0x2330
movq 0x6113(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x3947(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq 0x60f1(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
movq 0x663f(%rip), %rdx      # 0xd530
leaq 0x3a09(%rip), %rsi      # 0xa901
movb $0x0, %al
callq 0x2330
movq 0x63f2(%rip), %rdi      # 0xd2f8
leaq 0x3a03(%rip), %rsi      # 0xa910
callq 0x49e0
movq %rax, %rdi
movq 0x6614(%rip), %rsi      # 0xd530
callq 0x6680
movq -0x88(%rbp), %rdi
callq 0x2280
movq -0x90(%rbp), %rdi
callq 0x2280
movq -0x98(%rbp), %rdi
callq 0x2280
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
callq 0x2280
movq -0xa0(%rbp), %rdi
callq 0x2280
movq -0xb8(%rbp), %rdi
callq 0x2280
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)