// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: mg_authorize_digest
int mg_authorize_digest(struct mg_connection *c, FILE *fp) {
  struct connection *conn = MG_CONN_2_CONN(c);
  const char *hdr;
  char line[256], f_user[256], ha1[256], f_domain[256], user[100], nonce[100],
       uri[MAX_REQUEST_SIZE], cnonce[100], resp[100], qop[100], nc[100];

  if (c == NULL || fp == NULL) return 0;
  if ((hdr = mg_get_header(c, "Authorization")) == NULL ||
      mg_strncasecmp(hdr, "Digest ", 7) != 0) return 0;
  if (!mg_parse_header(hdr, "username", user, sizeof(user))) return 0;
  if (!mg_parse_header(hdr, "cnonce", cnonce, sizeof(cnonce))) return 0;
  if (!mg_parse_header(hdr, "response", resp, sizeof(resp))) return 0;
  if (!mg_parse_header(hdr, "uri", uri, sizeof(uri))) return 0;
  if (!mg_parse_header(hdr, "qop", qop, sizeof(qop))) return 0;
  if (!mg_parse_header(hdr, "nc", nc, sizeof(nc))) return 0;
  if (!mg_parse_header(hdr, "nonce", nonce, sizeof(nonce))) return 0;

  while (fgets(line, sizeof(line), fp) != NULL) {
    if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) == 3 &&
        !strcmp(user, f_user) &&
        // NOTE(lsm): due to a bug in MSIE, we do not compare URIs
        !strcmp(conn->server->config_options[AUTH_DOMAIN], f_domain))
      return check_password(c->request_method, ha1, uri,
                            nonce, nc, cnonce, qop, resp);
  }
  return MG_FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x46e0, %rsp           # imm = 0x46E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xb2bbd
cmpq $0x0, -0x18(%rbp)
jne 0xb2bc9
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x10(%rbp), %rdi
leaq 0x10210(%rip), %rsi     # 0xc2de4
callq 0xb0fe0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xb2bfd
movq -0x28(%rbp), %rdi
leaq 0x14086(%rip), %rsi     # 0xc6c74
movl $0x7, %edx
callq 0xb2e40
cmpl $0x0, %eax
je 0xb2c09
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x4a0(%rbp), %rdx
leaq 0xcb83(%rip), %rsi      # 0xbf79e
movl $0x64, %ecx
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2c36
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x4580(%rbp), %rdx
leaq 0x14034(%rip), %rsi     # 0xc6c7c
movl $0x64, %ecx
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2c63
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x45f0(%rbp), %rdx
leaq 0x1400e(%rip), %rsi     # 0xc6c83
movl $0x64, %ecx
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2c90
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x4510(%rbp), %rdx
leaq 0x13fea(%rip), %rsi     # 0xc6c8c
movl $0x4000, %ecx           # imm = 0x4000
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2cbd
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x4660(%rbp), %rdx
leaq 0x13fc1(%rip), %rsi     # 0xc6c90
movl $0x64, %ecx
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2cea
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x46d0(%rbp), %rdx
leaq 0x13f98(%rip), %rsi     # 0xc6c94
movl $0x64, %ecx
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2d17
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
movq -0x28(%rbp), %rdi
leaq -0x510(%rbp), %rdx
leaq 0x13f54(%rip), %rsi     # 0xc6c7d
movl $0x64, %ecx
callq 0xb2ee0
cmpl $0x0, %eax
jne 0xb2d44
movl $0x0, -0x4(%rbp)
jmp 0xb2e27
jmp 0xb2d46
leaq -0x130(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0xd880
cmpq $0x0, %rax
je 0xb2e20
leaq -0x130(%rbp), %rdi
leaq -0x230(%rbp), %rdx
leaq -0x430(%rbp), %rcx
leaq -0x330(%rbp), %r8
leaq 0x13f0f(%rip), %rsi     # 0xc6c97
movb $0x0, %al
callq 0xd130
cmpl $0x3, %eax
jne 0xb2e1b
leaq -0x4a0(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xdab0
cmpl $0x0, %eax
jne 0xb2e1b
movq -0x20(%rbp), %rax
movq 0x2a8(%rax), %rax
movq 0x48(%rax), %rdi
leaq -0x430(%rbp), %rsi
callq 0xdab0
cmpl $0x0, %eax
jne 0xb2e1b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x330(%rbp), %rsi
leaq -0x4510(%rbp), %rdx
leaq -0x510(%rbp), %rcx
leaq -0x46d0(%rbp), %r8
leaq -0x4580(%rbp), %r9
leaq -0x4660(%rbp), %r10
leaq -0x45f0(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xb2f40
movl %eax, -0x4(%rbp)
jmp 0xb2e27
jmp 0xb2d46
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x46e0, %rsp           # imm = 0x46E0
popq %rbp
retq
nopw %cs:(%rax,%rax)