// File: /workspace/github_c_makefile_star2_O1/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 0xe41(%rip), %rdx       # 0x2065
leaq 0xa(%rsp), %r15
movl $0x2, %esi
movq %r15, %rdi
callq 0x10b0
movq %rax, %rbx
xorl %edi, %edi
cmpq $0x2, %rax
setb %dil
leaq 0xe31(%rip), %r14       # 0x207b
movl $0x24, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpq $0x1, %rbx
sete %dil
movl $0x25, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
leaq 0xddd(%rip), %rdx       # 0x2056
movl $0x2, %esi
movq %r15, %rdi
callq 0x10b0
movq %rax, %rbx
xorl %edi, %edi
cmpq $0x2, %rax
setae %dil
movl $0x2a, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpq $0xe, %rbx
sete %dil
movl $0x2b, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
leaq 0xd6e(%rip), %rbp       # 0x2030
leaq 0xd86(%rip), %r13       # 0x204f
leaq 0x10(%rsp), %r14
movl $0x400, %r12d           # imm = 0x400
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
movq %rbp, %rdx
movl $0x2a, %ecx
movl $0x5c, %r8d
movq %r13, %r9
callq 0x1070
movq %rax, %rbx
xorl %edi, %edi
cmpq %r12, %rax
setb %dil
leaq 0xd85(%rip), %r12       # 0x208a
movl $0x33, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
movdqu 0xa(%r14), %xmm0
pcmpeqb 0xcee(%rip), %xmm0      # 0x2010
movdqa (%r14), %xmm1
pcmpeqb 0xcf1(%rip), %xmm1      # 0x2020
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
xorl %edi, %edi
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %dil
movl $0x34, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpq $0x19, %rbx
sete %dil
movl $0x35, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
movl $0x2, %esi
movq %r15, %rdi
movq %rbp, %rdx
movl $0x2a, %ecx
movl $0x5c, %r8d
movq %r13, %r9
callq 0x1070
movq %rax, %rbx
xorl %edi, %edi
cmpq $0x2, %rax
setae %dil
movl $0x3c, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpq $0x19, %rbx
sete %dil
movl $0x3d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
xorl %esi, %esi
movq %rbp, %rdx
movl $0x2a, %ecx
movl $0x5c, %r8d
movq %r13, %r9
callq 0x1070
movq %rax, %rbx
xorl %edi, %edi
cmpq $0x2, %rax
setae %dil
movl $0x43, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpq $0x19, %rbx
sete %dil
movl $0x44, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x16d6
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
leaq 0xc3b(%rip), %rbx       # 0x2056
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x1060
xorl %edi, %edi
movl $0x400, %r12d           # imm = 0x400
cmpq %r12, %rax
setb %dil
leaq 0xc6a(%rip), %r15       # 0x20a5
movl $0x49, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
movabsq $0x7a672e7261742e64, %rax # imm = 0x7A672E7261742E64
xorq (%r14), %rax
movzbl 0x8(%r14), %ecx
xorl %edi, %edi
orq %rax, %rcx
sete %dil
movl $0x4a, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
movl $0x400, %esi            # imm = 0x400
movl $0x1, %ecx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1060
xorl %edi, %edi
cmpq %r12, %rax
movl $0x400, %r12d           # imm = 0x400
setb %dil
movl $0x4e, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
movl $0x61742e64, %eax       # imm = 0x61742E64
xorl (%r14), %eax
movzwl 0x4(%r14), %ecx
xorl $0x72, %ecx
xorl %edi, %edi
orl %eax, %ecx
sete %dil
movl $0x4f, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
movl $0x400, %esi            # imm = 0x400
movl $0x2, %ecx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1060
xorl %edi, %edi
cmpq %r12, %rax
setb %dil
movl $0x53, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpw $0x64, (%r14)
sete %dil
movl $0x54, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
movl $0x400, %esi            # imm = 0x400
movl $0x3, %ecx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1060
xorl %edi, %edi
cmpq %r12, %rax
setb %dil
movl $0x58, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
xorl %edi, %edi
cmpw $0x64, (%r14)
sete %dil
movl $0x59, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x16d6
leaq 0xb5b(%rip), %rdi       # 0x20be
leaq 0xc(%rsp), %rbx
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $0x1, (%rbx)
sete %dil
leaq 0xb8f(%rip), %r14       # 0x2112
movl $0x5e, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $0x2, (%rbx)
sete %dil
movl $0x60, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $0x1, (%rbx)
sete %dil
movl $0x62, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $0x2, (%rbx)
sete %dil
movl $0x64, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $-0x1, (%rbx)
sete %dil
movl $0x66, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $-0x1, (%rbx)
sete %dil
movl $0x68, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
movq %rax, %r15
xorl %edi, %edi
cmpl $0x2, (%rbx)
sete %dil
movl $0x6a, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x16d6
leaq 0xa78(%rip), %rsi       # 0x20f5
movq %r15, %rdi
callq 0x1040
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xa71(%rip), %rcx       # 0x2105
movl $0x6b, %edx
movq %r15, %r8
xorl %eax, %eax
callq 0x16d6
movq 0x292e(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
leaq 0xa54(%rip), %rsi       # 0x2108
leaq 0x9ac(%rip), %rdx       # 0x2067
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