// File: /workspace/github_c_makefile_star2_O3/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_hexdump_n
static int mg_hexdump_n(const void *buf, int len, char *dst, int dst_len,
                        int offset) {
  const unsigned char *p = (const unsigned char *) buf;
  char ascii[17] = "";
  int i, idx, n = 0;

  for (i = 0; i < len; i++) {
    idx = i % 16;
    if (idx == 0) {
      if (i > 0) n += snprintf(dst + n, MAX(dst_len - n, 0), "  %s\n", ascii);
      n += snprintf(dst + n, MAX(dst_len - n, 0), "%04x ", i + offset);
    }
    if (dst_len - n < 0) {
      return n;
    }
    n += snprintf(dst + n, MAX(dst_len - n, 0), " %02x", p[i]);
    ascii[idx] = p[i] < 0x20 || p[i] > 0x7e ? '.' : p[i];
    ascii[idx + 1] = '\0';
  }

  while (i++ % 16) n += snprintf(dst + n, MAX(dst_len - n, 0), "%s", "   ");
  n += snprintf(dst + n, MAX(dst_len - n, 0), "  %s\n", ascii);

  return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r14d
movq %rdx, %r15
movq %rdi, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movb $0x0, 0x20(%rsp)
movl $0x0, %eax
testl %esi, %esi
jle 0x10dc4
movl %esi, 0xc(%rsp)
movl %esi, %eax
movq %rax, 0x38(%rsp)
movl %r8d, %eax
movq %rax, 0x30(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %eax, %eax
movq %r14, %rbx
movq %r15, (%rsp)
movq %r13, %r14
andq $0xf, %r14
je 0x10c9c
movl %eax, %r12d
jmp 0x10cff
testq %r13, %r13
je 0x10cc8
movslq %eax, %r12
leaq (%r15,%r12), %rdi
movl %ebx, %esi
subl %r12d, %esi
testl %esi, %esi
cmovlel %ebp, %esi
leaq 0x695d(%rip), %rdx      # 0x17616
leaq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x31e0
addl %r12d, %eax
movq %r15, %rcx
movq %rbx, %r15
movslq %eax, %rbx
leaq (%rcx,%rbx), %rdi
movl %r15d, %esi
subl %ebx, %esi
testl %esi, %esi
cmovlel %ebp, %esi
movq 0x30(%rsp), %rax
leal (%rax,%r13), %ecx
leaq 0x692d(%rip), %rdx      # 0x1761c
xorl %eax, %eax
callq 0x31e0
movl %eax, %r12d
addl %ebx, %r12d
movq %r15, %rbx
movl %ebx, %eax
subl %r12d, %eax
js 0x10df8
movslq %r12d, %rdi
movq (%rsp), %r15
addq %r15, %rdi
movl %eax, %esi
movq 0x40(%rsp), %rbp
movzbl (%rbp,%r13), %ecx
leaq 0x68fa(%rip), %rdx      # 0x17622
xorl %eax, %eax
callq 0x31e0
addl %r12d, %eax
movzbl (%rbp,%r13), %ecx
xorl %ebp, %ebp
leal -0x7f(%rcx), %edx
cmpb $-0x5f, %dl
movl $0x2e, %edx
cmovbl %edx, %ecx
movl %r13d, %edx
andl $0xf, %edx
movb %cl, 0x10(%rsp,%rdx)
leaq 0x10(%rsp), %rcx
movb $0x0, 0x1(%r14,%rcx)
incq %r13
cmpq %r13, 0x38(%rsp)
jne 0x10c8e
movq %rbx, %r14
movl 0xc(%rsp), %ecx
testb $0xf, %cl
je 0x10dc0
incl %ecx
leaq 0x68a8(%rip), %r12      # 0x17628
movl %ecx, %r13d
movq (%rsp), %r15
movl %ecx, %ebp
movslq %eax, %rbx
leaq (%r15,%rbx), %rdi
movl %r14d, %esi
subl %ebx, %esi
testl %esi, %esi
movl $0x0, %eax
cmovlel %eax, %esi
leaq 0x526d(%rip), %rdx      # 0x16013
movq %r12, %rcx
xorl %eax, %eax
callq 0x31e0
addl %ebx, %eax
incl %r13d
testb $0xf, %bpl
movl %r13d, %ecx
jne 0x10d87
jmp 0x10dc4
movq (%rsp), %r15
movslq %eax, %rbx
addq %rbx, %r15
subl %ebx, %r14d
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
leaq 0x6836(%rip), %rdx      # 0x17616
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x31e0
movl %eax, %r12d
addl %ebx, %r12d
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq