// File: /workspace/github_c_makefile_star2_O1/sfeakes[P]unifi-motion/mongoose.c
// Function: c_vsnprintf
int c_vsnprintf(char *buf, size_t buf_size, const char *fmt, va_list ap) {
  int ch, i = 0, len_mod, flags, precision, field_width;

  while ((ch = *fmt++) != '\0') {
    if (ch != '%') {
      C_SNPRINTF_APPEND_CHAR(ch);
    } else {
      /*
       * Conversion specification:
       *   zero or more flags (one of: # 0 - <space> + ')
       *   an optional minimum  field  width (digits)
       *   an  optional precision (. followed by digits, or *)
       *   an optional length modifier (one of: hh h l ll L q j z t)
       *   conversion specifier (one of: d i o u x X e E f F g G a A c s p n)
       */
      flags = field_width = precision = len_mod = 0;

      /* Flags. only zero-pad flag is supported. */
      if (*fmt == '0') {
        flags |= C_SNPRINTF_FLAG_ZERO;
      }

      /* Field width */
      while (*fmt >= '0' && *fmt <= '9') {
        field_width *= 10;
        field_width += *fmt++ - '0';
      }
      /* Dynamic field width */
      if (*fmt == '*') {
        field_width = va_arg(ap, int);
        fmt++;
      }

      /* Precision */
      if (*fmt == '.') {
        fmt++;
        if (*fmt == '*') {
          precision = va_arg(ap, int);
          fmt++;
        } else {
          while (*fmt >= '0' && *fmt <= '9') {
            precision *= 10;
            precision += *fmt++ - '0';
          }
        }
      }

      /* Length modifier */
      switch (*fmt) {
        case 'h':
        case 'l':
        case 'L':
        case 'I':
        case 'q':
        case 'j':
        case 'z':
        case 't':
          len_mod = *fmt++;
          if (*fmt == 'h') {
            len_mod = 'H';
            fmt++;
          }
          if (*fmt == 'l') {
            len_mod = 'q';
            fmt++;
          }
          break;
      }

      ch = *fmt++;
      if (ch == 's') {
        const char *s = va_arg(ap, const char *); /* Always fetch parameter */
        int j;
        int pad = field_width - (precision >= 0 ? c_strnlen(s, precision) : 0);
        for (j = 0; j < pad; j++) {
          C_SNPRINTF_APPEND_CHAR(' ');
        }

        /* `s` may be NULL in case of %.*s */
        if (s != NULL) {
          /* Ignore negative and 0 precisions */
          for (j = 0; (precision <= 0 || j < precision) && s[j] != '\0'; j++) {
            C_SNPRINTF_APPEND_CHAR(s[j]);
          }
        }
      } else if (ch == 'c') {
        ch = va_arg(ap, int); /* Always fetch parameter */
        C_SNPRINTF_APPEND_CHAR(ch);
      } else if (ch == 'd' && len_mod == 0) {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, int), 10, flags,
                    field_width);
      } else if (ch == 'd' && len_mod == 'l') {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, long), 10, flags,
                    field_width);
#ifdef SSIZE_MAX
      } else if (ch == 'd' && len_mod == 'z') {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, ssize_t), 10, flags,
                    field_width);
#endif
      } else if (ch == 'd' && len_mod == 'q') {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, int64_t), 10, flags,
                    field_width);
      } else if ((ch == 'x' || ch == 'u') && len_mod == 0) {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, unsigned),
                    ch == 'x' ? 16 : 10, flags, field_width);
      } else if ((ch == 'x' || ch == 'u') && len_mod == 'l') {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, unsigned long),
                    ch == 'x' ? 16 : 10, flags, field_width);
      } else if ((ch == 'x' || ch == 'u') && len_mod == 'z') {
        i += c_itoa(buf + i, buf_size - i, va_arg(ap, size_t),
                    ch == 'x' ? 16 : 10, flags, field_width);
      } else if (ch == 'p') {
        unsigned long num = (unsigned long) (uintptr_t) va_arg(ap, void *);
        C_SNPRINTF_APPEND_CHAR('0');
        C_SNPRINTF_APPEND_CHAR('x');
        i += c_itoa(buf + i, buf_size - i, num, 16, flags, 0);
      } else {
#ifndef NO_LIBC
        /*
         * TODO(lsm): abort is not nice in a library, remove it
         * Also, ESP8266 SDK doesn't have it
         */
        abort();
#endif
      }
    }
  }

  /* Zero-terminate the result */
  if (buf_size > 0) {
    buf[i < (int) buf_size ? i : (int) buf_size - 1] = '\0';
  }

  return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r10
movq %rdx, %r13
movq %rsi, %rbp
movslq %ebp, %r12
xorl %r14d, %r14d
movq %rdi, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movq %rsi, (%rsp)
movzbl (%r13), %eax
incq %r13
cmpl $0x25, %eax
je 0x6eda
testl %eax, %eax
je 0x731a
cmpl %ebp, %r14d
jge 0x70b7
movslq %r14d, %rcx
movb %al, (%rdi,%rcx)
jmp 0x70b7
movb (%r13), %cl
xorl %r8d, %r8d
cmpb $0x30, %cl
sete %al
leal -0x30(%rcx), %edx
xorl %ebp, %ebp
cmpb $0x9, %dl
ja 0x6f0f
xorl %ebp, %ebp
leal (%rbp,%rbp,4), %edx
addb $-0x30, %cl
movzbl %cl, %ecx
leal (%rcx,%rdx,2), %ebp
movb 0x1(%r13), %cl
incq %r13
leal -0x30(%rcx), %edx
cmpb $0xa, %dl
jb 0x6ef3
cmpb $0x2a, %cl
jne 0x6f3d
movl (%r10), %edx
cmpq $0x28, %rdx
ja 0x6f2c
movq %rdx, %rcx
addq 0x10(%r10), %rcx
addl $0x8, %edx
movl %edx, (%r10)
jmp 0x6f38
movq 0x8(%r10), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%r10)
movl (%rcx), %ebp
incq %r13
xorl %ecx, %ecx
cmpb $0x2e, (%r13)
jne 0x6f95
cmpb $0x2a, 0x1(%r13)
jne 0x6f65
movl (%r10), %esi
cmpq $0x28, %rsi
ja 0x6f99
movq %rsi, %rdx
addq 0x10(%r10), %rdx
addl $0x8, %esi
movl %esi, (%r10)
jmp 0x6fa5
incq %r13
movb (%r13), %dl
leal -0x30(%rdx), %esi
cmpb $0x9, %sil
ja 0x6f95
xorl %ebx, %ebx
leal (%rbx,%rbx,4), %esi
addb $-0x30, %dl
movzbl %dl, %edx
leal (%rdx,%rsi,2), %ebx
movb 0x1(%r13), %dl
incq %r13
leal -0x30(%rdx), %esi
cmpb $0xa, %sil
jb 0x6f77
jmp 0x6fab
xorl %ebx, %ebx
jmp 0x6fab
movq 0x8(%r10), %rdx
leaq 0x8(%rdx), %rsi
movq %rsi, 0x8(%r10)
movl (%rdx), %ebx
addq $0x2, %r13
movzbl (%r13), %edx
leal -0x49(%rdx), %esi
cmpl $0x31, %esi
ja 0x7009
movabsq $0x2090a80000009, %r9   # imm = 0x2090A80000009
btq %rsi, %r9
jae 0x7009
leaq 0x1(%r13), %rsi
xorl %ecx, %ecx
cmpb $0x68, 0x1(%r13)
leaq 0x2(%r13), %r9
movzbl %dl, %edx
movl $0x48, %r11d
cmovel %r11d, %edx
sete %cl
cmoveq %r9, %rsi
xorl %r9d, %r9d
cmpb $0x6c, 0x1(%rcx,%r13)
movl $0x71, %ecx
cmovel %ecx, %edx
sete %r9b
movsbl %dl, %ecx
addq %rsi, %r9
movq %r9, %r13
movzbl (%r13), %edx
incq %r13
cmpl $0x63, %edx
je 0x7033
cmpl $0x73, %edx
jne 0x704b
movl (%r10), %ecx
cmpq $0x28, %rcx
ja 0x7076
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x7082
movl (%r10), %ecx
cmpq $0x28, %rcx
ja 0x709a
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x70a6
movb %al, %r8b
cmpb $0x64, %dl
jne 0x70bf
testl %ecx, %ecx
jne 0x70bf
movl (%r10), %ecx
cmpq $0x28, %rcx
ja 0x717a
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x7186
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movq (%rax), %r15
testl %ebx, %ebx
js 0x7104
movl %ebx, %esi
movq %r15, %rdi
callq 0x6e6d
movq 0x10(%rsp), %rdi
jmp 0x7106
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movq (%rsp), %rbp
cmpl %ebp, %r14d
jge 0x70b7
movb (%rax), %al
movslq %r14d, %rcx
movb %al, (%rdi,%rcx)
incl %r14d
jmp 0x6eb1
cmpb $0x64, %dl
jne 0x70c9
cmpl $0x6c, %ecx
je 0x70e5
cmpb $0x64, %dl
jne 0x70d3
cmpl $0x7a, %ecx
je 0x70e5
cmpb $0x64, %dl
jne 0x71dc
cmpl $0x71, %ecx
jne 0x71dc
movl (%r10), %ecx
cmpq $0x28, %rcx
ja 0x719b
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x71a7
xorl %eax, %eax
movl %ebp, %ecx
subl %eax, %ecx
testl %ecx, %ecx
jle 0x7135
movslq %r14d, %rcx
subl %ebp, %eax
xorl %edx, %edx
movq (%rsp), %rbp
movq 0x8(%rsp), %r10
cmpq %r12, %rcx
jge 0x7127
movb $0x20, (%rdi,%rcx)
incq %rcx
decl %edx
cmpl %edx, %eax
jne 0x711e
subl %edx, %r14d
jmp 0x713e
movq (%rsp), %rbp
movq 0x8(%rsp), %r10
testq %r15, %r15
je 0x6eb1
movslq %r14d, %r14
xorl %eax, %eax
movb (%r15,%rax), %cl
testb %cl, %cl
je 0x6eb1
cmpq %r12, %r14
jge 0x7161
movb %cl, (%rdi,%r14)
testl %ebx, %ebx
setle %cl
incq %r14
incq %rax
cmpl %eax, %ebx
setg %dl
orb %cl, %dl
jne 0x714c
jmp 0x6eb1
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movslq %r14d, %rcx
addq %rcx, %rdi
movq (%rsp), %r10
movq %r10, %rsi
subq %rcx, %rsi
movslq (%rax), %rdx
jmp 0x71ba
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movslq %r14d, %rcx
addq %rcx, %rdi
movq (%rsp), %r10
movq %r10, %rsi
subq %rcx, %rsi
movq (%rax), %rdx
movl $0xa, %ecx
movl %ebp, %r9d
movq %r10, %rbp
callq 0x7346
movq 0x10(%rsp), %rdi
addl %eax, %r14d
movq 0x8(%rsp), %r10
jmp 0x6eb1
cmpb $0x78, %dl
sete %sil
cmpb $0x75, %dl
sete %al
orb %sil, %al
cmpb $0x1, %al
jne 0x720c
testl %ecx, %ecx
jne 0x720c
movl (%r10), %ecx
cmpq $0x28, %rcx
ja 0x7240
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x724c
cmpl $0x6c, %ecx
sete %sil
andb %al, %sil
cmpb $0x1, %sil
je 0x7228
cmpl $0x7a, %ecx
sete %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x7297
movl (%r10), %ecx
cmpq $0x28, %rcx
ja 0x7263
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x726f
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movslq %r14d, %rcx
addq %rcx, %rdi
movq (%rsp), %r10
movq %r10, %rsi
subq %rcx, %rsi
cmpb $0x78, %dl
movl (%rax), %edx
jmp 0x7285
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movslq %r14d, %rcx
addq %rcx, %rdi
movq (%rsp), %r10
movq %r10, %rsi
subq %rcx, %rsi
cmpb $0x78, %dl
movq (%rax), %rdx
movl $0xa, %ecx
movl $0x10, %eax
cmovel %eax, %ecx
jmp 0x71bf
cmpb $0x70, %dl
jne 0x7341
movl (%r10), %ecx
cmpq $0x28, %rcx
movq (%rsp), %rbp
ja 0x72bc
movq %rcx, %rax
addq 0x10(%r10), %rax
addl $0x8, %ecx
movl %ecx, (%r10)
jmp 0x72c8
movq 0x8(%r10), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r10)
movq (%rax), %rdx
cmpl %ebp, %r14d
jge 0x72d7
movslq %r14d, %rax
movb $0x30, (%rdi,%rax)
movslq %r14d, %rax
leaq 0x1(%rax), %rcx
cmpl %ebp, %ecx
jge 0x72e6
movb $0x78, (%rdi,%rcx)
addq %rax, %rdi
addq $0x2, %rdi
addq $0x2, %rax
movq %rbp, %rsi
subq %rax, %rsi
movl $0x10, %ecx
xorl %r9d, %r9d
callq 0x7346
movq 0x10(%rsp), %rdi
addl %eax, %r14d
addl $0x2, %r14d
movq 0x8(%rsp), %r10
jmp 0x6eb1
testq %rbp, %rbp
je 0x732f
leal -0x1(%rbp), %eax
cmpl %ebp, %r14d
cmovll %r14d, %eax
cltq
movb $0x0, (%rdi,%rax)
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3090