// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_http_is_authorized
static int mg_http_is_authorized(struct http_message *hm, struct mg_str path,
                                 int is_directory, const char *domain,
                                 const char *passwords_file,
                                 int is_global_pass_file) {
  char buf[MG_MAX_PATH];
  const char *p;
  FILE *fp;
  int authorized = 1;

  if (domain != NULL && passwords_file != NULL) {
    if (is_global_pass_file) {
      fp = mg_fopen(passwords_file, "r");
    } else if (is_directory) {
      snprintf(buf, sizeof(buf), "%.*s%c%s", (int) path.len, path.p, DIRSEP,
               passwords_file);
      fp = mg_fopen(buf, "r");
    } else {
      p = strrchr(path.p, DIRSEP);
      if (p == NULL) p = path.p;
      snprintf(buf, sizeof(buf), "%.*s%c%s", (int) (p - path.p), path.p, DIRSEP,
               passwords_file);
      fp = mg_fopen(buf, "r");
    }

    if (fp != NULL) {
      authorized = mg_http_check_digest_auth(hm, domain, fp);
      fclose(fp);
    }
  }

  LOG(LL_DEBUG,
      ("%.*s %s %d %d", (int) path.len, path.p,
       passwords_file ? passwords_file : "", is_global_pass_file, authorized));
  return authorized;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1070, %rsp           # imm = 0x1070
movl 0x10(%rbp), %eax
movq %rsi, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x1, -0x1044(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1a162
cmpq $0x0, -0x30(%rbp)
je 0x1a162
cmpl $0x0, 0x10(%rbp)
je 0x1a057
movq -0x30(%rbp), %rdi
leaq 0x70c1(%rip), %rsi      # 0x21107
callq 0x12360
movq %rax, -0x1040(%rbp)
jmp 0x1a130
cmpl $0x0, -0x1c(%rbp)
je 0x1a0ae
leaq -0x1030(%rbp), %rdi
movq -0x8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %r8
movq -0x30(%rbp), %rax
movl $0x1000, %esi           # imm = 0x1000
leaq 0x6692(%rip), %rdx      # 0x20710
movl $0x2f, %r9d
movq %rax, (%rsp)
movb $0x0, %al
callq 0x31f0
leaq -0x1030(%rbp), %rdi
leaq 0x706a(%rip), %rsi      # 0x21107
callq 0x12360
movq %rax, -0x1040(%rbp)
jmp 0x1a12e
movq -0x10(%rbp), %rdi
movl $0x2f, %esi
callq 0x3200
movq %rax, -0x1038(%rbp)
cmpq $0x0, -0x1038(%rbp)
jne 0x1a0d8
movq -0x10(%rbp), %rax
movq %rax, -0x1038(%rbp)
leaq -0x1030(%rbp), %rdi
movq -0x1038(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %r8
movq -0x30(%rbp), %rax
movl $0x1000, %esi           # imm = 0x1000
leaq 0x660d(%rip), %rdx      # 0x20710
movl $0x2f, %r9d
movq %rax, (%rsp)
movb $0x0, %al
callq 0x31f0
leaq -0x1030(%rbp), %rdi
leaq 0x6fe5(%rip), %rsi      # 0x21107
callq 0x12360
movq %rax, -0x1040(%rbp)
jmp 0x1a130
cmpq $0x0, -0x1040(%rbp)
je 0x1a160
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x1040(%rbp), %rdx
callq 0x136d0
movl %eax, -0x1044(%rbp)
movq -0x1040(%rbp), %rdi
callq 0x3160
jmp 0x1a162
jmp 0x1a164
movl $0x3, %edi
leaq 0x65a9(%rip), %rsi      # 0x20719
leaq 0x53d3(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x1a1e7
movq -0x8(%rbp), %rax
movl %eax, -0x1054(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1050(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1a1aa
movq -0x30(%rbp), %rax
movq %rax, -0x1060(%rbp)
jmp 0x1a1ba
leaq 0x65fa(%rip), %rax      # 0x207ab
movq %rax, -0x1060(%rbp)
jmp 0x1a1ba
movq -0x1050(%rbp), %rdx
movl -0x1054(%rbp), %esi
movq -0x1060(%rbp), %rcx
movl 0x10(%rbp), %r8d
movl -0x1044(%rbp), %r9d
leaq 0x654f(%rip), %rdi      # 0x2072f
movb $0x0, %al
callq 0x47a0
jmp 0x1a1e9
movl -0x1044(%rbp), %eax
addq $0x1070, %rsp           # imm = 0x1070
popq %rbp
retq
nopl (%rax,%rax)