#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*/ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char *strstr(char *, char *);
char *CanonicaliseName(char *name) {
  char *match, *name2;
  match = name;
  while ((match = strstr(match, "/./")) || !strncmp(match = name, "./", 2)) {
    char *prev = match, *next = match + 2;
    while ((*prev++ = *next++))
      ;
  }
  match = name;
  while ((match = strstr(match, "//"))) {
    char *prev = match, *next = match + 1;
    while ((*prev++ = *next++))
      ;
  }
  match = name2 = name;
  while ((match = strstr(match, "/../"))) {
    char *prev = match, *next = match + 4;
    if ((prev - name2) == 2 && !strncmp(name2, "../", 3)) {
      name2 += 3;
      match++;
      continue;
    }
    while (prev > name2 && *--prev != '/')
      ;
    match = prev;
    if (*prev == '/')
      prev++;
    while ((*prev++ = *next++))
      ;
  }
  match = &name[strlen(name) - 2];
  if (match >= name && !strcmp(match, "/."))
    *match = 0;
  match = &name[strlen(name) - 3];
  if (match >= name && !strcmp(match, "/..")) {
    if (match == name)
      *++match = 0;
    else
      while (match > name && *--match != '/')
        *match = 0;
  }
  match = &name[strlen(name) - 1];
  if (match > name && !strcmp(match, "/"))
    *match = 0;
  if (!*name)
    *name = '.', *(name + 1) = 0;
  return (name);
}


x86 assembly (clang, -O0):
<CanonicaliseName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x49(%rbp)
jne    119e <CanonicaliseName+0x5e>
mov    -0x8(%rbp),%rdi
mov    %rdi,-0x10(%rbp)
lea    0xe80(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11ae <CanonicaliseName+0x6e>
jmp    11f6 <CanonicaliseName+0xb6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%al
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     11f1 <CanonicaliseName+0xb1>
jmp    11c2 <CanonicaliseName+0x82>
jmp    1154 <CanonicaliseName+0x14>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1264 <CanonicaliseName+0x124>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
mov    (%rax),%al
mov    -0x30(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     125f <CanonicaliseName+0x11f>
jmp    1230 <CanonicaliseName+0xf0>
jmp    11fe <CanonicaliseName+0xbe>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1398 <CanonicaliseName+0x258>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x2,%rax
jne    12f2 <CanonicaliseName+0x1b2>
mov    -0x18(%rbp),%rdi
lea    0xd46(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12f2 <CanonicaliseName+0x1b2>
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1270 <CanonicaliseName+0x130>
jmp    12f7 <CanonicaliseName+0x1b7>
mov    -0x40(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x4a(%rbp)
jbe    1326 <CanonicaliseName+0x1e6>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x40(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x4a(%rbp)
mov    -0x4a(%rbp),%al
test   $0x1,%al
jne    1336 <CanonicaliseName+0x1f6>
jmp    133b <CanonicaliseName+0x1fb>
jmp    12f7 <CanonicaliseName+0x1b7>
mov    -0x40(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    135f <CanonicaliseName+0x21f>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1364 <CanonicaliseName+0x224>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
mov    (%rax),%al
mov    -0x40(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     1393 <CanonicaliseName+0x253>
jmp    1364 <CanonicaliseName+0x224>
jmp    1270 <CanonicaliseName+0x130>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     13ea <CanonicaliseName+0x2aa>
mov    -0x10(%rbp),%rdi
lea    0xc37(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    13ea <CanonicaliseName+0x2aa>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x3,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     14b5 <CanonicaliseName+0x375>
mov    -0x10(%rbp),%rdi
lea    0xbe8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    14b5 <CanonicaliseName+0x375>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    145b <CanonicaliseName+0x31b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,0x1(%rax)
jmp    14b0 <CanonicaliseName+0x370>
jmp    1460 <CanonicaliseName+0x320>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x61(%rbp)
jbe    148f <CanonicaliseName+0x34f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    149f <CanonicaliseName+0x35f>
jmp    14ab <CanonicaliseName+0x36b>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    1460 <CanonicaliseName+0x320>
jmp    14b0 <CanonicaliseName+0x370>
jmp    14b5 <CanonicaliseName+0x375>
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1507 <CanonicaliseName+0x3c7>
mov    -0x10(%rbp),%rdi
lea    0xb18(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1507 <CanonicaliseName+0x3c7>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1523 <CanonicaliseName+0x3e3>
mov    -0x8(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CanonicaliseName>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xeab(%rip),%rbx
lea    0xead(%rip),%r14
mov    %rdi,%rax
nop
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    1189 <CanonicaliseName+0x49>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
mov    %r12,%rax
test   %ecx,%ecx
jne    11a0 <CanonicaliseName+0x60>
lea    0x2(%rax),%rcx
nopl   (%rax)
movzbl (%rcx),%edx
mov    %dl,-0x2(%rcx)
add    $0x1,%rcx
test   %dl,%dl
jne    1190 <CanonicaliseName+0x50>
jmp    1160 <CanonicaliseName+0x20>
lea    0xe5d(%rip),%rsi
mov    %r12,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11ee <CanonicaliseName+0xae>
lea    0xe49(%rip),%rbx
nopl   0x0(%rax,%rax,1)
lea    0x1(%rax),%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rcx),%edx
mov    %dl,-0x1(%rcx)
add    $0x1,%rcx
test   %dl,%dl
jne    11d0 <CanonicaliseName+0x90>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11c0 <CanonicaliseName+0x80>
lea    0xe12(%rip),%rsi
mov    %r12,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     12b5 <CanonicaliseName+0x175>
mov    %rax,%rbx
lea    0xdf8(%rip),%r14
lea    0xdf0(%rip),%r15
mov    %r12,%r13
jmp    1240 <CanonicaliseName+0x100>
add    $0x3,%r13
add    $0x1,%rbx
mov    %rbx,%rdi
nopw   0x0(%rax,%rax,1)
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12b5 <CanonicaliseName+0x175>
mov    %rbx,%rax
sub    %r13,%rax
mov    %rbx,%rdi
cmp    $0x2,%rax
jne    1270 <CanonicaliseName+0x130>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rbx,%rdi
test   %eax,%eax
je     121c <CanonicaliseName+0xdc>
cs nopw 0x0(%rax,%rax,1)
cmp    %r13,%rdi
jbe    1290 <CanonicaliseName+0x150>
lea    -0x1(%rdi),%rax
cmpb   $0x2f,-0x1(%rdi)
mov    %rax,%rdi
jne    1270 <CanonicaliseName+0x130>
mov    $0x2f,%cl
mov    %rax,%rdi
jmp    1292 <CanonicaliseName+0x152>
nopl   0x0(%rax)
mov    (%rdi),%cl
xor    %eax,%eax
cmp    $0x2f,%cl
sete   %al
add    %rdi,%rax
xor    %ecx,%ecx
nop
movzbl 0x4(%rbx,%rcx,1),%edx
mov    %dl,(%rax,%rcx,1)
add    $0x1,%rcx
test   %dl,%dl
jne    12a0 <CanonicaliseName+0x160>
jmp    1230 <CanonicaliseName+0xf0>
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     12e2 <CanonicaliseName+0x1a2>
cltq
lea    (%rax,%r12,1),%rbx
add    $0xfffffffffffffffe,%rbx
lea    0xd39(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    12e2 <CanonicaliseName+0x1a2>
movb   $0x0,(%rbx)
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     130e <CanonicaliseName+0x1ce>
mov    %eax,%ebp
cltq
lea    (%rax,%r12,1),%rbx
add    $0xfffffffffffffffd,%rbx
lea    0xd0d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1358 <CanonicaliseName+0x218>
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1338 <CanonicaliseName+0x1f8>
cltq
lea    (%rax,%r12,1),%rbx
add    $0xffffffffffffffff,%rbx
lea    0xcde(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1375 <CanonicaliseName+0x235>
cmpb   $0x0,(%r12)
jne    1346 <CanonicaliseName+0x206>
movw   $0x2e,(%r12)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xfffffffd,%ebp
je     1381 <CanonicaliseName+0x241>
nopl   (%rax)
cmpb   $0x2f,-0x1(%rbx)
je     130e <CanonicaliseName+0x1ce>
movb   $0x0,-0x1(%rbx)
add    $0xffffffffffffffff,%rbx
cmp    %r12,%rbx
ja     1360 <CanonicaliseName+0x220>
jmp    130e <CanonicaliseName+0x1ce>
movb   $0x0,(%rbx)
cmpb   $0x0,(%r12)
jne    1346 <CanonicaliseName+0x206>
jmp    133f <CanonicaliseName+0x1ff>
movb   $0x0,0x1(%rbx)
jmp    130e <CanonicaliseName+0x1ce>

LLVM IR (-O0):
@.str = [4 x i8] c"/./\00"
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [3 x i8] c"//\00"
@.str.3 = [5 x i8] c"/../\00"
@.str.4 = [4 x i8] c"../\00"
@.str.5 = [3 x i8] c"/.\00"
@.str.6 = [4 x i8] c"/..\00"
@.str.7 = [2 x i8] c"/\00"
define i8* @CanonicaliseName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %2
%11 = load i8*, i8** %2
store i8* %11, i8** %3
br label %12
12: ; preds = %35, %1
%13 = load i8*, i8** %3
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = load i8*, i8** %2
store i8* %17, i8** %3
%18 = call i32 @strncmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br label %21
21: ; preds = %16, %12
%22 = phi i1 [ true, %12 ], [ %20, %16 ]
br i1 %22, label %23, label %36
23: ; preds = %21
%24 = load i8*, i8** %3
store i8* %24, i8** %5
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 2
store i8* %26, i8** %6
br label %27
27: ; preds = %34, %23
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
%30 = load i8, i8* %28
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %5
store i8 %30, i8* %31
%33 = icmp ne i8 %30, 0
br i1 %33, label %34, label %35
34: ; preds = %27
br label %27
35: ; preds = %27
br label %12
36: ; preds = %21
%37 = load i8*, i8** %2
store i8* %37, i8** %3
br label %38
38: ; preds = %54, %36
%39 = load i8*, i8** %3
%40 = call i8* @strstr(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %40, i8** %3
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %55
42: ; preds = %38
%43 = load i8*, i8** %3
store i8* %43, i8** %7
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8* %45, i8** %8
br label %46
46: ; preds = %53, %42
%47 = load i8*, i8** %8
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %8
%49 = load i8, i8* %47
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
store i8 %49, i8* %50
%52 = icmp ne i8 %49, 0
br i1 %52, label %53, label %54
53: ; preds = %46
br label %46
54: ; preds = %46
br label %38
55: ; preds = %38
%56 = load i8*, i8** %2
store i8* %56, i8** %4
store i8* %56, i8** %3
br label %57
57: ; preds = %112, %75, %55
%58 = load i8*, i8** %3
%59 = call i8* @strstr(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %59, i8** %3
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %113
61: ; preds = %57
%62 = load i8*, i8** %3
store i8* %62, i8** %9
%63 = load i8*, i8** %3
%64 = getelementptr inbounds i8, i8* %63, i64 4
store i8* %64, i8** %10
%65 = load i8*, i8** %9
%66 = load i8*, i8** %4
%67 = ptrtoint i8* %65 to i64
%68 = ptrtoint i8* %66 to i64
%69 = sub i64 %67, %68
%70 = icmp eq i64 %69, 2
br i1 %70, label %71, label %80
71: ; preds = %61
%72 = load i8*, i8** %4
%73 = call i32 @strncmp(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%74 = icmp ne i32 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %71
%76 = load i8*, i8** %4
%77 = getelementptr inbounds i8, i8* %76, i64 3
store i8* %77, i8** %4
%78 = load i8*, i8** %3
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %3
br label %57
80: ; preds = %71, %61
br label %81
81: ; preds = %93, %80
%82 = load i8*, i8** %9
%83 = load i8*, i8** %4
%84 = icmp ugt i8* %82, %83
br i1 %84, label %85, label %91
85: ; preds = %81
%86 = load i8*, i8** %9
%87 = getelementptr inbounds i8, i8* %86, i32 -1
store i8* %87, i8** %9
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 47
br label %91
91: ; preds = %85, %81
%92 = phi i1 [ false, %81 ], [ %90, %85 ]
br i1 %92, label %93, label %94
93: ; preds = %91
br label %81
94: ; preds = %91
%95 = load i8*, i8** %9
store i8* %95, i8** %3
%96 = load i8*, i8** %9
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 47
br i1 %99, label %100, label %103
100: ; preds = %94
%101 = load i8*, i8** %9
%102 = getelementptr inbounds i8, i8* %101, i32 1
store i8* %102, i8** %9
br label %103
103: ; preds = %100, %94
br label %104
104: ; preds = %111, %103
%105 = load i8*, i8** %10
%106 = getelementptr inbounds i8, i8* %105, i32 1
store i8* %106, i8** %10
%107 = load i8, i8* %105
%108 = load i8*, i8** %9
%109 = getelementptr inbounds i8, i8* %108, i32 1
store i8* %109, i8** %9
store i8 %107, i8* %108
%110 = icmp ne i8 %107, 0
br i1 %110, label %111, label %112
111: ; preds = %104
br label %104
112: ; preds = %104
br label %57
113: ; preds = %57
%114 = load i8*, i8** %2
%115 = load i8*, i8** %2
%116 = call i32 @strlen(i8* %115)
%117 = sub nsw i32 %116, 2
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %114, i64 %118
store i8* %119, i8** %3
%120 = load i8*, i8** %3
%121 = load i8*, i8** %2
%122 = icmp uge i8* %120, %121
br i1 %122, label %123, label %129
123: ; preds = %113
%124 = load i8*, i8** %3
%125 = call i32 @strcmp(i8* %124, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%126 = icmp ne i32 %125, 0
br i1 %126, label %129, label %127
127: ; preds = %123
%128 = load i8*, i8** %3
store i8 0, i8* %128
br label %129
129: ; preds = %127, %123, %113
%130 = load i8*, i8** %2
%131 = load i8*, i8** %2
%132 = call i32 @strlen(i8* %131)
%133 = sub nsw i32 %132, 3
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %130, i64 %134
store i8* %135, i8** %3
%136 = load i8*, i8** %3
%137 = load i8*, i8** %2
%138 = icmp uge i8* %136, %137
br i1 %138, label %139, label %167
139: ; preds = %129
%140 = load i8*, i8** %3
%141 = call i32 @strcmp(i8* %140, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%142 = icmp ne i32 %141, 0
br i1 %142, label %167, label %143
143: ; preds = %139
%144 = load i8*, i8** %3
%145 = load i8*, i8** %2
%146 = icmp eq i8* %144, %145
br i1 %146, label %147, label %150
147: ; preds = %143
%148 = load i8*, i8** %3
%149 = getelementptr inbounds i8, i8* %148, i32 1
store i8* %149, i8** %3
store i8 0, i8* %149
br label %166
150: ; preds = %143
br label %151
151: ; preds = %163, %150
%152 = load i8*, i8** %3
%153 = load i8*, i8** %2
%154 = icmp ugt i8* %152, %153
br i1 %154, label %155, label %161
155: ; preds = %151
%156 = load i8*, i8** %3
%157 = getelementptr inbounds i8, i8* %156, i32 -1
store i8* %157, i8** %3
%158 = load i8, i8* %157
%159 = sext i8 %158 to i32
%160 = icmp ne i32 %159, 47
br label %161
161: ; preds = %155, %151
%162 = phi i1 [ false, %151 ], [ %160, %155 ]
br i1 %162, label %163, label %165
163: ; preds = %161
%164 = load i8*, i8** %3
store i8 0, i8* %164
br label %151
165: ; preds = %161
br label %166
166: ; preds = %165, %147
br label %167
167: ; preds = %166, %139, %129
%168 = load i8*, i8** %2
%169 = load i8*, i8** %2
%170 = call i32 @strlen(i8* %169)
%171 = sub nsw i32 %170, 1
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %168, i64 %172
store i8* %173, i8** %3
%174 = load i8*, i8** %3
%175 = load i8*, i8** %2
%176 = icmp ugt i8* %174, %175
br i1 %176, label %177, label %183
177: ; preds = %167
%178 = load i8*, i8** %3
%179 = call i32 @strcmp(i8* %178, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%180 = icmp ne i32 %179, 0
br i1 %180, label %183, label %181
181: ; preds = %177
%182 = load i8*, i8** %3
store i8 0, i8* %182
br label %183
183: ; preds = %181, %177, %167
%184 = load i8*, i8** %2
%185 = load i8, i8* %184
%186 = icmp ne i8 %185, 0
br i1 %186, label %191, label %187
187: ; preds = %183
%188 = load i8*, i8** %2
store i8 46, i8* %188
%189 = load i8*, i8** %2
%190 = getelementptr inbounds i8, i8* %189, i64 1
store i8 0, i8* %190
br label %191
191: ; preds = %187, %183
%192 = load i8*, i8** %2
ret i8* %192
}

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