// File: /workspace/github_c_makefile_star2_O1/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_send_ssi_file
static void mg_send_ssi_file(struct mg_connection *nc, struct http_message *hm,
                             const char *path, FILE *fp, int include_level,
                             const struct mg_serve_http_opts *opts) {
  static const struct mg_str btag = MG_MK_STR("<!--#");
  static const struct mg_str d_include = MG_MK_STR("include");
  static const struct mg_str d_call = MG_MK_STR("call");
#if MG_ENABLE_HTTP_SSI_EXEC
  static const struct mg_str d_exec = MG_MK_STR("exec");
#endif
  char buf[BUFSIZ], *p = buf + btag.len; /* p points to SSI directive */
  int ch, len, in_ssi_tag;

  if (include_level > 10) {
    mg_printf(nc, "SSI #include level is too deep (%s)", path);
    return;
  }

  in_ssi_tag = len = 0;
  while ((ch = fgetc(fp)) != EOF) {
    if (in_ssi_tag && ch == '>' && buf[len - 1] == '-' && buf[len - 2] == '-') {
      size_t i = len - 2;
      in_ssi_tag = 0;

      /* Trim closing --> */
      buf[i--] = '\0';
      while (i > 0 && buf[i] == ' ') {
        buf[i--] = '\0';
      }

      /* Handle known SSI directives */
      if (strncmp(p, d_include.p, d_include.len) == 0) {
        mg_do_ssi_include(nc, hm, path, p + d_include.len + 1, include_level,
                          opts);
      } else if (strncmp(p, d_call.p, d_call.len) == 0) {
        struct mg_ssi_call_ctx cctx;
        memset(&cctx, 0, sizeof(cctx));
        cctx.req = hm;
        cctx.file = mg_mk_str(path);
        cctx.arg = mg_mk_str(p + d_call.len + 1);
        mg_call(nc, NULL, nc->user_data, MG_EV_SSI_CALL,
                (void *) cctx.arg.p); /* NUL added above */
        mg_call(nc, NULL, nc->user_data, MG_EV_SSI_CALL_CTX, &cctx);
#if MG_ENABLE_HTTP_SSI_EXEC
      } else if (strncmp(p, d_exec.p, d_exec.len) == 0) {
        do_ssi_exec(nc, p + d_exec.len + 1);
#endif
      } else {
        /* Silently ignore unknown SSI directive. */
      }
      len = 0;
    } else if (ch == '<') {
      in_ssi_tag = 1;
      if (len > 0) {
        mg_send(nc, buf, (size_t) len);
      }
      len = 0;
      buf[len++] = ch & 0xff;
    } else if (in_ssi_tag) {
      if (len == (int) btag.len && strncmp(buf, btag.p, btag.len) != 0) {
        /* Not an SSI tag */
        in_ssi_tag = 0;
      } else if (len == (int) sizeof(buf) - 2) {
        mg_printf(nc, "%s: SSI tag is too large", path);
        len = 0;
      }
      buf[len++] = ch & 0xff;
    } else {
      buf[len++] = ch & 0xff;
      if (len == (int) sizeof(buf)) {
        mg_send(nc, buf, (size_t) len);
        len = 0;
      }
    }
  }

  /* Send the rest of buffered data */
  if (len > 0) {
    mg_send(nc, buf, (size_t) len);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4028, %rsp           # imm = 0x4028
movq %rdx, %r14
movq %rdi, %rbx
cmpl $0xa, %r8d
jle 0x13ade
leaq 0x36e4(%rip), %rsi      # 0x171a4
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x4028, %rsp           # imm = 0x4028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x80d3
movq %r9, %r15
movl %r8d, %r13d
movq %rcx, %r12
movq %rsi, 0x18(%rsp)
movq %rcx, %rdi
callq 0x3270
cmpl $-0x1, %eax
je 0x13eed
movl %eax, %ebp
movq %r15, 0x10(%rsp)
movq %r14, (%rsp)
incl %r13d
movl %r13d, 0xc(%rsp)
leaq 0x20(%rsp), %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
testl %r14d, %r14d
sete %al
cmpl $0x3e, %ebp
setne %cl
orb %al, %cl
jne 0x13c22
movslq %r15d, %rax
cmpb $0x2d, -0x1(%rax,%r13)
jne 0x13c22
cmpb $0x2d, 0x1e(%rsp,%rax)
jne 0x13c22
addq $-0x2, %rax
movb $0x0, 0x20(%rsp,%rax)
decq %rax
je 0x13b5e
cmpb $0x20, 0x20(%rsp,%rax)
je 0x13b4d
movl 0x25(%rsp), %eax
movl $0x6c636e69, %ecx       # imm = 0x6C636E69
xorl %ecx, %eax
movl 0x28(%rsp), %ecx
movl $0x6564756c, %edx       # imm = 0x6564756C
xorl %edx, %ecx
orl %eax, %ecx
leaq 0x2d(%rsp), %r14
leaq 0x2020(%rsp), %r15
je 0x13ccc
cmpl $0x6c6c6163, 0x25(%rsp) # imm = 0x6C6C6163
jne 0x13ebc
xorps %xmm0, %xmm0
movaps %xmm0, 0x2020(%rsp)
movaps %xmm0, 0x2030(%rsp)
movq $0x0, 0x2040(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x2020(%rsp)
movq (%rsp), %rdi
callq 0x6be8
movq %rax, 0x2028(%rsp)
movq %rdx, 0x2030(%rsp)
leaq 0x2a(%rsp), %rdi
callq 0x6be8
movq %rax, 0x2038(%rsp)
movq %rdx, 0x2040(%rsp)
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x69, %edx
movq %rax, %rcx
callq 0x7a51
movq %rbx, %rdi
xorl %esi, %esi
movl $0x6a, %edx
movq %r15, %rcx
callq 0x7a51
jmp 0x13ebf
cmpl $0x3c, %ebp
jne 0x13c50
testl %r15d, %r15d
jle 0x13c3a
movq %rbx, %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x808e
movb $0x3c, 0x20(%rsp)
movl $0x1, %r14d
movl $0x1, %r15d
jmp 0x13ec2
testl %r14d, %r14d
je 0x13c9b
movl $0x1, %r14d
cmpl $0x1ffe, %r15d          # imm = 0x1FFE
je 0x13d1c
cmpl $0x5, %r15d
jne 0x13d34
movl 0x20(%rsp), %eax
movl $0x2d2d213c, %ecx       # imm = 0x2D2D213C
xorl %ecx, %eax
movzbl 0x24(%rsp), %ecx
xorl $0x23, %ecx
orl %eax, %ecx
je 0x13d13
xorl %r14d, %r14d
movl $0x5, %r15d
jmp 0x13d34
movslq %r15d, %rax
incl %r15d
movb %bpl, 0x20(%rsp,%rax)
cmpl $0x2000, %r15d          # imm = 0x2000
je 0x13cb7
xorl %r14d, %r14d
jmp 0x13ec2
movq %rbx, %rdi
movq %r13, %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x808e
jmp 0x13ebc
movq %r14, %rdi
leaq 0x350b(%rip), %rsi      # 0x171e1
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
jne 0x13d44
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3020(%rsp), %r14
movq %r14, %rdi
leaq 0x2b2d(%rip), %rdx      # 0x16831
movq %r15, %r8
xorl %eax, %eax
callq 0x31e0
jmp 0x13e0c
cmpl $0x1ffe, %r15d          # imm = 0x1FFE
jne 0x13d34
xorl %r15d, %r15d
movq %rbx, %rdi
leaq 0x349f(%rip), %rsi      # 0x171c8
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x80d3
movslq %r15d, %rax
incl %r15d
movb %bpl, 0x20(%rsp,%rax)
jmp 0x13ec2
movq %r14, %rdi
leaq 0x34a4(%rip), %rsi      # 0x171f2
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
jne 0x13d72
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3020(%rsp), %r14
movq %r14, %rdi
jmp 0x13dfb
movq %r14, %rdi
leaq 0x3487(%rip), %rsi      # 0x17203
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
je 0x13da8
movq %r14, %rdi
leaq 0x347c(%rip), %rsi      # 0x17211
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
jne 0x13ed7
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3020(%rsp), %r14
movq %r14, %rdi
leaq 0x2233(%rip), %rdx      # 0x15ff2
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x31e0
movq %r14, %rdi
movl $0x2f, %esi
callq 0x31f0
testq %rax, %rax
je 0x13de0
movb $0x0, 0x1(%rax)
movq %r14, %rdi
callq 0x3180
leaq (%rsp,%rax), %rdi
addq $0x3020, %rdi           # imm = 0x3020
movl $0x1000, %esi           # imm = 0x1000
subq %rax, %rsi
leaq 0x21f0(%rip), %rdx      # 0x15ff2
movq %r15, %rcx
xorl %eax, %eax
callq 0x31e0
movq %r14, %rdi
leaq 0x1e37(%rip), %rsi      # 0x15c4d
callq 0x3370
testq %rax, %rax
je 0x13e7d
movq %rax, %r15
movq %rax, %rdi
callq 0x33c0
movl %eax, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x34f0
movq 0x10(%rsp), %r13
movq 0x30(%r13), %rbp
movq %rbp, %rdi
callq 0x3180
movq %rbp, %rdi
movl %eax, %esi
movq %r14, %rdx
callq 0x456e
movq %rbx, %rdi
testl %eax, %eax
jle 0x13ea7
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
movl 0xc(%rsp), %r8d
movq %r13, %r9
callq 0x13a9c
jmp 0x13eaf
callq 0x30a0
movl (%rax), %edi
callq 0x3600
movq %rbx, %rdi
leaq 0x339e(%rip), %rsi      # 0x17231
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x80d3
leaq 0x20(%rsp), %r13
jmp 0x13ebc
movq %r15, %rsi
callq 0x13f17
leaq 0x20(%rsp), %r13
movq %r15, %rdi
callq 0x3160
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x3270
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x13b1b
jmp 0x13ef0
movq %rbx, %rdi
leaq 0x3339(%rip), %rsi      # 0x1721a
movq %r14, %rdx
xorl %eax, %eax
callq 0x80d3
jmp 0x13ebc
xorl %r15d, %r15d
testl %r15d, %r15d
jle 0x13f05
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x808e
addq $0x4028, %rsp           # imm = 0x4028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq