// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x13828
cmpq $0x0, -0x48(%rbp)
je 0x13828
movq -0x38(%rbp), %rdi
leaq 0xc5d2(%rip), %rsi      # 0x1fce3
callq 0x10830
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0x90(%rbp), %rdx
leaq 0xc637(%rip), %rsi      # 0x1fd6d
movl $0x32, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
leaq 0xc61b(%rip), %rsi      # 0x1fd76
movl $0x40, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0x100(%rbp), %rdx
leaq 0xc5fd(%rip), %rsi      # 0x1fd7d
movl $0x28, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0x1d0(%rbp), %rdx
leaq 0xc5e1(%rip), %rsi      # 0x1fd86
movl $0xc8, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0x1f0(%rbp), %rdx
leaq 0xc5c4(%rip), %rsi      # 0x1fd8a
movl $0x14, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0x210(%rbp), %rdx
leaq 0xc5a7(%rip), %rsi      # 0x1fd8e
movl $0x14, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
movq -0x50(%rbp), %rdi
leaq -0x230(%rbp), %rdx
leaq 0xc56f(%rip), %rsi      # 0x1fd77
movl $0x1e, %ecx
callq 0x12c00
cmpl $0x0, %eax
je 0x13828
leaq -0x230(%rbp), %rdi
callq 0x13a50
cmpl $0x0, %eax
jne 0x13834
movl $0x0, -0x2c(%rbp)
jmp 0x13a36
movq -0x38(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x2c8(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x2c0(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x2b8(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x13881
movq -0x38(%rbp), %rax
movq 0x70(%rax), %rax
addq $0x1, %rax
movq %rax, -0x2d0(%rbp)
jmp 0x1388c
xorl %eax, %eax
movq %rax, -0x2d0(%rbp)
jmp 0x1388c
movq -0x2c0(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
movq -0x2d0(%rbp), %rax
addq %rax, %rsi
callq 0x8aa0
movq %rax, -0x240(%rbp)
movq %rdx, -0x238(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8a60
movq %rax, -0x250(%rbp)
movq %rdx, -0x248(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8a60
movq %rax, -0x260(%rbp)
movq %rdx, -0x258(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x8a60
movq %rax, -0x270(%rbp)
movq %rdx, -0x268(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x8a60
movq %rax, -0x280(%rbp)
movq %rdx, -0x278(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x8a60
movq %rax, -0x290(%rbp)
movq %rdx, -0x288(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x8a60
movq %rax, -0x2a0(%rbp)
movq %rdx, -0x298(%rbp)
movq -0x40(%rbp), %rdi
callq 0x8a60
movq -0x2c8(%rbp), %rcx
movq %rax, -0x2b0(%rbp)
movq %rdx, -0x2a8(%rbp)
movq -0x48(%rbp), %rax
movq (%rcx), %rdi
movq 0x8(%rcx), %rsi
movq -0x240(%rbp), %rdx
movq -0x238(%rbp), %rcx
movq -0x250(%rbp), %r8
movq -0x248(%rbp), %r9
leaq -0x260(%rbp), %r12
leaq -0x270(%rbp), %r15
leaq -0x280(%rbp), %r14
leaq -0x290(%rbp), %rbx
leaq -0x2a0(%rbp), %r11
leaq -0x2b0(%rbp), %r10
movq (%r12), %r13
movq %r13, (%rsp)
movq 0x8(%r12), %r12
movq %r12, 0x8(%rsp)
movq (%r15), %r12
movq %r12, 0x10(%rsp)
movq 0x8(%r15), %r15
movq %r15, 0x18(%rsp)
movq (%r14), %r15
movq %r15, 0x20(%rsp)
movq 0x8(%r14), %r14
movq %r14, 0x28(%rsp)
movq (%rbx), %r14
movq %r14, 0x30(%rsp)
movq 0x8(%rbx), %rbx
movq %rbx, 0x38(%rsp)
movq (%r11), %rbx
movq %rbx, 0x40(%rsp)
movq 0x8(%r11), %r11
movq %r11, 0x48(%rsp)
movq (%r10), %r11
movq %r11, 0x50(%rsp)
movq 0x8(%r10), %r10
movq %r10, 0x58(%rsp)
movq %rax, 0x60(%rsp)
callq 0x13ae0
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)