#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ _tap_is_str(char *, int, char *, char *, char *, char *,
                               char *);
int /*<<< orphan*/ free(char *);
char *globdir_escape_pattern(char *);
int tap_finish();
int /*<<< orphan*/ tap_plan(int);
int main(void) {
  tap_plan(4);
  {
    char *escaped = globdir_escape_pattern("foo/bar");
    _tap_is_str("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/andrewgregory/pacutils/refs/"
                "heads/master/ext/globdir.c/t/10-escape_pattern.c",
                17, escaped, "foo/bar", "%s -> %s",
                "foo/bar" ? "foo/bar" : "NULL", "foo/bar" ? "foo/bar" : "NULL");
    free(escaped);
  };
  {
    char *escaped = globdir_escape_pattern("fo*/bar");
    _tap_is_str("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/andrewgregory/pacutils/refs/"
                "heads/master/ext/globdir.c/t/10-escape_pattern.c",
                18, escaped, "fo\\*/bar", "%s -> %s",
                "fo*/bar" ? "fo*/bar" : "NULL",
                "fo\\*/bar" ? "fo\\*/bar" : "NULL");
    free(escaped);
  };
  {
    char *escaped = globdir_escape_pattern("\\?*[");
    _tap_is_str("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/andrewgregory/pacutils/refs/"
                "heads/master/ext/globdir.c/t/10-escape_pattern.c",
                19, escaped, "\\\\\\?\\*\\[", "%s -> %s",
                "\\?*[" ? "\\?*[" : "NULL",
                "\\\\\\?\\*\\[" ? "\\\\\\?\\*\\[" : "NULL");
    free(escaped);
  };
  {
    char *escaped = globdir_escape_pattern(NULL);
    _tap_is_str("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/andrewgregory/pacutils/refs/"
                "heads/master/ext/globdir.c/t/10-escape_pattern.c",
                20, escaped, NULL, "%s -> %s", NULL ? NULL : "NULL",
                NULL ? NULL : "NULL");
    free(escaped);
  };
  return tap_finish();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1040 <tap_plan@plt>
lea    0xe90(%rip),%rdi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe84(%rip),%rdi
mov    $0x11,%esi
lea    0xe70(%rip),%rax
lea    0xf18(%rip),%r8
mov    %rax,%rcx
mov    %rax,%r9
mov    %rax,(%rsp)
call   1060 <_tap_is_str@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xf07(%rip),%rdi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    0xe3e(%rip),%rdi
mov    $0x12,%esi
lea    0xeef(%rip),%rax
lea    0xed2(%rip),%r8
lea    0xed9(%rip),%r9
mov    %rax,%rcx
mov    %rax,(%rsp)
call   1060 <_tap_is_str@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xece(%rip),%rdi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
lea    0xdf4(%rip),%rdi
mov    $0x13,%esi
lea    0xeb3(%rip),%rax
lea    0xe88(%rip),%r8
lea    0xea0(%rip),%r9
mov    %rax,%rcx
mov    %rax,(%rsp)
call   1060 <_tap_is_str@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdx
lea    0xdad(%rip),%rdi
mov    $0x14,%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe44(%rip),%r8
lea    0xe46(%rip),%rax
mov    %rax,%r9
mov    %rax,(%rsp)
call   1060 <_tap_is_str@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1070 <tap_finish@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x4,%edi
call   1040 <tap_plan@plt>
lea    0xe97(%rip),%r12
mov    %r12,%rdi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,%rbx
mov    %r12,(%rsp)
lea    0xe89(%rip),%r15
lea    0xf29(%rip),%r14
mov    %r15,%rdi
mov    $0x11,%esi
mov    %rax,%rdx
mov    %r12,%rcx
mov    %r14,%r8
mov    %r12,%r9
call   1060 <_tap_is_str@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xf0f(%rip),%r12
mov    %r12,%rdi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,%rbx
lea    0xf05(%rip),%rcx
mov    %rcx,(%rsp)
mov    %r15,%rdi
mov    $0x12,%esi
mov    %rax,%rdx
mov    %r14,%r8
mov    %r12,%r9
call   1060 <_tap_is_str@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xee5(%rip),%r12
mov    %r12,%rdi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,%rbx
lea    0xed8(%rip),%rcx
mov    %rcx,(%rsp)
mov    %r15,%rdi
mov    $0x13,%esi
mov    %rax,%rdx
mov    %r14,%r8
mov    %r12,%r9
call   1060 <_tap_is_str@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1050 <globdir_escape_pattern@plt>
mov    %rax,%rbx
lea    0xe8a(%rip),%r9
mov    %r9,(%rsp)
mov    %r15,%rdi
mov    $0x14,%esi
mov    %rax,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
call   1060 <_tap_is_str@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <tap_finish@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"foo/bar\00"
@.str.1 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/andrewgregory/pacutils/refs/heads/master/ext/globdir.c/t/10-escape_pattern.c\00"
@.str.2 = [9 x i8] c"%s -> %s\00"
@.str.3 = [5 x i8] c"NULL\00"
@.str.4 = [8 x i8] c"fo*/bar\00"
@.str.5 = [9 x i8] c"fo\\*/bar\00"
@.str.6 = [5 x i8] c"\\?*[\00"
@.str.7 = [9 x i8] c"\\\\\\?\\*\\[\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i32 @tap_plan(i32 4)
%7 = call i8* @globdir_escape_pattern(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 17, i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %2
%11 = call i32 @free(i8* %10)
%12 = call i8* @globdir_escape_pattern(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 18, i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%15 = load i8*, i8** %3
%16 = call i32 @free(i8* %15)
%17 = call i8* @globdir_escape_pattern(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 19, i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = call i8* @globdir_escape_pattern(i8* null)
store i8* %22, i8** %5
%23 = load i8*, i8** %5
%24 = call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 20, i8* %23, i8* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = load i8*, i8** %5
%26 = call i32 @free(i8* %25)
%27 = call i32 (...) @tap_finish()
ret i32 %27
}

LLVM IR (-O2):
@.str = [8 x i8] c"foo/bar\00"
@.str.1 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/andrewgregory/pacutils/refs/heads/master/ext/globdir.c/t/10-escape_pattern.c\00"
@.str.2 = [9 x i8] c"%s -> %s\00"
@.str.3 = [5 x i8] c"NULL\00"
@.str.4 = [8 x i8] c"fo*/bar\00"
@.str.5 = [9 x i8] c"fo\\*/bar\00"
@.str.6 = [5 x i8] c"\\?*[\00"
@.str.7 = [9 x i8] c"\\\\\\?\\*\\[\00"
define i32 @main() {
%1 = tail call i32 @tap_plan(i32 4)
%2 = tail call i8* @globdir_escape_pattern(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 17, i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @free(i8* %2)
%5 = tail call i8* @globdir_escape_pattern(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 18, i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%7 = tail call i32 @free(i8* %5)
%8 = tail call i8* @globdir_escape_pattern(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 19, i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%10 = tail call i32 @free(i8* %8)
%11 = tail call i8* @globdir_escape_pattern(i8* null)
%12 = tail call i32 @_tap_is_str(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 20, i8* %11, i8* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @free(i8* %11)
%14 = tail call i32 (...) @tap_finish()
ret i32 %14
}