// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x478, %rsp            # imm = 0x478
movl $0x0, 0x474(%rsp)
movl %edi, 0x470(%rsp)
movq %rsi, 0x468(%rsp)
leaq 0xe3b(%rip), %rax       # 0x2023
movq %rax, 0x450(%rsp)
leaq 0xe0d(%rip), %rax       # 0x2004
movq %rax, 0x448(%rsp)
leaq 0xe0a(%rip), %rax       # 0x2010
movq %rax, 0x440(%rsp)
leaq 0xe15(%rip), %rax       # 0x202a
movq %rax, 0x438(%rsp)
leaq 0xe15(%rip), %rax       # 0x2039
movq %rax, 0x430(%rsp)
leaq 0x1e(%rsp), %rdi
movq 0x430(%rsp), %rdx
movl $0x2, %esi
callq 0x10b0
movq %rax, 0x460(%rsp)
cmpq $0x2, 0x460(%rsp)
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
cmpl $0x0, 0x45c(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xdbf(%rip), %rsi       # 0x203b
movl $0x24, %edx
leaq 0xdc7(%rip), %rcx       # 0x204f
movb $0x0, %al
callq 0x1a90
movq 0x460(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x430(%rsp), %rdi
callq 0x1030
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xd78(%rip), %rsi       # 0x203b
movl $0x25, %edx
leaq 0xd80(%rip), %rcx       # 0x204f
movb $0x0, %al
callq 0x1a90
leaq 0x1e(%rsp), %rdi
movq 0x438(%rsp), %rdx
movl $0x2, %esi
callq 0x10b0
movq %rax, 0x460(%rsp)
cmpq $0x2, 0x460(%rsp)
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
movl 0x45c(%rsp), %edi
leaq 0xd20(%rip), %rsi       # 0x203b
movl $0x2a, %edx
leaq 0xd28(%rip), %rcx       # 0x204f
movb $0x0, %al
callq 0x1a90
movq 0x460(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x438(%rsp), %rdi
callq 0x1030
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xcd9(%rip), %rsi       # 0x203b
movl $0x2b, %edx
leaq 0xce1(%rip), %rcx       # 0x204f
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
movq 0x448(%rsp), %rdx
movq 0x450(%rsp), %r9
movl $0x400, %esi            # imm = 0x400
movl $0x2a, %ecx
movl $0x5c, %r8d
callq 0x1070
movq %rax, 0x460(%rsp)
cmpq $0x400, 0x460(%rsp) # imm = 0x400
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
cmpl $0x0, 0x45c(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xc60(%rip), %rsi       # 0x203b
movl $0x33, %edx
leaq 0xc77(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
movq 0x440(%rsp), %rsi
callq 0x1040
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xc29(%rip), %rsi       # 0x203b
movl $0x34, %edx
leaq 0xc40(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
movq 0x440(%rsp), %rdi
callq 0x1030
cmpq 0x460(%rsp), %rax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xbf2(%rip), %rsi       # 0x203b
movl $0x35, %edx
leaq 0xc09(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
leaq 0x1e(%rsp), %rdi
movq 0x448(%rsp), %rdx
movq 0x450(%rsp), %r9
movl $0x2, %esi
movl $0x2a, %ecx
movl $0x5c, %r8d
callq 0x1070
movq %rax, 0x460(%rsp)
cmpq $0x2, 0x460(%rsp)
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
movl 0x45c(%rsp), %edi
leaq 0xb87(%rip), %rsi       # 0x203b
movl $0x3c, %edx
leaq 0xb9e(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
movq 0x440(%rsp), %rdi
callq 0x1030
cmpq 0x460(%rsp), %rax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xb50(%rip), %rsi       # 0x203b
movl $0x3d, %edx
leaq 0xb67(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
movq 0x448(%rsp), %rdx
movq 0x450(%rsp), %r9
xorl %eax, %eax
movl %eax, %esi
movl $0x2a, %ecx
movl $0x5c, %r8d
movq %rsi, %rdi
callq 0x1070
movq %rax, 0x460(%rsp)
cmpq $0x2, 0x460(%rsp)
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
movl 0x45c(%rsp), %edi
leaq 0xae8(%rip), %rsi       # 0x203b
movl $0x43, %edx
leaq 0xaff(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
movq 0x440(%rsp), %rdi
callq 0x1030
cmpq 0x460(%rsp), %rax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xab1(%rip), %rsi       # 0x203b
movl $0x44, %edx
leaq 0xac8(%rip), %rcx       # 0x205e
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
leaq 0xa7c(%rip), %rdx       # 0x202a
xorl %eax, %eax
movl %eax, %ecx
callq 0x1060
movq %rax, 0x460(%rsp)
cmpq $0x400, 0x460(%rsp) # imm = 0x400
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
cmpl $0x0, 0x45c(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xa48(%rip), %rsi       # 0x203b
movl $0x49, %edx
leaq 0xa7a(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
leaq 0xa1e(%rip), %rsi       # 0x2030
callq 0x1040
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0xa12(%rip), %rsi       # 0x203b
movl $0x4a, %edx
leaq 0xa44(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
leaq 0x9dd(%rip), %rdx       # 0x202a
movl $0x1, %ecx
callq 0x1060
movq %rax, 0x460(%rsp)
cmpq $0x400, 0x460(%rsp) # imm = 0x400
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
cmpl $0x0, 0x45c(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x9a8(%rip), %rsi       # 0x203b
movl $0x4e, %edx
leaq 0x9da(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
leaq 0x9da(%rip), %rsi       # 0x208c
callq 0x1040
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x972(%rip), %rsi       # 0x203b
movl $0x4f, %edx
leaq 0x9a4(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
leaq 0x93d(%rip), %rdx       # 0x202a
movl $0x2, %ecx
callq 0x1060
movq %rax, 0x460(%rsp)
cmpq $0x400, 0x460(%rsp) # imm = 0x400
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
cmpl $0x0, 0x45c(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x908(%rip), %rsi       # 0x203b
movl $0x53, %edx
leaq 0x93a(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
leaq 0x925(%rip), %rsi       # 0x2077
callq 0x1040
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x8d2(%rip), %rsi       # 0x203b
movl $0x54, %edx
leaq 0x904(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
leaq 0x89d(%rip), %rdx       # 0x202a
movl $0x3, %ecx
callq 0x1060
movq %rax, 0x460(%rsp)
cmpq $0x400, 0x460(%rsp) # imm = 0x400
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x45c(%rsp)
cmpl $0x0, 0x45c(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x868(%rip), %rsi       # 0x203b
movl $0x58, %edx
leaq 0x89a(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x20(%rsp), %rdi
leaq 0x885(%rip), %rsi       # 0x2077
callq 0x1040
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x832(%rip), %rsi       # 0x203b
movl $0x59, %edx
leaq 0x864(%rip), %rcx       # 0x2079
movb $0x0, %al
callq 0x1a90
leaq 0x86f(%rip), %rax       # 0x2092
movq %rax, 0x428(%rsp)
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $0x1, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x7dc(%rip), %rsi       # 0x203b
movl $0x5e, %edx
leaq 0x87b(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $0x2, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x795(%rip), %rsi       # 0x203b
movl $0x60, %edx
leaq 0x834(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $0x1, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x74e(%rip), %rsi       # 0x203b
movl $0x62, %edx
leaq 0x7ed(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $0x2, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x707(%rip), %rsi       # 0x203b
movl $0x64, %edx
leaq 0x7a6(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $-0x1, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x6c0(%rip), %rsi       # 0x203b
movl $0x66, %edx
leaq 0x75f(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $-0x1, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x679(%rip), %rsi       # 0x203b
movl $0x68, %edx
leaq 0x718(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x1080
movq %rax, 0x428(%rsp)
cmpl $0x2, 0x458(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x632(%rip), %rsi       # 0x203b
movl $0x6a, %edx
leaq 0x6d1(%rip), %rcx       # 0x20e6
movb $0x0, %al
callq 0x1a90
movq 0x428(%rsp), %rdi
leaq 0x69e(%rip), %rsi       # 0x20c9
callq 0x1040
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
movq 0x428(%rsp), %r8
leaq 0x5f1(%rip), %rsi       # 0x203b
movl $0x6b, %edx
leaq 0x683(%rip), %rcx       # 0x20d9
movb $0x0, %al
callq 0x1a90
movq 0x2574(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
leaq 0x66e(%rip), %rsi       # 0x20dc
leaq 0x5c6(%rip), %rdx       # 0x203b
movb $0x0, %al
callq 0x1050
xorl %eax, %eax
addq $0x478, %rsp            # imm = 0x478
retq
nopw %cs:(%rax,%rax)