// File: /workspace/github_c_makefile_star2_O3/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 0x13fc8
leaq 0x3218(%rip), %rsi      # 0x171c2
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 0x7ff5
movq %r9, %r13
movl %r8d, %ebp
movq %rcx, %r12
movq %rsi, 0x18(%rsp)
movq %rcx, %rdi
callq 0x3270
cmpl $-0x1, %eax
je 0x14428
movl %eax, %r15d
movq %r13, 0x10(%rsp)
movq %r14, (%rsp)
incl %ebp
movl %ebp, 0xc(%rsp)
leaq 0x20(%rsp), %r13
xorl %ebp, %ebp
xorl %r14d, %r14d
testl %r14d, %r14d
sete %al
cmpl $0x3e, %r15d
setne %cl
orb %al, %cl
jne 0x1410b
movslq %ebp, %rax
cmpb $0x2d, -0x1(%rax,%r13)
jne 0x1415d
cmpb $0x2d, 0x1e(%rsp,%rax)
jne 0x1415d
addq $-0x2, %rax
movb $0x0, 0x20(%rsp,%rax)
decq %rax
leaq 0x2020(%rsp), %r15
je 0x14059
cmpb $0x20, 0x20(%rsp,%rax)
jne 0x14059
movb $0x0, 0x20(%rsp,%rax)
decq %rax
jne 0x14048
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
je 0x141d3
cmpl $0x6c6c6163, 0x25(%rsp) # imm = 0x6C6C6163
jne 0x143c3
leaq 0x2028(%rsp), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x2020(%rsp)
movq (%rsp), %rdi
callq 0x6b26
movq %rax, 0x2028(%rsp)
movq %rdx, 0x2030(%rsp)
leaq 0x2a(%rsp), %rdi
callq 0x6b26
movq %rax, 0x2038(%rsp)
movq %rdx, 0x2040(%rsp)
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x69, %edx
movq %rax, %rcx
callq 0x7979
movq %rbx, %rdi
xorl %esi, %esi
movl $0x6a, %edx
movq %r15, %rcx
callq 0x7979
jmp 0x143c6
cmpl $0x3c, %r15d
jne 0x14158
testl %ebp, %ebp
jle 0x14143
callq 0x4aab
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rbx)
movl 0xc8(%rbx), %eax
andl $0x2, %eax
movq 0xc0(%rbx), %rcx
movq 0x10(%rcx), %rcx
movl %ebp, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq *0x48(%rcx,%rax,4)
movb $0x3c, 0x20(%rsp)
movl $0x1, %r14d
movl $0x1, %ebp
jmp 0x143c8
testl %r14d, %r14d
je 0x141b9
movl $0x1, %r14d
cmpl $0x1ffe, %ebp           # imm = 0x1FFE
je 0x14193
cmpl $0x5, %ebp
jne 0x141aa
movl 0x20(%rsp), %eax
movl $0x2d2d213c, %ecx       # imm = 0x2D2D213C
xorl %ecx, %eax
movzbl 0x24(%rsp), %ecx
xorl $0x23, %ecx
xorl %r14d, %r14d
orl %eax, %ecx
sete %r14b
movl $0x5, %ebp
jmp 0x141aa
xorl %ebp, %ebp
movq %rbx, %rdi
leaq 0x3047(%rip), %rsi      # 0x171e6
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x7ff5
movslq %ebp, %rax
incl %ebp
movb %r15b, 0x20(%rsp,%rax)
jmp 0x143c8
movslq %ebp, %rax
incl %ebp
movb %r15b, 0x20(%rsp,%rax)
cmpl $0x2000, %ebp           # imm = 0x2000
je 0x1421a
xorl %r14d, %r14d
jmp 0x143c8
movq %r14, %rdi
leaq 0x3022(%rip), %rsi      # 0x171ff
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
jne 0x14250
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3020(%rsp), %r14
movq %r14, %rdi
leaq 0x2644(%rip), %rdx      # 0x1684f
movq %r15, %r8
xorl %eax, %eax
callq 0x31e0
jmp 0x14318
callq 0x4aab
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rbx)
movl 0xc8(%rbx), %eax
andl $0x2, %eax
movq 0xc0(%rbx), %rcx
movq 0x10(%rcx), %rcx
movl $0x2000, %edx           # imm = 0x2000
movq %rbx, %rdi
movq %r13, %rsi
callq *0x48(%rcx,%rax,4)
jmp 0x143c3
movq %r14, %rdi
leaq 0x2fb6(%rip), %rsi      # 0x17210
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
jne 0x1427e
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3020(%rsp), %r14
movq %r14, %rdi
jmp 0x14307
movq %r14, %rdi
leaq 0x2f99(%rip), %rsi      # 0x17221
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
je 0x142b4
movq %r14, %rdi
leaq 0x2f8e(%rip), %rsi      # 0x1722f
movq %r15, %rdx
xorl %eax, %eax
callq 0x3420
cmpl $0x1, %eax
jne 0x143de
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3020(%rsp), %r14
movq %r14, %rdi
leaq 0x1d48(%rip), %rdx      # 0x16013
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x31e0
movq %r14, %rdi
movl $0x2f, %esi
callq 0x31f0
testq %rax, %rax
je 0x142ec
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 0x1d05(%rip), %rdx      # 0x16013
movq %r15, %rcx
xorl %eax, %eax
callq 0x31e0
movq %r14, %rdi
leaq 0x194c(%rip), %rsi      # 0x15c6e
callq 0x3370
testq %rax, %rax
je 0x14389
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 0x44fc
movq %rbx, %rdi
testl %eax, %eax
jle 0x143ae
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
movl 0xc(%rsp), %r8d
movq %r13, %r9
callq 0x13f86
jmp 0x143b6
callq 0x30a0
movl (%rax), %edi
callq 0x3600
movq %rbx, %rdi
leaq 0x2eb0(%rip), %rsi      # 0x1724f
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x7ff5
jmp 0x143c3
movq %r15, %rsi
callq 0x1443a
leaq 0x20(%rsp), %r13
movq %r15, %rdi
callq 0x3160
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x3270
movl %eax, %r15d
cmpl $-0x1, %eax
jne 0x14003
jmp 0x143f4
movq %rbx, %rdi
leaq 0x2e50(%rip), %rsi      # 0x17238
movq %r14, %rdx
xorl %eax, %eax
callq 0x7ff5
jmp 0x143c3
testl %ebp, %ebp
jle 0x14428
callq 0x4aab
cvttsd2si %xmm0, %rax
movq %rax, 0x70(%rbx)
movl 0xc8(%rbx), %eax
andl $0x2, %eax
movq 0xc0(%rbx), %rcx
movq 0x10(%rcx), %rcx
movl %ebp, %edx
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq *0x48(%rcx,%rax,4)
addq $0x4028, %rsp           # imm = 0x4028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq