// File: /workspace/github_cpp_makefile_star2_O2/alan0201tw[P]RayTracer/include/tiny_obj_loader.h
// Function: tinyobj::ParseTextureNameAndOption(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, tinyobj::texture_option_t*, char const*)
bool ParseTextureNameAndOption(std::string *texname, texture_option_t *texopt,
                               const char *linebuf) {
  // @todo { write more robust lexer and parser. }
  bool found_texname = false;
  std::string texture_name;

  const char *token = linebuf;  // Assume line ends with NULL

  while (!IS_NEW_LINE((*token))) {
    token += strspn(token, " \t");  // skip space
    if ((0 == strncmp(token, "-blendu", 7)) && IS_SPACE((token[7]))) {
      token += 8;
      texopt->blendu = parseOnOff(&token, /* default */ true);
    } else if ((0 == strncmp(token, "-blendv", 7)) && IS_SPACE((token[7]))) {
      token += 8;
      texopt->blendv = parseOnOff(&token, /* default */ true);
    } else if ((0 == strncmp(token, "-clamp", 6)) && IS_SPACE((token[6]))) {
      token += 7;
      texopt->clamp = parseOnOff(&token, /* default */ true);
    } else if ((0 == strncmp(token, "-boost", 6)) && IS_SPACE((token[6]))) {
      token += 7;
      texopt->sharpness = parseReal(&token, 1.0);
    } else if ((0 == strncmp(token, "-bm", 3)) && IS_SPACE((token[3]))) {
      token += 4;
      texopt->bump_multiplier = parseReal(&token, 1.0);
    } else if ((0 == strncmp(token, "-o", 2)) && IS_SPACE((token[2]))) {
      token += 3;
      parseReal3(&(texopt->origin_offset[0]), &(texopt->origin_offset[1]),
                 &(texopt->origin_offset[2]), &token);
    } else if ((0 == strncmp(token, "-s", 2)) && IS_SPACE((token[2]))) {
      token += 3;
      parseReal3(&(texopt->scale[0]), &(texopt->scale[1]), &(texopt->scale[2]),
                 &token, 1.0, 1.0, 1.0);
    } else if ((0 == strncmp(token, "-t", 2)) && IS_SPACE((token[2]))) {
      token += 3;
      parseReal3(&(texopt->turbulence[0]), &(texopt->turbulence[1]),
                 &(texopt->turbulence[2]), &token);
    } else if ((0 == strncmp(token, "-type", 5)) && IS_SPACE((token[5]))) {
      token += 5;
      texopt->type = parseTextureType((&token), TEXTURE_TYPE_NONE);
    } else if ((0 == strncmp(token, "-imfchan", 8)) && IS_SPACE((token[8]))) {
      token += 9;
      token += strspn(token, " \t");
      const char *end = token + strcspn(token, " \t\r");
      if ((end - token) == 1) {  // Assume one char for -imfchan
        texopt->imfchan = (*token);
      }
      token = end;
    } else if ((0 == strncmp(token, "-mm", 3)) && IS_SPACE((token[3]))) {
      token += 4;
      parseReal2(&(texopt->brightness), &(texopt->contrast), &token, 0.0, 1.0);
    } else if ((0 == strncmp(token, "-colorspace", 11)) &&
               IS_SPACE((token[11]))) {
      token += 12;
      texopt->colorspace = parseString(&token);
    } else {
// Assume texture filename
#if 0
      size_t len = strcspn(token, " \t\r");  // untile next space
      texture_name = std::string(token, token + len);
      token += len;

      token += strspn(token, " \t");  // skip space
#else
      // Read filename until line end to parse filename containing whitespace
      // TODO(syoyo): Support parsing texture option flag after the filename.
      texture_name = std::string(token);
      token += texture_name.length();
#endif

      found_texname = true;
    }
  }

  if (found_texname) {
    (*texname) = texture_name;
    return true;
  } else {
    return false;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, 0x70(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x10(%rsi), %rax
movq %rax, 0x68(%rsp)
leaq 0x14(%rsi), %rax
movq %rax, 0x60(%rsp)
leaq 0x18(%rsi), %rax
movq %rax, 0x58(%rsp)
leaq 0x1c(%rsi), %rax
movq %rax, 0x50(%rsp)
leaq 0x20(%rsi), %rax
movq %rax, 0x48(%rsp)
leaq 0x24(%rsi), %rax
movq %rax, 0x40(%rsp)
leaq 0x28(%rsi), %rax
movq %rax, 0x30(%rsp)
leaq 0x2c(%rsi), %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsi), %rax
movq %rax, 0x20(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
leaq 0xc(%rsi), %rax
movq %rax, 0x10(%rsp)
leaq 0x40(%rsi), %rax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
leaq 0x24071(%rip), %r15     # 0x307b0
pushq $0x7
popq %r13
movzbl (%r12), %eax
cmpl $0xd, %eax
ja 0xc75b
movl $0x2401, %ecx           # imm = 0x2401
btl %eax, %ecx
jb 0xcc0e
movq %r12, %rdi
movq %r15, %rsi
callq 0x6180
movq %rax, %rbx
addq %r12, %rbx
movq %rbx, (%rsp)
movq %rbx, %rdi
leaq 0x24039(%rip), %rsi     # 0x307b3
movq %r13, %rdx
callq 0x61c0
testl %eax, %eax
je 0xc82e
movq %rbx, %rdi
leaq 0x24027(%rip), %rsi     # 0x307bb
movq %r13, %rdx
callq 0x61c0
testl %eax, %eax
je 0xc859
movq %rbx, %rdi
leaq 0x24015(%rip), %rsi     # 0x307c3
pushq $0x6
popq %rdx
callq 0x61c0
testl %eax, %eax
je 0xc884
movq %rbx, %rdi
leaq 0x24002(%rip), %rsi     # 0x307ca
pushq $0x6
popq %rdx
callq 0x61c0
testl %eax, %eax
je 0xc8af
movb (%rbx), %r12b
cmpb $0x2d, %r12b
jne 0xc999
cmpb $0x62, 0x1(%rbx)
jne 0xc8e4
cmpb $0x6d, 0x2(%rbx)
jne 0xc8e4
movzbl 0x3(%rbx), %eax
cmpl $0x20, %eax
je 0xc80b
cmpl $0x9, %eax
jne 0xc8e4
addq $0x4, %rbx
movq %rbx, (%rsp)
movq %rsp, %rdi
movsd 0x23c92(%rip), %xmm0    # 0x304b0
callq 0xccc7
movss %xmm0, 0x38(%r14)
jmp 0xcc05
movzbl 0x7(%rbx), %eax
cmpl $0x20, %eax
je 0xc840
cmpl $0x9, %eax
jne 0xc78a
addq $0x8, %rbx
movq %rbx, (%rsp)
movq %rsp, %rdi
callq 0xcc5e
movb %al, 0x36(%r14)
jmp 0xcc05
movzbl 0x7(%rbx), %eax
cmpl $0x20, %eax
je 0xc86b
cmpl $0x9, %eax
jne 0xc7a4
addq $0x8, %rbx
movq %rbx, (%rsp)
movq %rsp, %rdi
callq 0xcc5e
movb %al, 0x37(%r14)
jmp 0xcc05
movzbl 0x6(%rbx), %eax
cmpl $0x20, %eax
je 0xc896
cmpl $0x9, %eax
jne 0xc7be
addq $0x7, %rbx
movq %rbx, (%rsp)
movq %rsp, %rdi
callq 0xcc5e
movb %al, 0x34(%r14)
jmp 0xcc05
movzbl 0x6(%rbx), %eax
cmpl $0x20, %eax
je 0xc8c1
cmpl $0x9, %eax
jne 0xc7d8
addq $0x7, %rbx
movq %rbx, (%rsp)
movq %rsp, %rdi
movsd 0x23bdc(%rip), %xmm0    # 0x304b0
callq 0xccc7
movss %xmm0, 0x4(%r14)
jmp 0xcc05
cmpb $0x6f, 0x1(%rbx)
jne 0xc91a
movzbl 0x2(%rbx), %eax
cmpl $0x20, %eax
je 0xc8f8
cmpl $0x9, %eax
jne 0xc91a
addq $0x3, %rbx
movq %rbx, (%rsp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
jmp 0xc98c
cmpb $0x73, 0x1(%rbx)
jne 0xc958
movzbl 0x2(%rbx), %eax
cmpl $0x20, %eax
je 0xc92e
cmpl $0x9, %eax
jne 0xc958
addq $0x3, %rbx
movq %rbx, (%rsp)
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rsp, %rcx
movsd 0x23b60(%rip), %xmm0    # 0x304b0
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
jmp 0xc98f
cmpb $0x74, 0x1(%rbx)
jne 0xc999
movzbl 0x2(%rbx), %eax
cmpl $0x20, %eax
je 0xc96c
cmpl $0x9, %eax
jne 0xc999
addq $0x3, %rbx
movq %rbx, (%rsp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rsp, %rcx
callq 0xcd3c
jmp 0xcc05
movq %rbx, %rdi
leaq 0x23e2e(%rip), %rsi     # 0x307d1
pushq $0x5
popq %rdx
callq 0x61c0
testl %eax, %eax
je 0xca6f
movq %rbx, %rdi
leaq 0x23e1a(%rip), %rsi     # 0x307d7
pushq $0x8
popq %rdx
callq 0x61c0
testl %eax, %eax
je 0xcb72
cmpb $0x2d, %r12b
jne 0xca14
cmpb $0x6d, 0x1(%rbx)
jne 0xca14
cmpb $0x6d, 0x2(%rbx)
jne 0xca14
movzbl 0x3(%rbx), %eax
cmpl $0x20, %eax
je 0xc9ed
cmpl $0x9, %eax
jne 0xca14
addq $0x4, %rbx
movq %rbx, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rsp, %rdx
movsd 0x23aa6(%rip), %xmm0    # 0x304b0
callq 0xcd9f
jmp 0xcc05
movq %rbx, %rdi
leaq 0x23dc2(%rip), %rsi     # 0x307e0
pushq $0xb
popq %rdx
callq 0x61c0
testl %eax, %eax
je 0xcbc3
leaq 0x98(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
leaq 0xf(%rsp), %rdx
callq 0x1631a
leaq 0x78(%rsp), %rdi
movq %r12, %rsi
callq 0x64e0
movq %r12, %rdi
callq 0x61a0
addq 0x80(%rsp), %rbx
movq %rbx, (%rsp)
movb $0x1, %bpl
jmp 0xcc05
movzbl 0x5(%rbx), %eax
cmpl $0x20, %eax
je 0xca81
cmpl $0x9, %eax
jne 0xc9b3
addq $0x5, %rbx
movq %rbx, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6180
movq %rax, %r12
addq %rbx, %r12
movq %r12, (%rsp)
movq %r12, %rdi
leaq 0x242fd(%rip), %rsi     # 0x30da5
callq 0x6050
movq %rax, %rbx
movq %r12, %rdi
leaq 0x2427a(%rip), %rsi     # 0x30d34
pushq $0x8
popq %rdx
callq 0x61c0
pushq $0x2
popq %rcx
testl %eax, %eax
je 0xcb63
movq %r12, %rdi
leaq 0x24266(%rip), %rsi     # 0x30d3d
pushq $0xb
popq %rdx
callq 0x61c0
pushq $0x3
popq %rcx
testl %eax, %eax
je 0xcb63
movq %r12, %rdi
leaq 0x24259(%rip), %rsi     # 0x30d49
pushq $0x9
popq %rdx
callq 0x61c0
pushq $0x6
popq %rcx
testl %eax, %eax
je 0xcb63
movq %r12, %rdi
leaq 0x2424a(%rip), %rsi     # 0x30d53
pushq $0xa
popq %rdx
callq 0x61c0
pushq $0x7
popq %rcx
testl %eax, %eax
je 0xcb63
movq %r12, %rdi
leaq 0x2423c(%rip), %rsi     # 0x30d5e
pushq $0xa
popq %rdx
callq 0x61c0
pushq $0x4
popq %rcx
testl %eax, %eax
je 0xcb63
movq %r12, %rdi
leaq 0x2422e(%rip), %rsi     # 0x30d69
pushq $0x9
popq %rdx
callq 0x61c0
pushq $0x5
popq %rcx
testl %eax, %eax
je 0xcb63
movq %r12, %rdi
leaq 0x2421f(%rip), %rsi     # 0x30d73
pushq $0x6
popq %rdx
callq 0x61c0
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
addq %rbx, %r12
movq %r12, (%rsp)
movl %ecx, (%r14)
jmp 0xcc05
movzbl 0x8(%rbx), %eax
cmpl $0x20, %eax
je 0xcb84
cmpl $0x9, %eax
jne 0xc9cd
leaq 0x9(%rbx), %rdi
movq %rdi, (%rsp)
movq %r15, %rsi
callq 0x6180
addq %rax, %rbx
addq $0x9, %rbx
movq %rbx, (%rsp)
movq %rbx, %rdi
leaq 0x241fc(%rip), %rsi     # 0x30da5
callq 0x6050
cmpq $0x1, %rax
jne 0xcbba
movb (%rbx), %cl
movb %cl, 0x35(%r14)
addq %rax, %rbx
movq %rbx, (%rsp)
jmp 0xcc05
movzbl 0xb(%rbx), %eax
cmpl $0x20, %eax
je 0xcbd5
cmpl $0x9, %eax
jne 0xca2e
addq $0xc, %rbx
movq %rbx, (%rsp)
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
movq %rsp, %rsi
callq 0xcde4
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x64e0
movq %rbx, %rdi
callq 0x61a0
movq (%rsp), %r12
jmp 0xc743
testb $0x1, %bpl
je 0xcc23
leaq 0x78(%rsp), %rsi
movq 0x70(%rsp), %rdi
callq 0x6220
leaq 0x78(%rsp), %rdi
callq 0x61a0
andb $0x1, %bpl
movl %ebp, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcc49
jmp 0xcc49
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x61a0
movq %rbx, %rdi
callq 0x6710