// File: /workspace/github_c_makefile_star2_O2/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 %r12d, %r12d
orb %al, %cl
jne 0xd29d
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x7d45(%rip), %rsi      # 0x14d47
callq 0xb03c
testq %rax, %rax
je 0xd29d
movq %rax, %r13
leaq 0x7db7(%rip), %rsi      # 0x14dd1
leaq 0x160(%rsp), %rdx
pushq $0x32
popq %rcx
movq %rax, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
leaq 0x7d9e(%rip), %rsi      # 0x14dda
leaq 0x1a0(%rsp), %rdx
pushq $0x40
popq %rcx
movq %r13, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
leaq 0x7d83(%rip), %rsi      # 0x14de1
leaq 0x130(%rsp), %rdx
pushq $0x28
popq %rcx
movq %r13, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
leaq 0x7d6a(%rip), %rsi      # 0x14dea
leaq 0x1e0(%rsp), %rdx
movl $0xc8, %ecx
movq %r13, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
leaq 0x7d4a(%rip), %rsi      # 0x14dee
leaq 0x110(%rsp), %rdx
pushq $0x14
popq %rcx
movq %r13, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
leaq 0x7d2c(%rip), %rsi      # 0x14df2
leaq 0xf0(%rsp), %rdx
pushq $0x14
popq %rcx
movq %r13, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
leaq 0x7cf3(%rip), %rsi      # 0x14ddb
leaq 0xd0(%rsp), %rdx
pushq $0x1e
popq %rcx
movq %r13, %rdi
callq 0xc94d
testl %eax, %eax
je 0xd29d
callq 0x483c
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x71ec(%rip), %xmm0     # 0x14308
cvttsd2si %xmm0, %r13
andq %rcx, %r13
orq %rax, %r13
xorl %r12d, %r12d
leaq 0xd0(%rsp), %rdi
pushq $0x10
popq %rdx
xorl %esi, %esi
callq 0x3570
subq %rax, %r13
setae %al
cmpq $0xe10, %r13            # imm = 0xE10
setae %cl
testb %cl, %al
jne 0xd29d
movq 0x30(%r14), %rdi
movq 0x70(%r14), %rax
leaq 0x1(%rax), %rsi
testq %rax, %rax
cmoveq %rax, %rsi
addq 0x38(%r14), %rsi
callq 0x6892
movq %rax, 0x68(%rsp)
movq %rdx, %r13
leaq 0x160(%rsp), %rdi
callq 0x6875
movq %rax, %rbp
movq %rdx, %r12
leaq 0x1a0(%rsp), %rdi
callq 0x6875
movq %rax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x6875
movq %rax, 0xb0(%rsp)
movq %rdx, 0xb8(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x6875
movq %rax, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x6875
movq %rax, 0x90(%rsp)
movq %rdx, 0x98(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6875
movq %rax, 0x80(%rsp)
movq %rdx, 0x88(%rsp)
movq %r15, %rdi
callq 0x6875
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)
movupd 0xc0(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %rbx, 0x60(%rsp)
movq 0x68(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %r12, %r9
callq 0xd2b2
movl %eax, %r12d
movl %r12d, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq