#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 */
char read_oct(char *);
char *strchr(char *, char);
void unmangle_path(char *path) {
  char *p = strchr(path, '\\');
  if (p) {
    if (read_oct(p) == ' ') {
      *p = ' ';
      int i = 3;
      do {
        p++;
        if (*(p + i) == '\\' && read_oct(p + i) == ' ') {
          *p = ' ';
          i += 3;
        } else
          *p = *(p + i);
      } while (*p);
    }
  }
}


x86 assembly (clang, -O0):
<unmangle_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11eb <unmangle_path+0xcb>
mov    -0x10(%rbp),%rdi
call   1030 <read_oct@plt>
movsbl %al,%eax
cmp    $0x20,%eax
jne    11e6 <unmangle_path+0xc6>
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x3,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    11be <unmangle_path+0x9e>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
call   1030 <read_oct@plt>
movsbl %al,%eax
cmp    $0x20,%eax
jne    11be <unmangle_path+0x9e>
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    11cf <unmangle_path+0xaf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    11d4 <unmangle_path+0xb4>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116c <unmangle_path+0x4c>
jmp    11e6 <unmangle_path+0xc6>
jmp    11eb <unmangle_path+0xcb>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unmangle_path>:
push   %rbp
push   %r14
push   %rbx
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1183 <unmangle_path+0x63>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <read_oct@plt>
cmp    $0x20,%al
jne    1183 <unmangle_path+0x63>
movb   $0x20,(%rbx)
add    $0x1,%rbx
mov    $0x3,%ebp
jmp    115e <unmangle_path+0x3e>
movzbl (%r14),%eax
mov    %al,(%rbx)
add    $0x1,%rbx
test   %al,%al
je     1183 <unmangle_path+0x63>
movslq %ebp,%r14
movzbl (%rbx,%r14,1),%eax
cmp    $0x5c,%al
jne    1154 <unmangle_path+0x34>
add    %rbx,%r14
mov    %r14,%rdi
call   1030 <read_oct@plt>
cmp    $0x20,%al
jne    1150 <unmangle_path+0x30>
movb   $0x20,(%rbx)
add    $0x3,%ebp
mov    $0x20,%al
jmp    1156 <unmangle_path+0x36>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @unmangle_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strchr(i8* %5, i8 signext 92)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %52
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call signext i8 @read_oct(i8* %10)
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 32
br i1 %13, label %14, label %51
14: ; preds = %9
%15 = load i8*, i8** %3
store i8 32, i8* %15
store i32 3, i32* %4
br label %16
16: ; preds = %46, %14
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 92
br i1 %25, label %26, label %38
26: ; preds = %16
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = call signext i8 @read_oct(i8* %30)
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i8*, i8** %3
store i8 32, i8* %35
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 3
store i32 %37, i32* %4
br label %45
38: ; preds = %26, %16
%39 = load i8*, i8** %3
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = load i8*, i8** %3
store i8 %43, i8* %44
br label %45
45: ; preds = %38, %34
br label %46
46: ; preds = %45
%47 = load i8*, i8** %3
%48 = load i8, i8* %47
%49 = icmp ne i8 %48, 0
br i1 %49, label %16, label %50
50: ; preds = %46
br label %51
51: ; preds = %50, %9
br label %52
52: ; preds = %51, %1
ret void
}

LLVM IR (-O2):
define void @unmangle_path(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 92)
%3 = icmp eq i8* %2, null
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = tail call signext i8 @read_oct(i8* %2)
%6 = icmp eq i8 %5, 32
br i1 %6, label %7, label %29
7: ; preds = %4
store i8 32, i8* %2
br label %8
8: ; preds = %25, %7
%9 = phi i8* [ %2, %7 ], [ %11, %25 ]
%10 = phi i32 [ 3, %7 ], [ %27, %25 ]
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 92
br i1 %15, label %16, label %23
16: ; preds = %8
%17 = tail call signext i8 @read_oct(i8* %13)
%18 = icmp eq i8 %17, 32
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = load i8, i8* %13
br label %23
21: ; preds = %16
store i8 32, i8* %11
%22 = add nsw i32 %10, 3
br label %25
23: ; preds = %19, %8
%24 = phi i8 [ %20, %19 ], [ %14, %8 ]
store i8 %24, i8* %11
br label %25
25: ; preds = %21, %23
%26 = phi i8 [ 32, %21 ], [ %24, %23 ]
%27 = phi i32 [ %22, %21 ], [ %10, %23 ]
%28 = icmp eq i8 %26, 0
br i1 %28, label %29, label %8
29: ; preds = %25, %4, %1
ret void
}