// File: alan0201tw[P]RayTracer/include/tiny_obj_loader.h
// Function: tinyobj::parseTriple(char const**, int, int, int, tinyobj::vertex_index_t*)
static bool parseTriple(const char **token, int vsize, int vnsize, int vtsize,
                        vertex_index_t *ret) {
  if (!ret) {
    return false;
  }

  vertex_index_t vi(-1);

  if (!fixIndex(atoi((*token)), vsize, &(vi.v_idx))) {
    return false;
  }

  (*token) += strcspn((*token), "/ \t\r");
  if ((*token)[0] != '/') {
    (*ret) = vi;
    return true;
  }
  (*token)++;

  // i//k
  if ((*token)[0] == '/') {
    (*token)++;
    if (!fixIndex(atoi((*token)), vnsize, &(vi.vn_idx))) {
      return false;
    }
    (*token) += strcspn((*token), "/ \t\r");
    (*ret) = vi;
    return true;
  }

  // i/j/k or i/j
  if (!fixIndex(atoi((*token)), vtsize, &(vi.vt_idx))) {
    return false;
  }

  (*token) += strcspn((*token), "/ \t\r");
  if ((*token)[0] != '/') {
    (*ret) = vi;
    return true;
  }

  // i/j/k
  (*token)++;  // skip '/'
  if (!fixIndex(atoi((*token)), vnsize, &(vi.vn_idx))) {
    return false;
  }
  (*token) += strcspn((*token), "/ \t\r");

  (*ret) = vi;

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x21249
movb $0x0, -0x1(%rbp)
jmp 0x21433
leaq -0x34(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2f5f0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7770
movl %eax, %edi
movl -0x14(%rbp), %esi
leaq -0x34(%rbp), %rdx
callq 0x2aea0
testb $0x1, %al
jne 0x2127e
movb $0x0, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x5d921(%rip), %rsi     # 0x7ebad
callq 0x7060
movq %rax, %rcx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x212c7
movq -0x28(%rbp), %rax
movq -0x34(%rbp), %rcx
movq %rcx, (%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x21357
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7770
movl %eax, %edi
movl -0x18(%rbp), %esi
leaq -0x34(%rbp), %rdx
addq $0x8, %rdx
callq 0x2aea0
testb $0x1, %al
jne 0x2131d
movb $0x0, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x5d882(%rip), %rsi     # 0x7ebad
callq 0x7060
movq %rax, %rcx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x34(%rbp), %rcx
movq %rcx, (%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7770
movl %eax, %edi
movl -0x1c(%rbp), %esi
leaq -0x34(%rbp), %rdx
addq $0x4, %rdx
callq 0x2aea0
testb $0x1, %al
jne 0x21382
movb $0x0, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x5d81d(%rip), %rsi     # 0x7ebad
callq 0x7060
movq %rax, %rcx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x213c8
movq -0x28(%rbp), %rax
movq -0x34(%rbp), %rcx
movq %rcx, (%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7770
movl %eax, %edi
movl -0x18(%rbp), %esi
leaq -0x34(%rbp), %rdx
addq $0x8, %rdx
callq 0x2aea0
testb $0x1, %al
jne 0x213fe
movb $0x0, -0x1(%rbp)
jmp 0x21433
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x5d7a1(%rip), %rsi     # 0x7ebad
callq 0x7060
movq %rax, %rcx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq -0x34(%rbp), %rcx
movq %rcx, (%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nop