// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/mongoose/mongoose.c
// Function: do_ssi_include
static void do_ssi_include(struct mg_connection *conn, const char *ssi,
                           char *tag, int include_level) {
  char file_name[IOBUF_SIZE], path[MAX_PATH_SIZE], *p;
  char **opts = (MG_CONN_2_CONN(conn))->server->config_options;
  FILE *fp;

  // sscanf() is safe here, since send_ssi_file() also uses buffer
  // of size MG_BUF_LEN to get the tag. So strlen(tag) is always < MG_BUF_LEN.
  if (sscanf(tag, " virtual=\"%[^\"]\"", file_name) == 1) {
    // File name is relative to the webserver root
    mg_snprintf(path, sizeof(path), "%s%c%s",
                opts[DOCUMENT_ROOT], '/', file_name);
  } else if (sscanf(tag, " abspath=\"%[^\"]\"", file_name) == 1) {
    // File name is relative to the webserver working directory
    // or it is absolute system path
    mg_snprintf(path, sizeof(path), "%s", file_name);
  } else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1 ||
             sscanf(tag, " \"%[^\"]\"", file_name) == 1) {
    // File name is relative to the current document
    mg_snprintf(path, sizeof(path), "%s", ssi);
    if ((p = strrchr(path, '/')) != NULL) {
      p[1] = '\0';
    }
    mg_snprintf(path + strlen(path), sizeof(path) - strlen(path), "%s",
                file_name);
  } else {
    mg_printf(conn, "Bad SSI #include: [%s]", tag);
    return;
  }

  if ((fp = fopen(path, "rb")) == NULL) {
    mg_printf(conn, "Cannot open SSI #include: [%s]: fopen(%s): %s",
              tag, path, strerror(errno));
  } else {
    ns_set_close_on_exec(fileno(fp));
    if (mg_match_prefix(opts[SSI_PATTERN], strlen(opts[SSI_PATTERN]),
        path) > 0) {
      send_ssi_file(conn, path, fp, include_level + 1);
    } else {
      send_file_data(conn, fp);
    }
    fclose(fp);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4070, %rsp           # imm = 0x4070
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x2a0(%rax), %rax
addq $0x38, %rax
movq %rax, -0x4030(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x2020(%rbp), %rdx
leaq 0xf335(%rip), %rsi      # 0xc7b47
movb $0x0, %al
callq 0xd130
cmpl $0x1, %eax
jne 0xb8855
leaq -0x4020(%rbp), %rdi
movq -0x4030(%rbp), %rax
movq 0x38(%rax), %rcx
leaq -0x2020(%rbp), %r9
movl $0x2000, %esi           # imm = 0x2000
leaq 0xee79(%rip), %rdx      # 0xc76bc
movl $0x2f, %r8d
movb $0x0, %al
callq 0xb3c50
jmp 0xb899f
movq -0x18(%rbp), %rdi
leaq -0x2020(%rbp), %rdx
leaq 0xf2f1(%rip), %rsi      # 0xc7b58
movb $0x0, %al
callq 0xd130
cmpl $0x1, %eax
jne 0xb8899
leaq -0x4020(%rbp), %rdi
leaq -0x2020(%rbp), %rcx
movl $0x2000, %esi           # imm = 0x2000
leaq 0xbfa3(%rip), %rdx      # 0xc4830
movb $0x0, %al
callq 0xb3c50
jmp 0xb899d
movq -0x18(%rbp), %rdi
leaq -0x2020(%rbp), %rdx
leaq 0xf2be(%rip), %rsi      # 0xc7b69
movb $0x0, %al
callq 0xd130
cmpl $0x1, %eax
je 0xb88d9
movq -0x18(%rbp), %rdi
leaq -0x2020(%rbp), %rdx
leaq 0xf2ae(%rip), %rsi      # 0xc7b77
movb $0x0, %al
callq 0xd130
cmpl $0x1, %eax
jne 0xb8980
leaq -0x4020(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x2000, %esi           # imm = 0x2000
leaq 0xbf40(%rip), %rdx      # 0xc4830
movb $0x0, %al
callq 0xb3c50
leaq -0x4020(%rbp), %rdi
movl $0x2f, %esi
callq 0xdbe0
movq %rax, -0x4028(%rbp)
cmpq $0x0, %rax
je 0xb8920
movq -0x4028(%rbp), %rax
movb $0x0, 0x1(%rax)
leaq -0x4020(%rbp), %rax
movq %rax, -0x4048(%rbp)
leaq -0x4020(%rbp), %rdi
callq 0xd550
movq %rax, %rcx
movq -0x4048(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x4040(%rbp)
leaq -0x4020(%rbp), %rdi
callq 0xd550
movq -0x4040(%rbp), %rdi
movl $0x2000, %esi           # imm = 0x2000
subq %rax, %rsi
leaq -0x2020(%rbp), %rcx
leaq 0xbeb9(%rip), %rdx      # 0xc4830
movb $0x0, %al
callq 0xb3c50
jmp 0xb899b
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xf1f1(%rip), %rsi      # 0xc7b80
movb $0x0, %al
callq 0xb0cb0
jmp 0xb8aab
jmp 0xb899d
jmp 0xb899f
leaq -0x4020(%rbp), %rdi
leaq 0x6b2c(%rip), %rsi      # 0xbf4d9
callq 0xdd20
movq %rax, -0x4038(%rbp)
cmpq $0x0, %rax
jne 0xb8a1a
movq -0x8(%rbp), %rax
movq %rax, -0x4060(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x4058(%rbp)
leaq -0x4020(%rbp), %rax
movq %rax, -0x4050(%rbp)
callq 0xdcc0
movl (%rax), %edi
callq 0xda00
movq -0x4060(%rbp), %rdi
movq -0x4058(%rbp), %rdx
movq -0x4050(%rbp), %rcx
movq %rax, %r8
leaq 0xf189(%rip), %rsi      # 0xc7b97
movb $0x0, %al
callq 0xb0cb0
jmp 0xb8aab
movq -0x4038(%rbp), %rdi
callq 0xde90
movl %eax, %edi
callq 0xaf170
movq -0x4030(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x4068(%rbp)
movq -0x4030(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0xd550
movq -0x4068(%rbp), %rdi
movq %rax, %rsi
leaq -0x4020(%rbp), %rdx
callq 0xb10f0
cmpl $0x0, %eax
jle 0xb8a8f
movq -0x8(%rbp), %rdi
leaq -0x4020(%rbp), %rsi
movq -0x4038(%rbp), %rdx
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
callq 0xb8470
jmp 0xb8a9f
movq -0x8(%rbp), %rdi
movq -0x4038(%rbp), %rsi
callq 0xb8ba0
movq -0x4038(%rbp), %rdi
callq 0xd5b0
addq $0x4070, %rsp           # imm = 0x4070
popq %rbp
retq
nopw %cs:(%rax,%rax)