// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20a0, %rsp           # imm = 0x20A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x2030(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x2038(%rbp)
cmpl $0xa, -0x24(%rbp)
jle 0x1c066
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x5132(%rip), %rsi      # 0x2118c
movb $0x0, %al
callq 0xb2f0
jmp 0x1c450
movl $0x0, -0x2040(%rbp)
movl $0x0, -0x2044(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3290
movl %eax, -0x203c(%rbp)
cmpl $-0x1, %eax
je 0x1c42e
cmpl $0x0, -0x2044(%rbp)
je 0x1c2cc
cmpl $0x3e, -0x203c(%rbp)
jne 0x1c2cc
movl -0x2040(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x2030(%rbp,%rax), %eax
cmpl $0x2d, %eax
jne 0x1c2cc
movl -0x2040(%rbp), %eax
subl $0x2, %eax
cltq
movsbl -0x2030(%rbp,%rax), %eax
cmpl $0x2d, %eax
jne 0x1c2cc
movl -0x2040(%rbp), %eax
subl $0x2, %eax
cltq
movq %rax, -0x2050(%rbp)
movl $0x0, -0x2044(%rbp)
movq -0x2050(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x2050(%rbp)
movb $0x0, -0x2030(%rbp,%rax)
xorl %eax, %eax
cmpq $0x0, -0x2050(%rbp)
movb %al, -0x2099(%rbp)
jbe 0x1c14a
movq -0x2050(%rbp), %rax
movsbl -0x2030(%rbp,%rax), %eax
cmpl $0x20, %eax
sete %al
movb %al, -0x2099(%rbp)
movb -0x2099(%rbp), %al
testb $0x1, %al
jne 0x1c156
jmp 0x1c175
movq -0x2050(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x2050(%rbp)
movb $0x0, -0x2030(%rbp,%rax)
jmp 0x1c11d
movq -0x2038(%rbp), %rdi
movq 0xa79d(%rip), %rsi      # 0x26920
movl $0x7, %edx
callq 0x30b0
cmpl $0x0, %eax
jne 0x1c1bf
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x2038(%rbp), %rcx
addq $0x7, %rcx
addq $0x1, %rcx
movl -0x24(%rbp), %r8d
movq -0x30(%rbp), %r9
callq 0x1c460
jmp 0x1c2bd
movq -0x2038(%rbp), %rdi
movq 0xa763(%rip), %rsi      # 0x26930
movl $0x4, %edx
callq 0x30b0
cmpl $0x0, %eax
jne 0x1c2b9
leaq -0x2078(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x3260
movq -0x10(%rbp), %rax
movq %rax, -0x2078(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8a60
movq %rax, -0x2088(%rbp)
movq %rdx, -0x2080(%rbp)
movq -0x2088(%rbp), %rax
movq %rax, -0x2070(%rbp)
movq -0x2080(%rbp), %rax
movq %rax, -0x2068(%rbp)
movq -0x2038(%rbp), %rdi
addq $0x4, %rdi
addq $0x1, %rdi
callq 0x8a60
movq %rax, -0x2098(%rbp)
movq %rdx, -0x2090(%rbp)
movq -0x2098(%rbp), %rax
movq %rax, -0x2060(%rbp)
movq -0x2090(%rbp), %rax
movq %rax, -0x2058(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdx
movq -0x2060(%rbp), %r8
xorl %eax, %eax
movl %eax, %esi
movl $0x69, %ecx
callq 0xa8e0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
movl $0x6a, %ecx
leaq -0x2078(%rbp), %r8
callq 0xa8e0
jmp 0x1c2bb
jmp 0x1c2bb
jmp 0x1c2bd
movl $0x0, -0x2040(%rbp)
jmp 0x1c429
cmpl $0x3c, -0x203c(%rbp)
jne 0x1c337
movl $0x1, -0x2044(%rbp)
cmpl $0x0, -0x2040(%rbp)
jle 0x1c301
movq -0x8(%rbp), %rdi
leaq -0x2030(%rbp), %rsi
movslq -0x2040(%rbp), %rax
movl %eax, %edx
callq 0xb260
movl $0x0, -0x2040(%rbp)
movl -0x203c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movl -0x2040(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x2040(%rbp)
cltq
movb %cl, -0x2030(%rbp,%rax)
jmp 0x1c427
cmpl $0x0, -0x2044(%rbp)
je 0x1c3cd
cmpl $0x5, -0x2040(%rbp)
jne 0x1c376
leaq -0x2030(%rbp), %rdi
movq 0xa5b5(%rip), %rsi      # 0x26910
movl $0x5, %edx
callq 0x30b0
cmpl $0x0, %eax
je 0x1c376
movl $0x0, -0x2044(%rbp)
jmp 0x1c3a4
cmpl $0x1ffe, -0x2040(%rbp)  # imm = 0x1FFE
jne 0x1c3a2
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x4e1f(%rip), %rsi      # 0x211b0
movb $0x0, %al
callq 0xb2f0
movl $0x0, -0x2040(%rbp)
jmp 0x1c3a4
movl -0x203c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movl -0x2040(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x2040(%rbp)
cltq
movb %cl, -0x2030(%rbp,%rax)
jmp 0x1c425
movl -0x203c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movl -0x2040(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x2040(%rbp)
cltq
movb %cl, -0x2030(%rbp,%rax)
cmpl $0x2000, -0x2040(%rbp)  # imm = 0x2000
jne 0x1c423
movq -0x8(%rbp), %rdi
leaq -0x2030(%rbp), %rsi
movslq -0x2040(%rbp), %rax
movl %eax, %edx
callq 0xb260
movl $0x0, -0x2040(%rbp)
jmp 0x1c425
jmp 0x1c427
jmp 0x1c429
jmp 0x1c07a
cmpl $0x0, -0x2040(%rbp)
jle 0x1c450
movq -0x8(%rbp), %rdi
leaq -0x2030(%rbp), %rsi
movslq -0x2040(%rbp), %rax
movl %eax, %edx
callq 0xb260
addq $0x20a0, %rsp           # imm = 0x20A0
popq %rbp
retq
nopl (%rax)