// File: /workspace/github_c_makefile_star2_O1/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_check_digest_auth
int mg_http_check_digest_auth(struct http_message *hm, const char *auth_domain,
                              FILE *fp) {
  struct mg_str *hdr;
  char username[50], cnonce[64], response[40], uri[200], qop[20], nc[20],
      nonce[30];

  /* Parse "Authorization:" header, fail fast on parse error */
  if (hm == NULL || fp == NULL ||
      (hdr = mg_get_http_header(hm, "Authorization")) == NULL ||
      mg_http_parse_header(hdr, "username", username, sizeof(username)) == 0 ||
      mg_http_parse_header(hdr, "cnonce", cnonce, sizeof(cnonce)) == 0 ||
      mg_http_parse_header(hdr, "response", response, sizeof(response)) == 0 ||
      mg_http_parse_header(hdr, "uri", uri, sizeof(uri)) == 0 ||
      mg_http_parse_header(hdr, "qop", qop, sizeof(qop)) == 0 ||
      mg_http_parse_header(hdr, "nc", nc, sizeof(nc)) == 0 ||
      mg_http_parse_header(hdr, "nonce", nonce, sizeof(nonce)) == 0 ||
      mg_check_nonce(nonce) == 0) {
    return 0;
  }

  /* NOTE(lsm): due to a bug in MSIE, we do not compare URIs */

  return mg_check_digest_auth(
      hm->method,
      mg_mk_str_n(
          hm->uri.p,
          hm->uri.len + (hm->query_string.len ? hm->query_string.len + 1 : 0)),
      mg_mk_str(username), mg_mk_str(cnonce), mg_mk_str(response),
      mg_mk_str(qop), mg_mk_str(nc), mg_mk_str(nonce), mg_mk_str(auth_domain),
      fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
testq %rdi, %rdi
sete %al
testq %rdx, %rdx
sete %cl
xorl %ebp, %ebp
orb %al, %cl
jne 0xe085
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x7f26(%rip), %rsi      # 0x15d43
callq 0xbaa7
testq %rax, %rax
je 0xe085
movq %rax, %r12
leaq 0x7f98(%rip), %rsi      # 0x15dcd
leaq 0x160(%rsp), %rdx
movl $0x32, %ecx
movq %rax, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0x7f7d(%rip), %rsi      # 0x15dd6
leaq 0x1a0(%rsp), %rdx
movl $0x40, %ecx
movq %r12, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0x7f60(%rip), %rsi      # 0x15ddd
leaq 0x130(%rsp), %rdx
movl $0x28, %ecx
movq %r12, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0x7f45(%rip), %rsi      # 0x15de6
leaq 0x1e0(%rsp), %rdx
movl $0xc8, %ecx
movq %r12, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0x7f25(%rip), %rsi      # 0x15dea
leaq 0x110(%rsp), %rdx
movl $0x14, %ecx
movq %r12, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0x7f05(%rip), %rsi      # 0x15dee
leaq 0xf0(%rsp), %rdx
movl $0x14, %ecx
movq %r12, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0x7eca(%rip), %rsi      # 0x15dd7
leaq 0xd0(%rsp), %rdx
movl $0x1e, %ecx
movq %r12, %rdi
callq 0xd707
testl %eax, %eax
je 0xe085
leaq 0xd0(%rsp), %rdi
callq 0xe099
testl %eax, %eax
je 0xe085
movq 0x30(%r14), %rdi
movq 0x70(%r14), %rax
leaq 0x1(%rax), %rsi
testq %rax, %rax
cmoveq %rax, %rsi
addq 0x38(%r14), %rsi
callq 0x6c05
movq %rax, 0x68(%rsp)
movq %rdx, %r13
leaq 0x160(%rsp), %rdi
callq 0x6be8
movq %rax, %rbp
movq %rdx, %r12
leaq 0x1a0(%rsp), %rdi
callq 0x6be8
movq %rax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x6be8
movq %rax, 0xb0(%rsp)
movq %rdx, 0xb8(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x6be8
movq %rax, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x6be8
movq %rax, 0x90(%rsp)
movq %rdx, 0x98(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6be8
movq %rax, 0x80(%rsp)
movq %rdx, 0x88(%rsp)
movq %r15, %rdi
callq 0x6be8
movq %rax, 0x70(%rsp)
movq %rdx, 0x78(%rsp)
movq 0x20(%r14), %rdi
movq 0x28(%r14), %rsi
movups 0x70(%rsp), %xmm0
movups %xmm0, 0x50(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, 0x40(%rsp)
movups 0x90(%rsp), %xmm0
movups %xmm0, 0x30(%rsp)
movups 0xa0(%rsp), %xmm0
movups %xmm0, 0x20(%rsp)
movups 0xb0(%rsp), %xmm0
movups %xmm0, 0x10(%rsp)
movups 0xc0(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, 0x60(%rsp)
movq 0x68(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %r12, %r9
callq 0xe0f0
movl %eax, %ebp
movl %ebp, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq