#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__ memcmp(char *, char *, int);
size_t util_path_decode(char *s) {
  size_t i, j;
  for (i = 0, j = 0; s[i] != '\0'; j++) {
    if (memcmp(&s[i], "\\x2f", 4) == 0) {
      s[j] = '/';
      i += 4;
    } else if (memcmp(&s[i], "\\x5c", 4) == 0) {
      s[j] = '\\';
      i += 4;
    } else {
      s[j] = s[i];
      i++;
    }
  }
  s[j] = '\0';
  return j;
}


x86 assembly (clang, -O0):
<util_path_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11fe <util_path_decode+0xee>
mov    -0x8(%rbp),%rdi
add    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    1181 <util_path_decode+0x71>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    11e8 <util_path_decode+0xd8>
mov    -0x8(%rbp),%rdi
add    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11c1 <util_path_decode+0xb1>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x5c,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    11e3 <util_path_decode+0xd3>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11e8 <util_path_decode+0xd8>
jmp    11ed <util_path_decode+0xdd>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <util_path_decode+0x1c>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_path_decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x0,(%rdi)
je     11a4 <util_path_decode+0x94>
xor    %r13d,%r13d
lea    0xecf(%rip),%r15
mov    %r14,%rbx
xor    %ebp,%ebp
jmp    1158 <util_path_decode+0x48>
nopl   0x0(%rax,%rax,1)
mov    $0x2f,%al
mov    %al,(%r14,%r13,1)
add    %r12,%rbp
add    $0x1,%r13
lea    (%r14,%rbp,1),%rbx
cmpb   $0x0,(%r14,%rbp,1)
je     11a7 <util_path_decode+0x97>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
mov    $0x4,%r12d
test   %rax,%rax
je     1140 <util_path_decode+0x30>
mov    %rbx,%rdi
lea    0xe88(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     11a0 <util_path_decode+0x90>
movzbl (%rbx),%eax
mov    $0x1,%r12d
jmp    1142 <util_path_decode+0x32>
nopw   0x0(%rax,%rax,1)
mov    $0x5c,%al
jmp    1142 <util_path_decode+0x32>
xor    %r13d,%r13d
movb   $0x0,(%r14,%r13,1)
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"\\x2f\00"
@.str.1 = [5 x i8] c"\\x5c\00"
define i64 @util_path_decode(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %5
5: ; preds = %48, %1
%6 = load i8*, i8** %2
%7 = load i64, i64* %3
%8 = getelementptr inbounds i8, i8* %6, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %51
12: ; preds = %5
%13 = load i8*, i8** %2
%14 = load i64, i64* %3
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = call i64 @memcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i8*, i8** %2
%20 = load i64, i64* %4
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8 47, i8* %21
%22 = load i64, i64* %3
%23 = add i64 %22, 4
store i64 %23, i64* %3
br label %47
24: ; preds = %12
%25 = load i8*, i8** %2
%26 = load i64, i64* %3
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = call i64 @memcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i8*, i8** %2
%32 = load i64, i64* %4
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8 92, i8* %33
%34 = load i64, i64* %3
%35 = add i64 %34, 4
store i64 %35, i64* %3
br label %46
36: ; preds = %24
%37 = load i8*, i8** %2
%38 = load i64, i64* %3
%39 = getelementptr inbounds i8, i8* %37, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %2
%42 = load i64, i64* %4
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8 %40, i8* %43
%44 = load i64, i64* %3
%45 = add i64 %44, 1
store i64 %45, i64* %3
br label %46
46: ; preds = %36, %30
br label %47
47: ; preds = %46, %18
br label %48
48: ; preds = %47
%49 = load i64, i64* %4
%50 = add i64 %49, 1
store i64 %50, i64* %4
br label %5
51: ; preds = %5
%52 = load i8*, i8** %2
%53 = load i64, i64* %4
%54 = getelementptr inbounds i8, i8* %52, i64 %53
store i8 0, i8* %54
%55 = load i64, i64* %4
ret i64 %55
}

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