// File: /workspace/github_c_makefile_star2_O3/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 0xdf4d
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x807f(%rip), %rsi      # 0x15d64
callq 0xb896
testq %rax, %rax
je 0xdf4d
movq %rax, %r12
leaq 0x80f1(%rip), %rsi      # 0x15dee
leaq 0x160(%rsp), %rdx
movl $0x32, %ecx
movq %rax, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0x80d6(%rip), %rsi      # 0x15df7
leaq 0x1a0(%rsp), %rdx
movl $0x40, %ecx
movq %r12, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0x80b9(%rip), %rsi      # 0x15dfe
leaq 0x130(%rsp), %rdx
movl $0x28, %ecx
movq %r12, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0x809e(%rip), %rsi      # 0x15e07
leaq 0x1e0(%rsp), %rdx
movl $0xc8, %ecx
movq %r12, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0x807e(%rip), %rsi      # 0x15e0b
leaq 0x110(%rsp), %rdx
movl $0x14, %ecx
movq %r12, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0x805e(%rip), %rsi      # 0x15e0f
leaq 0xf0(%rsp), %rdx
movl $0x14, %ecx
movq %r12, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0x8023(%rip), %rsi      # 0x15df8
leaq 0xd0(%rsp), %rdx
movl $0x1e, %ecx
movq %r12, %rdi
callq 0xd5e0
testl %eax, %eax
je 0xdf4d
leaq 0xd0(%rsp), %rdi
callq 0xdf61
testl %eax, %eax
je 0xdf4d
movq 0x30(%r14), %rdi
movq 0x70(%r14), %rax
leaq 0x1(%rax), %rsi
testq %rax, %rax
cmoveq %rax, %rsi
addq 0x38(%r14), %rsi
callq 0x6b43
movq %rax, 0x68(%rsp)
movq %rdx, %r13
leaq 0x160(%rsp), %rdi
callq 0x6b26
movq %rax, %rbp
movq %rdx, %r12
leaq 0x1a0(%rsp), %rdi
callq 0x6b26
movq %rax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x6b26
movq %rax, 0xb0(%rsp)
movq %rdx, 0xb8(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x6b26
movq %rax, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x6b26
movq %rax, 0x90(%rsp)
movq %rdx, 0x98(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6b26
movq %rax, 0x80(%rsp)
movq %rdx, 0x88(%rsp)
movq %r15, %rdi
callq 0x6b26
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 0xdfb8
movl %eax, %ebp
movl %ebp, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq