#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 */
scalar_t__ strncmp(char *, char *, int);
void fixpath(char *path) {
  char *dst = path;
  char *src = path;
  for (; *src;) {
    if (0 == strncmp(src, "//", 2)) {
      src++;
      continue;
    }
    if (0 == strncmp(src, "/./", 3)) {
      src += 2;
      continue;
    }
    *(dst++) = *(src++);
  }
  *dst = 0;
}


x86 assembly (clang, -O0):
<fixpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c8 <fixpath+0xb8>
mov    -0x18(%rbp),%rdi
lea    0xebc(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    116d <fixpath+0x5d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <fixpath+0x1c>
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11a1 <fixpath+0x91>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <fixpath+0x1c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    112c <fixpath+0x1c>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixpath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1195 <fixpath+0x85>
lea    0xed9(%rip),%r14
lea    0xed5(%rip),%r15
mov    %rbx,%r12
jmp    114f <fixpath+0x3f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%ecx
cmpb   $0x0,(%rbx,%rcx,1)
lea    (%rbx,%rcx,1),%rbx
je     1198 <fixpath+0x88>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1140 <fixpath+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    $0x2,%ecx
test   %rax,%rax
je     1145 <fixpath+0x35>
movzbl (%rbx),%eax
mov    %al,(%r12)
add    $0x1,%r12
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    114f <fixpath+0x3f>
jmp    1198 <fixpath+0x88>
mov    %rbx,%r12
movb   $0x0,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"//\00"
@.str.1 = [4 x i8] c"/./\00"
define void @fixpath(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %25, %22, %15, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = icmp eq i64 0, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
br label %7
18: ; preds = %11
%19 = load i8*, i8** %4
%20 = call i64 @strncmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%21 = icmp eq i64 0, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 2
store i8* %24, i8** %4
br label %7
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
%28 = load i8, i8* %26
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
store i8 %28, i8* %29
br label %7
31: ; preds = %7
%32 = load i8*, i8** %3
store i8 0, i8* %32
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"//\00"
@.str.1 = [4 x i8] c"/./\00"
define void @fixpath(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %25, label %4
4: ; preds = %1, %19
%5 = phi i8* [ %20, %19 ], [ %0, %1 ]
%6 = phi i8* [ %22, %19 ], [ %0, %1 ]
br label %7
7: ; preds = %4, %11
%8 = phi i8* [ %5, %4 ], [ %13, %11 ]
%9 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7, %16
%12 = phi i64 [ 2, %16 ], [ 1, %7 ]
%13 = getelementptr inbounds i8, i8* %8, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %25, label %7
16: ; preds = %7
%17 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %11, label %19
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %8, i64 1
%21 = load i8, i8* %8
%22 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %21, i8* %6
%23 = load i8, i8* %20
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %4
25: ; preds = %19, %11, %1
%26 = phi i8* [ %0, %1 ], [ %6, %11 ], [ %22, %19 ]
store i8 0, i8* %26
ret void
}