// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/src/test_stringop.c
// Function: main
int
main (int argc VL_UNUSED, char *argv[] VL_UNUSED)
{
  vl_size q ;
  int err, protocol ;
  char const *repl  = "vision" ;
  char const *str   = "*: * '\\*' *" ;
  char const *subst = "vision: vision '*' vision" ;
  char const *t1   = "a/b/c/d.tar.gz" ;
  char const *t3   = "t" ;
  char const *next ;

  enum { buf_len = 1024 } ;
  char buf [buf_len] ;

  enum { sml_len = 2 } ;
  char sml [sml_len] ;

  /* -------------------------------------------------------------- */

  /* t3 fits in the destination buffer */
  q = vl_string_copy (sml, sml_len, t3) ;
  err = (q >= sml_len) ;
  check (! err, "vl_string_copy") ;
  check (q == strlen(t3), "vl_string_copy") ;

  /* t1 does not fit in the destination buffer */
  q = vl_string_copy (sml, sml_len, t1) ;
  err = (q >= sml_len) ;
  check (err, "vl_string_copy") ;
  check (q == strlen(t1), "vl_string_copy") ;

  /* -------------------------------------------------------------- */

  /* check substitution with widcard */
  q = vl_string_replace_wildcard (buf, buf_len,
                                  str, '*', '\\', repl) ;
  err = (q >= buf_len) ;
  check (! err, "vl_string_replace_wildcard") ;
  check (strcmp(buf, subst) == 0, "vl_string_replace_wildcard") ;
  check (strlen(subst) == q, "vl_string_replace_wildcard") ;


  /* and the case in which the destination buffer is too small */
  q = vl_string_replace_wildcard (sml, sml_len,
                                  str, '*', '\\', repl) ;
  err = (q >= sml_len) ;
  check (err, "vl_string_replace_wildcard") ;
  check (strlen(subst) == q, "vl_string_replace_wildcard") ;

  /* and without output string */
  q = vl_string_replace_wildcard (0,0,
                                  str, '*', '\\', repl) ;
  err = (q >= sml_len) ;
  check (err, "vl_string_replace_wildcard") ;
  check (strlen(subst) == q, "vl_string_replace_wildcard") ;

  /* -------------------------------------------------------------- */
  q = vl_string_basename (buf, buf_len, "a/b/c/d.tar.gz", 0) ;
  err = (q >= buf_len) ;
  check (! err, "vl_string_basename") ;
  check (strcmp(buf, "d.tar.gz") == 0, "vl_string_basename") ;

  q = vl_string_basename (buf, buf_len, "a/b/c/d.tar.gz", 1) ;
  err = (q >= buf_len) ;
  check (! err, "vl_string_basename") ;
  check (strcmp(buf, "d.tar") == 0, "vl_string_basename") ;

  q = vl_string_basename (buf, buf_len, "a/b/c/d.tar.gz", 2) ;
  err = (q >= buf_len) ;
  check (! err, "vl_string_basename") ;
  check (strcmp(buf, "d") == 0, "vl_string_basename") ;

  q = vl_string_basename (buf, buf_len, "a/b/c/d.tar.gz", 3) ;
  err = (q >= buf_len) ;
  check (! err, "vl_string_basename") ;
  check (strcmp(buf, "d") == 0, "vl_string_basename") ;

  /* -------------------------------------------------------------- */
  next = "ascii://bin://ascii://bin://unkown1://unknown2://bin:///which remains/" ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_ASCII,) ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_BINARY,) ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_ASCII,) ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_BINARY,) ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_UNKNOWN,) ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_UNKNOWN,) ;
  next = vl_string_parse_protocol(next, &protocol) ;
  check (protocol == VL_PROT_BINARY,) ;
  check (strcmp(next, "/which remains/") == 0,"%s",next) ;

  check_signoff() ;
  return 0 ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
leaq 0xe55(%rip), %rdx       # 0x2039
leaq 0xa(%rsp), %r12
pushq $0x2
popq %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x10c0
movq %rax, %r14
xorl %edi, %edi
cmpq $0x2, %rax
setb %dil
leaq 0xe43(%rip), %rbx       # 0x204f
pushq $0x24
popq %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpq $0x1, %r14
sete %dil
pushq $0x25
popq %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xdf3(%rip), %rdx       # 0x202a
movq %r12, %rdi
movq %r15, %rsi
callq 0x10c0
movq %rax, %r14
xorl %edi, %edi
cmpq $0x2, %rax
setae %dil
pushq $0x2a
popq %r15
movl %r15d, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpq $0xe, %r14
sete %dil
pushq $0x2b
popq %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xd86(%rip), %r12       # 0x2004
leaq 0xd9e(%rip), %r9        # 0x2023
leaq 0x10(%rsp), %r14
movl $0x400, %r13d           # imm = 0x400
pushq $0x5c
popq %r8
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
movq %r12, %rdx
movl %r15d, %ecx
movl %r8d, %ebp
callq 0x1080
movq %rax, %rbx
xorl %edi, %edi
cmpq %r13, %rax
setb %dil
leaq 0xda1(%rip), %r13       # 0x205e
pushq $0x33
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xd3f(%rip), %rsi       # 0x2010
pushq $0x1a
popq %rdx
movq %r14, %rdi
callq 0x1070
xorl %edi, %edi
testl %eax, %eax
sete %dil
pushq $0x34
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpq $0x19, %rbx
sete %dil
pushq $0x35
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xa(%rsp), %rdi
pushq $0x2
popq %rsi
movq %r12, %rdx
movl %r15d, %ecx
movl %ebp, %r8d
leaq 0xd03(%rip), %r9        # 0x2023
callq 0x1080
movq %rax, %rbx
xorl %edi, %edi
cmpq $0x2, %rax
setae %dil
pushq $0x3c
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpq $0x19, %rbx
sete %dil
pushq $0x3d
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
xorl %esi, %esi
movq %r12, %rdx
movl %r15d, %ecx
movl %ebp, %r8d
leaq 0xcb9(%rip), %r9        # 0x2023
callq 0x1080
movq %rax, %rbx
xorl %edi, %edi
cmpq $0x2, %rax
setae %dil
pushq $0x43
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpq $0x19, %rbx
sete %dil
pushq $0x44
popq %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1648
movl $0x400, %esi            # imm = 0x400
movq %r14, %r15
movq %r14, %rdi
leaq 0xc78(%rip), %rbx       # 0x202a
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x1060
xorl %edi, %edi
movl $0x400, %r14d           # imm = 0x400
cmpq %r14, %rax
setb %dil
leaq 0xca7(%rip), %r12       # 0x2079
pushq $0x49
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xc4a(%rip), %rsi       # 0x2030
pushq $0x9
popq %rdx
movq %r15, %rdi
callq 0x1070
xorl %edi, %edi
testl %eax, %eax
sete %dil
pushq $0x4a
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
pushq $0x1
popq %rcx
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdi
movq %rbx, %rdx
callq 0x1060
xorl %edi, %edi
cmpq %r14, %rax
movl $0x400, %r14d           # imm = 0x400
setb %dil
pushq $0x4e
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xc50(%rip), %rsi       # 0x208c
pushq $0x6
popq %rdx
movq %r15, %rdi
callq 0x1070
xorl %edi, %edi
testl %eax, %eax
sete %dil
pushq $0x4f
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdi
movq %rbx, %rdx
pushq $0x2
popq %rcx
callq 0x1060
xorl %edi, %edi
cmpq %r14, %rax
setb %dil
pushq $0x53
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpw $0x64, (%r15)
sete %dil
pushq $0x54
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
pushq $0x3
popq %rcx
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdi
movq %rbx, %rdx
callq 0x1060
xorl %edi, %edi
cmpq %r14, %rax
setb %dil
pushq $0x58
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
xorl %edi, %edi
cmpw $0x64, (%r15)
sete %dil
pushq $0x59
popq %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xbad(%rip), %rdi       # 0x2092
leaq 0xc(%rsp), %rbx
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $0x1, (%rbx)
sete %dil
leaq 0xbe1(%rip), %r14       # 0x20e6
pushq $0x5e
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $0x2, (%rbx)
sete %dil
pushq $0x60
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $0x1, (%rbx)
sete %dil
pushq $0x62
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $0x2, (%rbx)
sete %dil
pushq $0x64
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $-0x1, (%rbx)
sete %dil
pushq $0x66
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $-0x1, (%rbx)
sete %dil
pushq $0x68
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1090
movq %rax, %r15
xorl %edi, %edi
cmpl $0x2, (%rbx)
sete %dil
pushq $0x6a
popq %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1648
leaq 0xad8(%rip), %rsi       # 0x20c9
movq %r15, %rdi
callq 0x1040
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xad1(%rip), %rcx       # 0x20d9
pushq $0x6b
popq %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x1648
movq 0x29bc(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
leaq 0xab6(%rip), %rsi       # 0x20dc
leaq 0xa0e(%rip), %rdx       # 0x203b
xorl %eax, %eax
callq 0x1050
xorl %eax, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq