#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int ndb_getDebugLevel();
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char *);
void ndb_unix_split(const char *s_files, char *pDir, char *pWild) {
  int iLastSep;
  int i;
  char pathfile[260];
  if (ndb_getDebugLevel() >= 5)
    fprintf(stdout, "ndb_unix_split: path+file '%s' -> ", s_files);
  pDir[0] = '\0';
  pWild[0] = '\0';
  strcpy(pathfile, s_files);
  iLastSep = -1;
  for (i = 0; pathfile[i] != '\0'; i++) {
    if ((pathfile[i] == '*') || (pathfile[i] == '?') || (pathfile[i] == '['))
      break;
    if ((pathfile[i] == '\\') || (pathfile[i] == '/'))
      iLastSep = i;
  }
  if (iLastSep > -1) {
    pathfile[iLastSep] = '\0';
    strcpy(pWild, &pathfile[iLastSep + 1]);
    strcpy(pDir, pathfile);
    if ((strlen(pDir) == 0) && (s_files[0] == '/')) {
      strcpy(pDir, "/");
    }
  } else {
    strcpy(pDir, ".");
    strcpy(pWild, pathfile);
  }
  if (ndb_getDebugLevel() >= 5)
    fprintf(stdout, "ndb_unix_split: path '%s', wildcard '%s'\n", pDir, pWild);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<ndb_unix_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1050 <ndb_getDebugLevel@plt>
cmp    $0x5,%eax
jl     1192 <ndb_unix_split+0x42>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     125a <ndb_unix_split+0x10a>
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x2a,%eax
je     1212 <ndb_unix_split+0xc2>
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x3f,%eax
je     1212 <ndb_unix_split+0xc2>
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x5b,%eax
jne    1217 <ndb_unix_split+0xc7>
jmp    125a <ndb_unix_split+0x10a>
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x5c,%eax
je     1241 <ndb_unix_split+0xf1>
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    1247 <ndb_unix_split+0xf7>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    124c <ndb_unix_split+0xfc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11be <ndb_unix_split+0x6e>
cmpl   $0xffffffff,-0x1c(%rbp)
jle    12d3 <ndb_unix_split+0x183>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x130(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0x130(%rbp),%rsi
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    12ce <ndb_unix_split+0x17e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12ce <ndb_unix_split+0x17e>
mov    -0x10(%rbp),%rdi
lea    0xd5a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12f3 <ndb_unix_split+0x1a3>
mov    -0x10(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1030 <strcpy@plt>
mov    $0x0,%al
call   1050 <ndb_getDebugLevel@plt>
cmp    $0x5,%eax
jl     1322 <ndb_unix_split+0x1d2>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ndb_unix_split>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xor    %eax,%eax
call   1040 <ndb_getDebugLevel@plt>
cmp    $0x5,%eax
jl     117d <ndb_unix_split+0x3d>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
movb   $0x0,(%r12)
movb   $0x0,(%r14)
mov    %rsp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    $0xffffffff,%eax
xor    %ecx,%ecx
movabs $0x4000000000020,%rdx
movabs $0x2000000200001,%rsi
jmp    11bd <ndb_unix_split+0x7d>
bt     %rbx,%rsi
jb     11d6 <ndb_unix_split+0x96>
test   %dil,%dil
je     11d6 <ndb_unix_split+0x96>
add    $0x1,%rcx
movzbl (%rsp,%rcx,1),%edi
lea    -0x2a(%rdi),%ebx
cmp    $0x32,%bl
ja     11b4 <ndb_unix_split+0x74>
movzbl %bl,%ebx
bt     %rbx,%rdx
jae    11ae <ndb_unix_split+0x6e>
mov    %ecx,%eax
jmp    11b9 <ndb_unix_split+0x79>
test   %eax,%eax
js     1214 <ndb_unix_split+0xd4>
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    (%rsp,%rax,1),%rsi
add    $0x1,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %rsp,%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
cmpb   $0x0,(%r12)
jne    122e <ndb_unix_split+0xee>
cmpb   $0x2f,(%r15)
jne    122e <ndb_unix_split+0xee>
lea    0xe14(%rip),%rsi
mov    %r12,%rdi
jmp    1229 <ndb_unix_split+0xe9>
lea    0xe0a(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1040 <ndb_getDebugLevel@plt>
cmp    $0x5,%eax
jl     1257 <ndb_unix_split+0x117>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [35 x i8] c"ndb_unix_split: path+file '%s' -> \00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [42 x i8] c"ndb_unix_split: path '%s', wildcard '%s'\0A\00"
define void @ndb_unix_split(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [260 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = call i32 (...) @ndb_getDebugLevel()
%11 = icmp sge i32 %10, 5
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* @stdout
%14 = load i8*, i8** %4
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %3
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 0, i8* %18
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 0
store i8 0, i8* %20
%21 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @strcpy(i8* %21, i8* %22)
store i32 -1, i32* %7
store i32 0, i32* %8
br label %24
24: ; preds = %70, %16
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %73
31: ; preds = %24
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 42
br i1 %37, label %52, label %38
38: ; preds = %31
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 63
br i1 %44, label %52, label %45
45: ; preds = %38
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 91
br i1 %51, label %52, label %53
52: ; preds = %45, %38, %31
br label %73
53: ; preds = %45
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 92
br i1 %59, label %67, label %60
60: ; preds = %53
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 47
br i1 %66, label %67, label %69
67: ; preds = %60, %53
%68 = load i32, i32* %8
store i32 %68, i32* %7
br label %69
69: ; preds = %67, %60
br label %70
70: ; preds = %69
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
br label %24
73: ; preds = %52, %24
%74 = load i32, i32* %7
%75 = icmp sgt i32 %74, -1
br i1 %75, label %76, label %102
76: ; preds = %73
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %78
store i8 0, i8* %79
%80 = load i8*, i8** %6
%81 = load i32, i32* %7
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 %83
%85 = call i32 @strcpy(i8* %80, i8* %84)
%86 = load i8*, i8** %5
%87 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 0
%88 = call i32 @strcpy(i8* %86, i8* %87)
%89 = load i8*, i8** %5
%90 = call i64 @strlen(i8* %89)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %101
92: ; preds = %76
%93 = load i8*, i8** %4
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 47
br i1 %97, label %98, label %101
98: ; preds = %92
%99 = load i8*, i8** %5
%100 = call i32 @strcpy(i8* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %101
101: ; preds = %98, %92, %76
br label %108
102: ; preds = %73
%103 = load i8*, i8** %5
%104 = call i32 @strcpy(i8* %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%105 = load i8*, i8** %6
%106 = getelementptr inbounds [260 x i8], [260 x i8]* %9, i64 0, i64 0
%107 = call i32 @strcpy(i8* %105, i8* %106)
br label %108
108: ; preds = %102, %101
%109 = call i32 (...) @ndb_getDebugLevel()
%110 = icmp sge i32 %109, 5
br i1 %110, label %111, label %116
111: ; preds = %108
%112 = load i32, i32* @stdout
%113 = load i8*, i8** %5
%114 = load i8*, i8** %6
%115 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %113, i8* %114)
br label %116
116: ; preds = %111, %108
%117 = load i32, i32* @stdout
%118 = call i32 @fflush(i32 %117)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [35 x i8] c"ndb_unix_split: path+file '%s' -> \00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [42 x i8] c"ndb_unix_split: path '%s', wildcard '%s'\0A\00"
define void @ndb_unix_split(i8* %0, i8* %1, i8* %2) {
%4 = alloca [260 x i8]
%5 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (...) @ndb_getDebugLevel()
%7 = icmp sgt i32 %6, 4
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i32, i32* @stdout
%10 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %8, %3
store i8 0, i8* %1
store i8 0, i8* %2
%12 = call i32 @strcpy(i8* %5, i8* %0)
br label %13
13: ; preds = %20, %11
%14 = phi i64 [ %22, %20 ], [ 0, %11 ]
%15 = phi i32 [ %21, %20 ], [ -1, %11 ]
%16 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 %14
%17 = load i8, i8* %16
switch i8 %17, label %20 [
i8 0, label %23
i8 42, label %23
i8 63, label %23
i8 91, label %23
i8 92, label %18
i8 47, label %18
]
18: ; preds = %13, %13
%19 = trunc i64 %14 to i32
br label %20
20: ; preds = %13, %18
%21 = phi i32 [ %19, %18 ], [ %15, %13 ]
%22 = add nuw i64 %14, 1
br label %13
23: ; preds = %13, %13, %13, %13
%24 = icmp sgt i32 %15, -1
br i1 %24, label %25, label %40
25: ; preds = %23
%26 = zext i32 %15 to i64
%27 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 %26
store i8 0, i8* %27
%28 = add nuw nsw i32 %15, 1
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 %29
%31 = call i32 @strcpy(i8* %2, i8* %30)
%32 = call i32 @strcpy(i8* %1, i8* %5)
%33 = load i8, i8* %1
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %25
%36 = load i8, i8* %0
%37 = icmp eq i8 %36, 47
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %43
40: ; preds = %23
%41 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @strcpy(i8* %2, i8* %5)
br label %43
43: ; preds = %25, %35, %38, %40
%44 = call i32 (...) @ndb_getDebugLevel()
%45 = icmp sgt i32 %44, 4
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* @stdout
%48 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %2)
br label %49
49: ; preds = %46, %43
%50 = load i32, i32* @stdout
%51 = call i32 @fflush(i32 %50)
ret void
}