#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*/ test_path_resolve_int(char *, char *);
void test_path_resolve(void) {
  test_path_resolve_int("c:\\test\\.", "c:\\test\\");
  test_path_resolve_int("c:\\test\\.\\", "c:\\test\\");
  test_path_resolve_int("c:\\test\\..", "c:\\");
  test_path_resolve_int("c:\\test\\..\\", "c:\\");
  test_path_resolve_int("c:\\test\\.\\..", "c:\\");
  test_path_resolve_int("c:\\test\\.\\\\..", "c:\\");
  test_path_resolve_int(".", ".");
  test_path_resolve_int(".\\", "");
  test_path_resolve_int("..", "");
  test_path_resolve_int("..\\", "");
  test_path_resolve_int("c:\\test\\123\\.\\abc.txt", "c:\\test\\123\\abc.txt");
  test_path_resolve_int("c:\\test\\123\\..\\abc.txt", "c:\\test\\abc.txt");
  test_path_resolve_int("c:\\test\\123\\..\\..\\abc.txt", "c:\\abc.txt");
  test_path_resolve_int("c:\\test\\123\\..\\..\\..\\abc.txt", "abc.txt");
}


x86 assembly (clang, -O0):
<test_path_resolve>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee8(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xee5(%rip),%rdi
lea    0xed5(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xedd(%rip),%rdi
lea    0xee1(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xed9(%rip),%rdi
lea    0xece(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xed2(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xecc(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xeb7(%rip),%rsi
mov    %rsi,%rdi
call   1030 <test_path_resolve_int@plt>
lea    0xe9a(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe94(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe73(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe7f(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe96(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xeaa(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xebc(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_path_resolve>:
push   %rbx
lea    0xee8(%rip),%rdi
lea    0xeeb(%rip),%rbx
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xee1(%rip),%rdi
lea    0xee5(%rip),%rbx
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xeda(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xed7(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xed5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xec4(%rip),%rdi
mov    %rdi,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xea7(%rip),%rdi
lea    0xeaf(%rip),%rbx
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe9e(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xe91(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xea8(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xebc(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1030 <test_path_resolve_int@plt>
lea    0xece(%rip),%rdi
lea    0xedc(%rip),%rsi
pop    %rbx
jmp    1030 <test_path_resolve_int@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"c:\\test\\.\00"
@.str.1 = [9 x i8] c"c:\\test\\\00"
@.str.2 = [11 x i8] c"c:\\test\\.\\\00"
@.str.3 = [11 x i8] c"c:\\test\\..\00"
@.str.4 = [4 x i8] c"c:\\\00"
@.str.5 = [12 x i8] c"c:\\test\\..\\\00"
@.str.6 = [13 x i8] c"c:\\test\\.\\..\00"
@.str.7 = [14 x i8] c"c:\\test\\.\\\\..\00"
@.str.8 = [2 x i8] c".\00"
@.str.9 = [3 x i8] c".\\\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [3 x i8] c"..\00"
@.str.12 = [4 x i8] c"..\\\00"
@.str.13 = [22 x i8] c"c:\\test\\123\\.\\abc.txt\00"
@.str.14 = [20 x i8] c"c:\\test\\123\\abc.txt\00"
@.str.15 = [23 x i8] c"c:\\test\\123\\..\\abc.txt\00"
@.str.16 = [16 x i8] c"c:\\test\\abc.txt\00"
@.str.17 = [26 x i8] c"c:\\test\\123\\..\\..\\abc.txt\00"
@.str.18 = [11 x i8] c"c:\\abc.txt\00"
@.str.19 = [29 x i8] c"c:\\test\\123\\..\\..\\..\\abc.txt\00"
@.str.20 = [8 x i8] c"abc.txt\00"
define void @test_path_resolve() {
%1 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%4 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%5 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%8 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%9 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%10 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%11 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%12 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
%13 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
%14 = call i32 @test_path_resolve_int(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"c:\\test\\.\00"
@.str.1 = [9 x i8] c"c:\\test\\\00"
@.str.2 = [11 x i8] c"c:\\test\\.\\\00"
@.str.3 = [11 x i8] c"c:\\test\\..\00"
@.str.4 = [4 x i8] c"c:\\\00"
@.str.5 = [12 x i8] c"c:\\test\\..\\\00"
@.str.6 = [13 x i8] c"c:\\test\\.\\..\00"
@.str.7 = [14 x i8] c"c:\\test\\.\\\\..\00"
@.str.8 = [2 x i8] c".\00"
@.str.9 = [3 x i8] c".\\\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [3 x i8] c"..\00"
@.str.12 = [4 x i8] c"..\\\00"
@.str.13 = [22 x i8] c"c:\\test\\123\\.\\abc.txt\00"
@.str.14 = [20 x i8] c"c:\\test\\123\\abc.txt\00"
@.str.15 = [23 x i8] c"c:\\test\\123\\..\\abc.txt\00"
@.str.16 = [16 x i8] c"c:\\test\\abc.txt\00"
@.str.17 = [26 x i8] c"c:\\test\\123\\..\\..\\abc.txt\00"
@.str.18 = [11 x i8] c"c:\\abc.txt\00"
@.str.19 = [29 x i8] c"c:\\test\\123\\..\\..\\..\\abc.txt\00"
@.str.20 = [8 x i8] c"abc.txt\00"
define void @test_path_resolve() {
%1 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%4 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%5 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%8 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%9 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%10 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%11 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%12 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
%13 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
%14 = tail call i32 @test_path_resolve_int(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
ret void
}