#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*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *unixify(char *name) {
  static char piece[512];
  char *s, *p;
  if (strchr(name, '/') != 0)
    return name;
  p = piece;
  *p = 0;
  s = strchr(name, ':');
  if (s != 0) {
    *s = 0;
    *p++ = '/';
    *p++ = '/';
    strcpy(p, name);
    p += strlen(p);
    *s = ':';
  }
  *p++ = '/';
  s = strchr(name, '[');
  if (s != 0) {
    s++;
    switch (*s) {
    case ']':
      strcat(p, "./");
      break;
    case '-':
      strcat(p, "../");
      break;
    case '.':
      strcat(p, "./");
      break;
    default:
      s--;
      break;
    }
    s++;
    while (*s) {
      if (*s == '.')
        *p++ = '/';
      else
        *p++ = *s;
      s++;
      if (*s == ']') {
        s++;
        break;
      }
    }
    if (*s != 0) {
      if (*(p - 1) != '/')
        *p++ = '/';
      strcpy(p, s);
    }
  } else {
    *p++ = 0;
  }
  if (*(p - 1) != '/')
    *p++ = '/';
  *p = 0;
  return piece;
}


x86 assembly (clang, -O0):
<unixify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1171 <unixify+0x31>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    13cd <unixify+0x28d>
lea    0x2ed8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11f8 <unixify+0xb8>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2f,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2f,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x3a,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2f,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x5b,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1386 <unixify+0x246>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2d,%eax
je     1282 <unixify+0x142>
jmp    124b <unixify+0x10b>
mov    -0x24(%rbp),%eax
sub    $0x2e,%eax
je     1297 <unixify+0x157>
jmp    125c <unixify+0x11c>
mov    -0x24(%rbp),%eax
sub    $0x5d,%eax
jne    12ac <unixify+0x16c>
jmp    126d <unixify+0x12d>
mov    -0x20(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   1060 <strcat@plt>
jmp    12b8 <unixify+0x178>
mov    -0x20(%rbp),%rdi
lea    0xd73(%rip),%rsi
call   1060 <strcat@plt>
jmp    12b8 <unixify+0x178>
mov    -0x20(%rbp),%rdi
lea    0xd5f(%rip),%rsi
call   1060 <strcat@plt>
jmp    12b8 <unixify+0x178>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1341 <unixify+0x201>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    12f8 <unixify+0x1b8>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2f,(%rax)
jmp    130f <unixify+0x1cf>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
jne    133c <unixify+0x1fc>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1341 <unixify+0x201>
jmp    12c4 <unixify+0x184>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1381 <unixify+0x241>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
je     1374 <unixify+0x234>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2f,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1398 <unixify+0x258>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
je     13bb <unixify+0x27b>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2f,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2c87(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unixify>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1279 <unixify+0x139>
movb   $0x0,0x2eeb(%rip)
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11b7 <unixify+0x77>
mov    %rax,%r15
movb   $0x0,(%rax)
movw   $0x2f2f,0x2eca(%rip)
2f 2f
lea    0x2ec3(%rip),%r12
lea    0x2ebe(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rax,%r12,1),%r14
add    $0x2,%r14
movb   $0x3a,(%r15)
jmp    11be <unixify+0x7e>
lea    0x2e92(%rip),%r14
movb   $0x2f,(%r14)
mov    %rbx,%rdi
mov    $0x5b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1288 <unixify+0x148>
mov    %rax,%rbx
add    $0x1,%r14
movsbl 0x1(%rax),%eax
lea    0xe17(%rip),%rsi
cmp    $0x5d,%eax
je     1200 <unixify+0xc0>
cmp    $0x2e,%eax
je     1200 <unixify+0xc0>
cmp    $0x2d,%eax
jne    120c <unixify+0xcc>
lea    0xe00(%rip),%rsi
add    $0x1,%rbx
mov    %r14,%rdi
call   1060 <strcat@plt>
mov    0x1(%rbx),%al
add    $0x2,%rbx
jmp    1234 <unixify+0xf4>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ecx
mov    %cl,(%r14)
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x5d,%al
je     1240 <unixify+0x100>
mov    $0x2f,%cl
cmp    $0x2e,%al
je     1222 <unixify+0xe2>
test   %al,%al
jne    1220 <unixify+0xe0>
jmp    125f <unixify+0x11f>
cmpb   $0x0,(%rbx)
je     125f <unixify+0x11f>
cmpb   $0x2f,-0x1(%r14)
je     1254 <unixify+0x114>
movb   $0x2f,(%r14)
add    $0x1,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
cmpb   $0x2f,-0x1(%r14)
je     126e <unixify+0x12e>
movb   $0x2f,(%r14)
add    $0x1,%r14
movb   $0x0,(%r14)
lea    0x2dd7(%rip),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
movb   $0x0,0x1(%r14)
add    $0x2,%r14
cmpb   $0x2f,-0x1(%r14)
jne    1266 <unixify+0x126>
jmp    126e <unixify+0x12e>

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

LLVM IR (-O2):
@unixify.piece = internal global [512 x i8] zeroinitializer
@.str = [3 x i8] c"./\00"
@.str.1 = [4 x i8] c"../\00"
define i8* @unixify(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %63
4: ; preds = %1
store i8 0, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 0)
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
store i8 0, i8* %5
store i8 47, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 0)
store i8 47, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 1)
%8 = tail call i32 @strcpy(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 2), i8* %0)
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 2))
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 2), i64 %10
store i8 58, i8* %5
br label %12
12: ; preds = %7, %4
%13 = phi i8* [ %11, %7 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 0), %4 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8 47, i8* %13
%15 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 91)
%16 = icmp eq i8* %15, null
br i1 %16, label %52, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %15, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %25 [
i32 93, label %22
i32 45, label %21
i32 46, label %22
]
21: ; preds = %17
br label %22
22: ; preds = %17, %17, %21
%23 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %21 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %17 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %17 ]
%24 = tail call i32 @strcat(i8* %14, i8* %23)
br label %25
25: ; preds = %22, %17
%26 = phi i8* [ %15, %17 ], [ %18, %22 ]
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
br label %29
29: ; preds = %34, %25
%30 = phi i8 [ %38, %34 ], [ %28, %25 ]
%31 = phi i8* [ %37, %34 ], [ %27, %25 ]
%32 = phi i8* [ %36, %34 ], [ %14, %25 ]
switch i8 %30, label %33 [
i8 0, label %54
i8 46, label %34
]
33: ; preds = %29
br label %34
34: ; preds = %29, %33
%35 = phi i8 [ %30, %33 ], [ 47, %29 ]
%36 = getelementptr inbounds i8, i8* %32, i64 1
store i8 %35, i8* %32
%37 = getelementptr inbounds i8, i8* %31, i64 1
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 93
br i1 %39, label %40, label %29
40: ; preds = %34
%41 = getelementptr inbounds i8, i8* %31, i64 2
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %54, label %44
44: ; preds = %40
%45 = load i8, i8* %32
%46 = icmp eq i8 %45, 47
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = getelementptr inbounds i8, i8* %32, i64 2
store i8 47, i8* %36
br label %49
49: ; preds = %47, %44
%50 = phi i8* [ %48, %47 ], [ %36, %44 ]
%51 = tail call i32 @strcpy(i8* %50, i8* %41)
br label %54
52: ; preds = %12
%53 = getelementptr inbounds i8, i8* %13, i64 2
store i8 0, i8* %14
br label %54
54: ; preds = %29, %40, %49, %52
%55 = phi i8* [ %50, %49 ], [ %36, %40 ], [ %53, %52 ], [ %32, %29 ]
%56 = getelementptr inbounds i8, i8* %55, i64 -1
%57 = load i8, i8* %56
%58 = icmp eq i8 %57, 47
br i1 %58, label %61, label %59
59: ; preds = %54
%60 = getelementptr inbounds i8, i8* %55, i64 1
store i8 47, i8* %55
br label %61
61: ; preds = %59, %54
%62 = phi i8* [ %60, %59 ], [ %55, %54 ]
store i8 0, i8* %62
br label %63
63: ; preds = %1, %61
%64 = phi i8* [ getelementptr inbounds ([512 x i8], [512 x i8]* @unixify.piece, i64 0, i64 0), %61 ], [ %0, %1 ]
ret i8* %64
}