// File: /workspace/github_c_makefile_star2_O0/cktan[P]tomlc99/toml.c
// Function: toml_utf8_to_ucs
int toml_utf8_to_ucs(const char *orig, int len, int64_t *ret) {
  const unsigned char *buf = (const unsigned char *)orig;
  unsigned i = *buf++;
  int64_t v;

  /* 0x00000000 - 0x0000007F:
     0xxxxxxx
  */
  if (0 == (i >> 7)) {
    if (len < 1)
      return -1;
    v = i;
    return *ret = v, 1;
  }
  /* 0x00000080 - 0x000007FF:
     110xxxxx 10xxxxxx
  */
  if (0x6 == (i >> 5)) {
    if (len < 2)
      return -1;
    v = i & 0x1f;
    for (int j = 0; j < 1; j++) {
      i = *buf++;
      if (0x2 != (i >> 6))
        return -1;
      v = (v << 6) | (i & 0x3f);
    }
    return *ret = v, (const char *)buf - orig;
  }

  /* 0x00000800 - 0x0000FFFF:
     1110xxxx 10xxxxxx 10xxxxxx
  */
  if (0xE == (i >> 4)) {
    if (len < 3)
      return -1;
    v = i & 0x0F;
    for (int j = 0; j < 2; j++) {
      i = *buf++;
      if (0x2 != (i >> 6))
        return -1;
      v = (v << 6) | (i & 0x3f);
    }
    return *ret = v, (const char *)buf - orig;
  }

  /* 0x00010000 - 0x001FFFFF:
     11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
  */
  if (0x1E == (i >> 3)) {
    if (len < 4)
      return -1;
    v = i & 0x07;
    for (int j = 0; j < 3; j++) {
      i = *buf++;
      if (0x2 != (i >> 6))
        return -1;
      v = (v << 6) | (i & 0x3f);
    }
    return *ret = v, (const char *)buf - orig;
  }

  /* 0x00200000 - 0x03FFFFFF:
     111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
  */
  if (0x3E == (i >> 2)) {
    if (len < 5)
      return -1;
    v = i & 0x03;
    for (int j = 0; j < 4; j++) {
      i = *buf++;
      if (0x2 != (i >> 6))
        return -1;
      v = (v << 6) | (i & 0x3f);
    }
    return *ret = v, (const char *)buf - orig;
  }

  /* 0x04000000 - 0x7FFFFFFF:
     1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
  */
  if (0x7e == (i >> 1)) {
    if (len < 6)
      return -1;
    v = i & 0x01;
    for (int j = 0; j < 5; j++) {
      i = *buf++;
      if (0x2 != (i >> 6))
        return -1;
      v = (v << 6) | (i & 0x3f);
    }
    return *ret = v, (const char *)buf - orig;
  }
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movzbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
shrl $0x7, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1f38
cmpl $0x1, -0x14(%rbp)
jge 0x1f1a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movl -0x2c(%rbp), %eax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x229e
movl -0x2c(%rbp), %ecx
shrl $0x5, %ecx
movl $0x6, %eax
cmpl %ecx, %eax
jne 0x1fe6
cmpl $0x2, -0x14(%rbp)
jge 0x1f5d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movl -0x2c(%rbp), %eax
andl $0x1f, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jge 0x1fc8
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movzbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
shrl $0x6, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
je 0x1fa6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movq -0x38(%rbp), %rax
shlq $0x6, %rax
movl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f70
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x229e
movl -0x2c(%rbp), %ecx
shrl $0x4, %ecx
movl $0xe, %eax
cmpl %ecx, %eax
jne 0x2094
cmpl $0x3, -0x14(%rbp)
jge 0x200b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movl -0x2c(%rbp), %eax
andl $0xf, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x2, -0x40(%rbp)
jge 0x2076
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movzbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
shrl $0x6, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
je 0x2054
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movq -0x38(%rbp), %rax
shlq $0x6, %rax
movl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x201e
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x229e
movl -0x2c(%rbp), %ecx
shrl $0x3, %ecx
movl $0x1e, %eax
cmpl %ecx, %eax
jne 0x2142
cmpl $0x4, -0x14(%rbp)
jge 0x20b9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movl -0x2c(%rbp), %eax
andl $0x7, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x3, -0x44(%rbp)
jge 0x2124
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movzbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
shrl $0x6, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
je 0x2102
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movq -0x38(%rbp), %rax
shlq $0x6, %rax
movl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x20cc
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x229e
movl -0x2c(%rbp), %ecx
shrl $0x2, %ecx
movl $0x3e, %eax
cmpl %ecx, %eax
jne 0x21f0
cmpl $0x5, -0x14(%rbp)
jge 0x2167
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movl -0x2c(%rbp), %eax
andl $0x3, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
cmpl $0x4, -0x48(%rbp)
jge 0x21d2
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movzbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
shrl $0x6, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
je 0x21b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movq -0x38(%rbp), %rax
shlq $0x6, %rax
movl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x217a
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x229e
movl -0x2c(%rbp), %ecx
shrl %ecx
movl $0x7e, %eax
cmpl %ecx, %eax
jne 0x2297
cmpl $0x6, -0x14(%rbp)
jge 0x2214
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movl -0x2c(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $0x5, -0x4c(%rbp)
jge 0x227c
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movzbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
shrl $0x6, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
je 0x225a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x229e
movq -0x38(%rbp), %rax
shlq $0x6, %rax
movl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
orq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2227
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x229e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)