#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*/ __assert_int_equal(char *, int, int, int, char *);
int /*<<< orphan*/ __assert_string_equal(char *, char *, char *, int, char *);
int /*<<< orphan*/ parse_path(char *, char **, int, int *);
int /*<<< orphan*/ path_resolve(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ test_case_begin(char *);
int /*<<< orphan*/ test_case_end();
int /*<<< orphan*/ test_case_summary();
void testPathParser() {
  int count;
  char *parts[16];
  test_case_begin("Path parser test case");
  char path[128] = "/home/dir/abc.txt";
  char path2[128];
  parse_path(path, parts, 16, &count);
  __assert_int_equal("/home/dir/abc.txt should be parsed to 3 parts", 3, count,
                     63,
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/morningsend/zkernel/"
                     "refs/heads/master/fs/test/testfs.c");
  ;
  __assert_string_equal(
      "part 1 should be home", "home", parts[0], 64,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  __assert_string_equal(
      "part 2 should be dir", "dir", parts[1], 65,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  __assert_string_equal(
      "part 3 should be abc.txt", "abc.txt", parts[2], 66,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  strcpy(path, "/home/dir/ccc/");
  parse_path(path, parts, 16, &count);
  __assert_int_equal("path with trailing slash is will be parsed as normal, "
                     "e.g. /home/dir/ccc/",
                     3, count, 70,
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/morningsend/zkernel/"
                     "refs/heads/master/fs/test/testfs.c");
  ;
  __assert_string_equal(
      "dir with trailing slash will be parsed to name without slash", "ccc",
      parts[2], 71,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  strcpy(path, "home");
  parse_path(path, parts, 16, &count);
  __assert_int_equal("path with no slashes should parsed as one file", 1, count,
                     75,
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/morningsend/zkernel/"
                     "refs/heads/master/fs/test/testfs.c");
  ;
  __assert_string_equal(
      "parsing 'home' should produce 'home'", "home", parts[0], 76,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  strcpy(path, "/hello");
  path_resolve(path, "world", path2);
  __assert_string_equal(
      "path resolve joins path together", path2, "/hello/world", 79,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  strcpy(path, "/hello");
  path_resolve(path, "/world", path2);
  __assert_string_equal(
      "path starts with / will be resolve relative to root", path2, "/world",
      82,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/"
      "testfs.c");
  ;
  test_case_end();
  test_case_summary();
}


x86 assembly (clang, -O0):
<testPathParser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
lea    0xe5e(%rip),%rdi
call   1050 <test_case_begin@plt>
lea    -0x110(%rbp),%rdi
lea    0x10bb(%rip),%rsi
mov    $0x80,%edx
call   1080 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x10,%edx
lea    -0x4(%rbp),%rcx
call   10a0 <parse_path@plt>
mov    -0x4(%rbp),%edx
lea    0xe31(%rip),%rdi
mov    $0x3,%esi
mov    $0x3f,%ecx
lea    0xe4e(%rip),%r8
call   1070 <__assert_int_equal@plt>
mov    -0x90(%rbp),%rdx
lea    0xecc(%rip),%rdi
lea    0xed6(%rip),%rsi
mov    $0x40,%ecx
lea    0xe28(%rip),%r8
call   10b0 <__assert_string_equal@plt>
mov    -0x88(%rbp),%rdx
lea    0xebc(%rip),%rdi
lea    0xec6(%rip),%rsi
mov    $0x41,%ecx
lea    0xe02(%rip),%r8
call   10b0 <__assert_string_equal@plt>
mov    -0x80(%rbp),%rdx
lea    0xeae(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x42,%ecx
lea    0xddf(%rip),%r8
call   10b0 <__assert_string_equal@plt>
lea    -0x110(%rbp),%rdi
lea    0xedc(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x10,%edx
lea    -0x4(%rbp),%rcx
call   10a0 <parse_path@plt>
mov    -0x4(%rbp),%edx
lea    0xe76(%rip),%rdi
mov    $0x3,%esi
mov    $0x46,%ecx
lea    0xd90(%rip),%r8
call   1070 <__assert_int_equal@plt>
mov    -0x80(%rbp),%rdx
lea    0xe9f(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    $0x47,%ecx
lea    0xd6d(%rip),%r8
call   10b0 <__assert_string_equal@plt>
lea    -0x110(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x10,%edx
lea    -0x4(%rbp),%rcx
call   10a0 <parse_path@plt>
mov    -0x4(%rbp),%edx
lea    0xe8f(%rip),%rdi
mov    $0x1,%esi
mov    $0x4b,%ecx
lea    0xd1e(%rip),%r8
call   1070 <__assert_int_equal@plt>
mov    -0x90(%rbp),%rdx
lea    0xe9a(%rip),%rdi
lea    0xda6(%rip),%rsi
mov    $0x4c,%ecx
lea    0xcf8(%rip),%r8
call   10b0 <__assert_string_equal@plt>
lea    -0x110(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x190(%rbp),%rdx
lea    0xeae(%rip),%rsi
call   1060 <path_resolve@plt>
lea    -0x190(%rbp),%rsi
lea    0xe73(%rip),%rdi
lea    0xe8d(%rip),%rdx
mov    $0x4f,%ecx
lea    0xca5(%rip),%r8
call   10b0 <__assert_string_equal@plt>
lea    -0x110(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x190(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1060 <path_resolve@plt>
lea    -0x190(%rbp),%rsi
lea    0xe4e(%rip),%rdi
lea    0xe40(%rip),%rdx
mov    $0x52,%ecx
lea    0xc52(%rip),%r8
call   10b0 <__assert_string_equal@plt>
mov    $0x0,%al
call   1040 <test_case_end@plt>
mov    $0x0,%al
call   1090 <test_case_summary@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testPathParser>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
lea    0xe68(%rip),%rdi
call   1050 <test_case_begin@plt>
movaps 0x113c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0x111d(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0x1101(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0x10e5(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x10c9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x10ad(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x1091(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x1075(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r14
lea    0x90(%rsp),%r15
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1090 <parse_path@plt>
mov    0xc(%rsp),%edx
lea    0xde6(%rip),%rdi
lea    0xe0d(%rip),%r12
mov    $0x3,%esi
mov    $0x3f,%ecx
mov    %r12,%r8
call   1070 <__assert_int_equal@plt>
mov    0x90(%rsp),%rdx
lea    0xe7d(%rip),%rdi
lea    0xe87(%rip),%r13
mov    %r13,%rsi
mov    $0x40,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
mov    0x98(%rsp),%rdx
lea    0xe6d(%rip),%rdi
lea    0xe77(%rip),%rsi
mov    $0x41,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
mov    0xa0(%rsp),%rdx
lea    0xe5f(%rip),%rdi
lea    0xe69(%rip),%rsi
mov    $0x42,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1090 <parse_path@plt>
mov    0xc(%rsp),%edx
lea    0xe37(%rip),%rdi
mov    $0x3,%esi
mov    $0x46,%ecx
mov    %r12,%r8
call   1070 <__assert_int_equal@plt>
mov    0xa0(%rsp),%rdx
lea    0xe60(%rip),%rdi
lea    0xe96(%rip),%rsi
mov    $0x47,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1090 <parse_path@plt>
mov    0xc(%rsp),%edx
lea    0xe64(%rip),%rdi
mov    $0x1,%esi
mov    $0x4b,%ecx
mov    %r12,%r8
call   1070 <__assert_int_equal@plt>
mov    0x90(%rsp),%rdx
lea    0xe72(%rip),%rdi
mov    %r13,%rsi
mov    $0x4c,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
lea    0xe80(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe9d(%rip),%rsi
lea    0x110(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <path_resolve@plt>
lea    0xe5b(%rip),%rdi
lea    0xe75(%rip),%rdx
mov    %rbx,%rsi
mov    $0x4f,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe59(%rip),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <path_resolve@plt>
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    $0x52,%ecx
mov    %r12,%r8
call   10a0 <__assert_string_equal@plt>
xor    %eax,%eax
call   1040 <test_case_end@plt>
xor    %eax,%eax
call   1080 <test_case_summary@plt>
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Path parser test case\00"
@__const.testPathParser.path = [128 x i8] c"/home/dir/abc.txt\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [46 x i8] c"/home/dir/abc.txt should be parsed to 3 parts\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/testfs.c\00"
@.str.3 = [22 x i8] c"part 1 should be home\00"
@.str.4 = [5 x i8] c"home\00"
@.str.5 = [21 x i8] c"part 2 should be dir\00"
@.str.6 = [4 x i8] c"dir\00"
@.str.7 = [25 x i8] c"part 3 should be abc.txt\00"
@.str.8 = [8 x i8] c"abc.txt\00"
@.str.9 = [15 x i8] c"/home/dir/ccc/\00"
@.str.10 = [74 x i8] c"path with trailing slash is will be parsed as normal, e.g. /home/dir/ccc/\00"
@.str.11 = [61 x i8] c"dir with trailing slash will be parsed to name without slash\00"
@.str.12 = [4 x i8] c"ccc\00"
@.str.13 = [47 x i8] c"path with no slashes should parsed as one file\00"
@.str.14 = [37 x i8] c"parsing 'home' should produce 'home'\00"
@.str.15 = [7 x i8] c"/hello\00"
@.str.16 = [6 x i8] c"world\00"
@.str.17 = [33 x i8] c"path resolve joins path together\00"
@.str.18 = [13 x i8] c"/hello/world\00"
@.str.19 = [7 x i8] c"/world\00"
@.str.20 = [52 x i8] c"path starts with / will be resolve relative to root\00"
define void @testPathParser() {
%1 = alloca i32
%2 = alloca [16 x i8*]
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = call i32 @test_case_begin(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = bitcast [128 x i8]* %3 to i8*
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%9 = call i32 @parse_path(i8* %7, i8** %8, i32 16, i32* %1)
%10 = load i32, i32* %1
%11 = call i32 @__assert_int_equal(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %10, i32 63, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %13, i32 64, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %16, i32 65, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%18 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %19, i32 66, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%24 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%25 = call i32 @parse_path(i8* %23, i8** %24, i32 16, i32* %1)
%26 = load i32, i32* %1
%27 = call i32 @__assert_int_equal(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.10, i64 0, i64 0), i32 3, i32 %26, i32 70, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %29, i32 71, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%34 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%35 = call i32 @parse_path(i8* %33, i8** %34, i32 16, i32* %1)
%36 = load i32, i32* %1
%37 = call i32 @__assert_int_equal(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.13, i64 0, i64 0), i32 1, i32 %36, i32 75, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %39, i32 76, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%45 = call i32 @path_resolve(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%47 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0), i8* %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i32 79, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%49 = call i32 @strcpy(i8* %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%52 = call i32 @path_resolve(i8* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* %51)
%53 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%54 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.20, i64 0, i64 0), i8* %53, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i32 82, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%55 = call i32 (...) @test_case_end()
%56 = call i32 (...) @test_case_summary()
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Path parser test case\00"
@__const.testPathParser.path = [128 x i8] c"/home/dir/abc.txt\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [46 x i8] c"/home/dir/abc.txt should be parsed to 3 parts\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/morningsend/zkernel/refs/heads/master/fs/test/testfs.c\00"
@.str.3 = [22 x i8] c"part 1 should be home\00"
@.str.4 = [5 x i8] c"home\00"
@.str.5 = [21 x i8] c"part 2 should be dir\00"
@.str.6 = [4 x i8] c"dir\00"
@.str.7 = [25 x i8] c"part 3 should be abc.txt\00"
@.str.8 = [8 x i8] c"abc.txt\00"
@.str.9 = [15 x i8] c"/home/dir/ccc/\00"
@.str.10 = [74 x i8] c"path with trailing slash is will be parsed as normal, e.g. /home/dir/ccc/\00"
@.str.11 = [61 x i8] c"dir with trailing slash will be parsed to name without slash\00"
@.str.12 = [4 x i8] c"ccc\00"
@.str.13 = [47 x i8] c"path with no slashes should parsed as one file\00"
@.str.14 = [37 x i8] c"parsing 'home' should produce 'home'\00"
@.str.15 = [7 x i8] c"/hello\00"
@.str.16 = [6 x i8] c"world\00"
@.str.17 = [33 x i8] c"path resolve joins path together\00"
@.str.18 = [13 x i8] c"/hello/world\00"
@.str.19 = [7 x i8] c"/world\00"
@.str.20 = [52 x i8] c"path starts with / will be resolve relative to root\00"
define void @testPathParser() {
%1 = alloca i32
%2 = alloca [16 x i8*]
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast [16 x i8*]* %2 to i8*
%7 = tail call i32 @test_case_begin(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 0
%11 = call i32 @parse_path(i8* %8, i8** %10, i32 16, i32* %1)
%12 = load i32, i32* %1
%13 = call i32 @__assert_int_equal(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %12, i32 63, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%14 = load i8*, i8** %10
%15 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32 64, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %17, i32 65, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [16 x i8*], [16 x i8*]* %2, i64 0, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %20, i32 66, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%23 = call i32 @parse_path(i8* %8, i8** %10, i32 16, i32* %1)
%24 = load i32, i32* %1
%25 = call i32 @__assert_int_equal(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.10, i64 0, i64 0), i32 3, i32 %24, i32 70, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%26 = load i8*, i8** %19
%27 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %26, i32 71, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @parse_path(i8* %8, i8** %10, i32 16, i32* %1)
%30 = load i32, i32* %1
%31 = call i32 @__assert_int_equal(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.13, i64 0, i64 0), i32 1, i32 %30, i32 75, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%32 = load i8*, i8** %10
%33 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %32, i32 76, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%35 = call i32 @path_resolve(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %9)
%36 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i32 79, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%38 = call i32 @path_resolve(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* %9)
%39 = call i32 @__assert_string_equal(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.20, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i32 82, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (...) @test_case_end()
%41 = call i32 (...) @test_case_summary()
ret void
}