// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: open_local_endpoint
static void open_local_endpoint(struct connection *conn, int skip_user) {
#ifndef MONGOOSE_NO_FILESYSTEM
  char path[MAX_PATH_SIZE];
  file_stat_t st;
  int exists = 0;
#endif

  // If EP_USER was set in a prev call, reset it
  conn->endpoint_type = EP_NONE;

#ifndef MONGOOSE_NO_AUTH
  if (conn->server->event_handler && call_user(conn, MG_AUTH) == MG_FALSE) {
    mg_send_digest_auth_request(&conn->mg_conn);
    return;
  }
#endif

  // Call URI handler if one is registered for this URI
  if (skip_user == 0 && conn->server->event_handler != NULL) {
    conn->endpoint_type = EP_USER;
#if MONGOOSE_POST_SIZE_LIMIT > 1
    {
      const char *cl = mg_get_header(&conn->mg_conn, "Content-Length");
      if ((strcmp(conn->mg_conn.request_method, "POST") == 0 ||
           strcmp(conn->mg_conn.request_method, "PUT") == 0) &&
          (cl == NULL || to64(cl) > MONGOOSE_POST_SIZE_LIMIT)) {
        send_http_error(conn, 500, "POST size > %lu",
                        (unsigned long) MONGOOSE_POST_SIZE_LIMIT);
      }
    }
#endif
    return;
  }

  if (strcmp(conn->mg_conn.request_method, "CONNECT") == 0 ||
      mg_strncasecmp(conn->mg_conn.uri, "http", 4) == 0) {
    const char *enp = conn->server->config_options[ENABLE_PROXY];
    if (enp == NULL || strcmp(enp, "yes") != 0) {
      send_http_error(conn, 405, NULL);
    } else {
      proxify_connection(conn);
    }
    return;
  }

  if (!strcmp(conn->mg_conn.request_method, "OPTIONS")) {
    send_options(conn);
    return;
  }

#ifdef MONGOOSE_NO_FILESYSTEM
  send_http_error(conn, 404, NULL);
#else
  exists = convert_uri_to_file_name(conn, path, sizeof(path), &st);

  if (!strcmp(conn->mg_conn.request_method, "OPTIONS")) {
    send_options(conn);
  } else if (conn->server->config_options[DOCUMENT_ROOT] == NULL) {
    send_http_error(conn, 404, NULL);
#ifndef MONGOOSE_NO_AUTH
  } else if ((!is_dav_request(conn) && !is_authorized(conn, path,
               exists && S_ISDIR(st.st_mode))) ||
             (is_dav_request(conn) && !is_authorized_for_dav(conn))) {
    mg_send_digest_auth_request(&conn->mg_conn);
    close_local_endpoint(conn);
#endif
#ifndef MONGOOSE_NO_DAV
  } else if (must_hide_file(conn, path)) {
    send_http_error(conn, 404, NULL);
  } else if (!strcmp(conn->mg_conn.request_method, "PROPFIND")) {
    handle_propfind(conn, path, &st, exists);
  } else if (!strcmp(conn->mg_conn.request_method, "MKCOL")) {
    handle_mkcol(conn, path);
  } else if (!strcmp(conn->mg_conn.request_method, "DELETE")) {
    handle_delete(conn, path);
  } else if (!strcmp(conn->mg_conn.request_method, "PUT")) {
    handle_put(conn, path);
#endif
  } else {
    mg_send_file_internal(&conn->mg_conn, path, &st, exists, NULL);
  }
#endif  // MONGOOSE_NO_FILESYSTEM
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20d0, %rsp           # imm = 0x20D0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x20a4(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x2b8(%rax)
movq -0x8(%rbp), %rax
movq 0x2a8(%rax), %rax
cmpq $0x0, 0x30(%rax)
je 0xb9961
movq -0x8(%rbp), %rdi
movl $0x66, %esi
callq 0xb7300
cmpl $0x0, %eax
jne 0xb9961
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
callq 0xb2360
jmp 0xb9c89
cmpl $0x0, -0xc(%rbp)
jne 0xb998c
movq -0x8(%rbp), %rax
movq 0x2a8(%rax), %rax
cmpq $0x0, 0x30(%rax)
je 0xb998c
movq -0x8(%rbp), %rax
movl $0x3, 0x2b8(%rax)
jmp 0xb9c89
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xd30b(%rip), %rsi      # 0xc6ca6
callq 0xdab0
cmpl $0x0, %eax
je 0xb99c3
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0xe3f9(%rip), %rsi      # 0xc7dad
movl $0x4, %edx
callq 0xb2e40
cmpl $0x0, %eax
jne 0xb9a22
movq -0x8(%rbp), %rax
movq 0x2a8(%rax), %rax
movq 0x80(%rax), %rax
movq %rax, -0x20b0(%rbp)
cmpq $0x0, -0x20b0(%rbp)
je 0xb99fe
movq -0x20b0(%rbp), %rdi
leaq 0x9050(%rip), %rsi      # 0xc2a44
callq 0xdab0
cmpl $0x0, %eax
je 0xb9a14
movq -0x8(%rbp), %rdi
movl $0x195, %esi            # imm = 0x195
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0xb3db0
jmp 0xb9a1d
movq -0x8(%rbp), %rdi
callq 0xbc820
jmp 0xb9c89
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe35f(%rip), %rsi      # 0xc7d90
callq 0xdab0
cmpl $0x0, %eax
jne 0xb9a49
movq -0x8(%rbp), %rdi
callq 0xbc9a0
jmp 0xb9c89
movq -0x8(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
leaq -0x20a0(%rbp), %rcx
callq 0xbc9f0
movl %eax, -0x20a4(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe316(%rip), %rsi      # 0xc7d90
callq 0xdab0
cmpl $0x0, %eax
jne 0xb9a92
movq -0x8(%rbp), %rdi
callq 0xbc9a0
jmp 0xb9c89
movq -0x8(%rbp), %rax
movq 0x2a8(%rax), %rax
cmpq $0x0, 0x70(%rax)
jne 0xb9abd
movq -0x8(%rbp), %rdi
movl $0x194, %esi            # imm = 0x194
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0xb3db0
jmp 0xb9c87
movq -0x8(%rbp), %rdi
callq 0xbcd80
cmpl $0x0, %eax
jne 0xb9b31
movq -0x8(%rbp), %rax
movq %rax, -0x20c8(%rbp)
leaq -0x2010(%rbp), %rax
movq %rax, -0x20c0(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x20a4(%rbp)
movb %al, -0x20b1(%rbp)
je 0xb9b0e
movl -0x2088(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
sete %al
movb %al, -0x20b1(%rbp)
movq -0x20c0(%rbp), %rsi
movq -0x20c8(%rbp), %rdi
movb -0x20b1(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xbce20
cmpl $0x0, %eax
je 0xb9b4d
movq -0x8(%rbp), %rdi
callq 0xbcd80
cmpl $0x0, %eax
je 0xb9b68
movq -0x8(%rbp), %rdi
callq 0xbce80
cmpl $0x0, %eax
jne 0xb9b68
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
callq 0xb2360
movq -0x8(%rbp), %rdi
callq 0xb23e0
jmp 0xb9c85
movq -0x8(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
callq 0xb3d00
cmpl $0x0, %eax
je 0xb9b96
movq -0x8(%rbp), %rdi
movl $0x194, %esi            # imm = 0x194
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0xb3db0
jmp 0xb9c83
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe1f3(%rip), %rsi      # 0xc7d98
callq 0xdab0
cmpl $0x0, %eax
jne 0xb9bd1
movq -0x8(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
movl -0x20a4(%rbp), %ecx
leaq -0x20a0(%rbp), %rdx
callq 0xbcf30
jmp 0xb9c81
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe1c1(%rip), %rsi      # 0xc7da1
callq 0xdab0
cmpl $0x0, %eax
jne 0xb9bff
movq -0x8(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
callq 0xbd170
jmp 0xb9c7f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe17b(%rip), %rsi      # 0xc7d89
callq 0xdab0
cmpl $0x0, %eax
jne 0xb9c2a
movq -0x8(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
callq 0xbd220
jmp 0xb9c7d
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x909a(%rip), %rsi      # 0xc2cd3
callq 0xdab0
cmpl $0x0, %eax
jne 0xb9c55
movq -0x8(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
callq 0xbd2e0
jmp 0xb9c7b
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq -0x2010(%rbp), %rsi
movl -0x20a4(%rbp), %ecx
leaq -0x20a0(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
callq 0xb3970
jmp 0xb9c7d
jmp 0xb9c7f
jmp 0xb9c81
jmp 0xb9c83
jmp 0xb9c85
jmp 0xb9c87
jmp 0xb9c89
addq $0x20d0, %rsp           # imm = 0x20D0
popq %rbp
retq
nopw %cs:(%rax,%rax)