#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*/ tidy_nop_ok(char *);
int /*<<< orphan*/ tidy_ok(char *, char *, char *);
void test_002(void) {
  tidy_nop_ok("nothing/to/see/here");
  tidy_nop_ok(".strange./.but./.true.");
  tidy_nop_ok("..stranger../..but../..still../..true../.../...");
  tidy_ok("//usr///local//bin/foo", "/usr/local/bin/foo", "extra slashes");
  tidy_ok("/", "/", "root");
  tidy_ok("/../", "/", "root");
  tidy_ok("./", "./", "canonical 'here'");
  tidy_ok("././", "./", "tidy 'here'");
  tidy_ok("/usr/./local/.//././bin/.", "/usr/local/bin", "lots of dots");
  tidy_ok("../../foo/bar", "../../foo/bar", "legitimate ups");
  tidy_ok("../foo/../bar", "../bar", "down, up");
  tidy_ok("../foo/baz/../../bar", "../bar", "multi down, up");
  tidy_ok("/tmp/../", "/", "root");
  tidy_ok("/.", "/.", "slashdot");
  tidy_ok("foo/.", "foo", "trailing");
  tidy_ok("/../tmp", "/tmp", "silly root up");
  tidy_ok("foo/..", ".", "degenerate special case");
  tidy_ok(".//../foo2/baz33/../bim444//../.././bar", "../bar", "pointless");
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <tidy_nop_ok@plt>
lea    0xedd(%rip),%rdi
call   1030 <tidy_nop_ok@plt>
lea    0xee8(%rip),%rdi
call   1030 <tidy_nop_ok@plt>
lea    0xf0c(%rip),%rdi
lea    0xf1c(%rip),%rsi
lea    0xf28(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xfdd(%rip),%rsi
lea    0xf23(%rip),%rdx
mov    %rsi,%rdi
call   1040 <tidy_ok@plt>
lea    0xfc4(%rip),%rdi
lea    0xfc0(%rip),%rsi
lea    0xf06(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xfac(%rip),%rsi
lea    0xef8(%rip),%rdx
mov    %rsi,%rdi
call   1040 <tidy_ok@plt>
lea    0xefa(%rip),%rdi
lea    0xf8f(%rip),%rsi
lea    0xef1(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xef1(%rip),%rdi
lea    0xf04(%rip),%rsi
lea    0xf0c(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xf0d(%rip),%rsi
lea    0xf14(%rip),%rdx
mov    %rsi,%rdi
call   1040 <tidy_ok@plt>
lea    0xf14(%rip),%rdi
lea    0xf29(%rip),%rsi
lea    0xf2f(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xf08(%rip),%rdi
lea    0xf0f(%rip),%rsi
lea    0xf0f(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xf12(%rip),%rdi
lea    0xf12(%rip),%rsi
lea    0xe58(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xe8a(%rip),%rsi
lea    0xefa(%rip),%rdx
mov    %rsi,%rdi
call   1040 <tidy_ok@plt>
lea    0xef4(%rip),%rdi
lea    0xe0a(%rip),%rsi
lea    0xeec(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xee9(%rip),%rdi
lea    0xee5(%rip),%rsi
lea    0xee3(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xee5(%rip),%rdi
lea    0xdc1(%rip),%rsi
lea    0xede(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xeea(%rip),%rdi
lea    0xe77(%rip),%rsi
lea    0xf04(%rip),%rdx
call   1040 <tidy_ok@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
call   1030 <tidy_nop_ok@plt>
lea    0xed9(%rip),%rdi
call   1030 <tidy_nop_ok@plt>
lea    0xee4(%rip),%rdi
call   1030 <tidy_nop_ok@plt>
lea    0xf08(%rip),%rdi
lea    0xf18(%rip),%rsi
lea    0xf24(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xfd9(%rip),%r12
lea    0xf1f(%rip),%r14
mov    %r12,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <tidy_ok@plt>
lea    0xfba(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <tidy_ok@plt>
lea    0xfaa(%rip),%rbx
lea    0xef6(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <tidy_ok@plt>
lea    0xef5(%rip),%rdi
lea    0xef3(%rip),%rdx
mov    %rbx,%rsi
call   1040 <tidy_ok@plt>
lea    0xef0(%rip),%rdi
lea    0xf03(%rip),%rsi
lea    0xf0b(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xf0c(%rip),%rdi
lea    0xf13(%rip),%rdx
mov    %rdi,%rsi
call   1040 <tidy_ok@plt>
lea    0xf13(%rip),%rdi
lea    0xf28(%rip),%r15
lea    0xf2e(%rip),%rdx
mov    %r15,%rsi
call   1040 <tidy_ok@plt>
lea    0xf04(%rip),%rdi
lea    0xf12(%rip),%rdx
mov    %r15,%rsi
call   1040 <tidy_ok@plt>
lea    0xf12(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <tidy_ok@plt>
lea    0xe92(%rip),%rdi
lea    0xf02(%rip),%rdx
mov    %rdi,%rsi
call   1040 <tidy_ok@plt>
lea    0xefc(%rip),%rdi
lea    0xe12(%rip),%rsi
lea    0xef4(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xef1(%rip),%rdi
lea    0xeed(%rip),%rsi
lea    0xeeb(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xeed(%rip),%rdi
lea    0xdc9(%rip),%rsi
lea    0xee6(%rip),%rdx
call   1040 <tidy_ok@plt>
lea    0xef2(%rip),%rdi
lea    0xf13(%rip),%rdx
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <tidy_ok@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"nothing/to/see/here\00"
@.str.1 = [23 x i8] c".strange./.but./.true.\00"
@.str.2 = [48 x i8] c"..stranger../..but../..still../..true../.../...\00"
@.str.3 = [23 x i8] c"//usr///local//bin/foo\00"
@.str.4 = [19 x i8] c"/usr/local/bin/foo\00"
@.str.5 = [14 x i8] c"extra slashes\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [5 x i8] c"root\00"
@.str.8 = [5 x i8] c"/../\00"
@.str.9 = [3 x i8] c"./\00"
@.str.10 = [17 x i8] c"canonical 'here'\00"
@.str.11 = [5 x i8] c"././\00"
@.str.12 = [12 x i8] c"tidy 'here'\00"
@.str.13 = [26 x i8] c"/usr/./local/.//././bin/.\00"
@.str.14 = [15 x i8] c"/usr/local/bin\00"
@.str.15 = [13 x i8] c"lots of dots\00"
@.str.16 = [14 x i8] c"../../foo/bar\00"
@.str.17 = [15 x i8] c"legitimate ups\00"
@.str.18 = [14 x i8] c"../foo/../bar\00"
@.str.19 = [7 x i8] c"../bar\00"
@.str.20 = [9 x i8] c"down, up\00"
@.str.21 = [21 x i8] c"../foo/baz/../../bar\00"
@.str.22 = [15 x i8] c"multi down, up\00"
@.str.23 = [9 x i8] c"/tmp/../\00"
@.str.24 = [3 x i8] c"/.\00"
@.str.25 = [9 x i8] c"slashdot\00"
@.str.26 = [6 x i8] c"foo/.\00"
@.str.27 = [4 x i8] c"foo\00"
@.str.28 = [9 x i8] c"trailing\00"
@.str.29 = [8 x i8] c"/../tmp\00"
@.str.30 = [5 x i8] c"/tmp\00"
@.str.31 = [14 x i8] c"silly root up\00"
@.str.32 = [7 x i8] c"foo/..\00"
@.str.33 = [2 x i8] c".\00"
@.str.34 = [24 x i8] c"degenerate special case\00"
@.str.35 = [40 x i8] c".//../foo2/baz33/../bim444//../.././bar\00"
@.str.36 = [10 x i8] c"pointless\00"
define void @test_002() {
%1 = call i32 @tidy_nop_ok(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @tidy_nop_ok(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @tidy_nop_ok(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @tidy_ok(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%5 = call i32 @tidy_ok(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%6 = call i32 @tidy_ok(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%7 = call i32 @tidy_ok(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%8 = call i32 @tidy_ok(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%9 = call i32 @tidy_ok(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0))
%10 = call i32 @tidy_ok(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
%11 = call i32 @tidy_ok(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
%12 = call i32 @tidy_ok(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0))
%13 = call i32 @tidy_ok(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @tidy_ok(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.25, i64 0, i64 0))
%15 = call i32 @tidy_ok(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.26, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i64 0, i64 0))
%16 = call i32 @tidy_ok(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.31, i64 0, i64 0))
%17 = call i32 @tidy_ok(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.33, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.34, i64 0, i64 0))
%18 = call i32 @tidy_ok(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.35, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.36, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"nothing/to/see/here\00"
@.str.1 = [23 x i8] c".strange./.but./.true.\00"
@.str.2 = [48 x i8] c"..stranger../..but../..still../..true../.../...\00"
@.str.3 = [23 x i8] c"//usr///local//bin/foo\00"
@.str.4 = [19 x i8] c"/usr/local/bin/foo\00"
@.str.5 = [14 x i8] c"extra slashes\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [5 x i8] c"root\00"
@.str.8 = [5 x i8] c"/../\00"
@.str.9 = [3 x i8] c"./\00"
@.str.10 = [17 x i8] c"canonical 'here'\00"
@.str.11 = [5 x i8] c"././\00"
@.str.12 = [12 x i8] c"tidy 'here'\00"
@.str.13 = [26 x i8] c"/usr/./local/.//././bin/.\00"
@.str.14 = [15 x i8] c"/usr/local/bin\00"
@.str.15 = [13 x i8] c"lots of dots\00"
@.str.16 = [14 x i8] c"../../foo/bar\00"
@.str.17 = [15 x i8] c"legitimate ups\00"
@.str.18 = [14 x i8] c"../foo/../bar\00"
@.str.19 = [7 x i8] c"../bar\00"
@.str.20 = [9 x i8] c"down, up\00"
@.str.21 = [21 x i8] c"../foo/baz/../../bar\00"
@.str.22 = [15 x i8] c"multi down, up\00"
@.str.23 = [9 x i8] c"/tmp/../\00"
@.str.24 = [3 x i8] c"/.\00"
@.str.25 = [9 x i8] c"slashdot\00"
@.str.26 = [6 x i8] c"foo/.\00"
@.str.27 = [4 x i8] c"foo\00"
@.str.28 = [9 x i8] c"trailing\00"
@.str.29 = [8 x i8] c"/../tmp\00"
@.str.30 = [5 x i8] c"/tmp\00"
@.str.31 = [14 x i8] c"silly root up\00"
@.str.32 = [7 x i8] c"foo/..\00"
@.str.33 = [2 x i8] c".\00"
@.str.34 = [24 x i8] c"degenerate special case\00"
@.str.35 = [40 x i8] c".//../foo2/baz33/../bim444//../.././bar\00"
@.str.36 = [10 x i8] c"pointless\00"
define void @test_002() {
%1 = tail call i32 @tidy_nop_ok(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @tidy_nop_ok(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @tidy_nop_ok(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%5 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%6 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%7 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%8 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%9 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0))
%10 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
%11 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
%12 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0))
%13 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%14 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.25, i64 0, i64 0))
%15 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.26, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.28, i64 0, i64 0))
%16 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.31, i64 0, i64 0))
%17 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.33, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.34, i64 0, i64 0))
%18 = tail call i32 @tidy_ok(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.35, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.36, i64 0, i64 0))
ret void
}