// File: /workspace/github_c_makefile_star2_O1/BatchLabs[P]msgpack-dump/src/cmp.c
// Function: cmp_skip_object_limit
bool cmp_skip_object_limit(cmp_ctx_t *ctx, cmp_object_t *obj, uint32_t limit) {
  size_t element_count = 1;
  uint32_t depth = 0;

  while (element_count) {
    uint8_t type_marker = 0;
    uint8_t cmp_type;
    uint32_t size = 0;

    if (!read_type_marker(ctx, &type_marker)) {
      return false;
    }

    if (!type_marker_to_cmp_type(type_marker, &cmp_type)) {
      ctx->error = INVALID_TYPE_ERROR;
      return false;
    }

    switch (cmp_type) {
      case CMP_TYPE_FIXARRAY:
      case CMP_TYPE_ARRAY16:
      case CMP_TYPE_ARRAY32:
      case CMP_TYPE_FIXMAP:
      case CMP_TYPE_MAP16:
      case CMP_TYPE_MAP32:
        depth++;

        if (depth > limit) {
          obj->type = cmp_type;

          if (!read_obj_data(ctx, type_marker, obj)) {
            return false;
          }

          ctx->error = SKIP_DEPTH_LIMIT_EXCEEDED_ERROR;

          return false;
        }

        break;
      default:
        if (!read_type_size(ctx, type_marker, cmp_type, &size)) {
          return false;
        }

        if (size) {
          switch (cmp_type) {
            case CMP_TYPE_FIXEXT1:
            case CMP_TYPE_FIXEXT2:
            case CMP_TYPE_FIXEXT4:
            case CMP_TYPE_FIXEXT8:
            case CMP_TYPE_FIXEXT16:
            case CMP_TYPE_EXT8:
            case CMP_TYPE_EXT16:
            case CMP_TYPE_EXT32:
              size++;
            default:
              break;
          }

          skip_bytes(ctx, size);
        }
    }

    element_count--;

    switch (cmp_type) {
      case CMP_TYPE_FIXARRAY:
      case CMP_TYPE_ARRAY16:
      case CMP_TYPE_ARRAY32:
        if (!read_type_size(ctx, type_marker, cmp_type, &size)) {
          return false;
        }
        element_count += size;
        break;
      case CMP_TYPE_FIXMAP:
      case CMP_TYPE_MAP16:
      case CMP_TYPE_MAP32:
        if (!read_type_size(ctx, type_marker, cmp_type, &size)) {
          return false;
        }
        element_count += ((size_t)size) * 2;
        break;
      default:
        break;
    }
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, -0x3c(%rbp)
movq %rsi, -0x48(%rbp)
movq %rdi, %r15
movl $0x0, -0x38(%rbp)
movl $0x1, %ebx
leaq -0x29(%rbp), %r14
movq %rbx, %r13
testq %rbx, %rbx
je 0x4978
movb $0x0, -0x29(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq *0x10(%r15)
testb %al, %al
je 0x48a1
movzbl -0x29(%rbp), %ebx
movl %ebx, %edi
leaq -0x31(%rbp), %rsi
callq 0x3f93
testb %al, %al
je 0x48a7
movzbl -0x31(%rbp), %r14d
cmpq $0x21, %r14
ja 0x48b6
movabsq $0x3c0000006, %rax      # imm = 0x3C0000006
btq %r14, %rax
jae 0x48b6
movl -0x38(%rbp), %eax
incl %eax
movl %eax, -0x38(%rbp)
cmpl -0x3c(%rbp), %eax
jbe 0x48f4
movq -0x48(%rbp), %rdx
movb %r14b, (%rdx)
movq %r15, %rdi
movl %ebx, %esi
callq 0x3fee
testb %al, %al
je 0x4940
movb $0x10, (%r15)
jmp 0x4940
movb $0x7, (%r15)
jmp 0x48ab
movb $0xd, (%r15)
xorl %r12d, %r12d
movq %r13, %rbx
jmp 0x496f
movzbl %r14b, %edx
movq %r15, %rdi
movl %ebx, %esi
leaq -0x30(%rbp), %rcx
callq 0x430c
testb %al, %al
je 0x4940
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0x48f4
cmpl $0x1a, %r14d
ja 0x48e9
movl $0x7c00e00, %ecx        # imm = 0x7C00E00
btl %r14d, %ecx
jae 0x48e9
incl %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %esi
movq %r15, %rdi
callq 0x4455
leaq -0x1(%r13), %rbx
movb $0x1, %r12b
cmpl $0x21, %r14d
ja 0x496b
movl %r14d, %eax
movl $0xc0000004, %ecx       # imm = 0xC0000004
btq %rax, %rcx
jb 0x4948
movabsq $0x300000002, %rcx      # imm = 0x300000002
btq %rax, %rcx
jae 0x496b
movzbl -0x29(%rbp), %esi
movzbl %r14b, %edx
movq %r15, %rdi
leaq -0x30(%rbp), %rcx
callq 0x430c
testb %al, %al
je 0x4968
movl -0x30(%rbp), %eax
leaq (%rbx,%rax,2), %rbx
jmp 0x496b
xorl %r12d, %r12d
movq %r13, %rbx
jmp 0x496b
movzbl -0x29(%rbp), %esi
movzbl %r14b, %edx
movq %r15, %rdi
leaq -0x30(%rbp), %rcx
callq 0x430c
testb %al, %al
je 0x4968
movl -0x30(%rbp), %eax
addq %rax, %rbx
jmp 0x496b
xorl %r12d, %r12d
leaq -0x29(%rbp), %r14
testb %r12b, %r12b
jne 0x481a
testq %r13, %r13
sete %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq