#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 transfer_mean(char *str) {
  char *head = NULL, *end = NULL;
  if (str == NULL) {
    return 0;
  }
  head = str;
  end = head;
  while (*head != '\0') {
    if ((*head == '\\\\')) {
      *head = '\\';
    }
    if (end < head) {
      *end = *head;
    }
    end++;
    head++;
  }
  *end = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<transfer_mean>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    112f <transfer_mean+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    11ad <transfer_mean+0xad>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119f <transfer_mean+0x9f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c5c,%eax
jne    1168 <transfer_mean+0x68>
mov    -0x18(%rbp),%rax
movb   $0x5c,(%rax)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1182 <transfer_mean+0x82>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113f <transfer_mean+0x3f>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_mean>:
test   %rdi,%rdi
je     111f <transfer_mean+0x1f>
cmpb   $0x0,(%rdi)
je     1122 <transfer_mean+0x22>
nopw   0x0(%rax,%rax,1)
lea    0x1(%rdi),%rax
cmpb   $0x0,0x1(%rdi)
mov    %rax,%rdi
jne    1110 <transfer_mean+0x10>
jmp    1125 <transfer_mean+0x25>
xor    %eax,%eax
ret
mov    %rdi,%rax
movb   $0x0,(%rax)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @transfer_mean(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %39
9: ; preds = %1
%10 = load i8*, i8** %3
store i8* %10, i8** %4
%11 = load i8*, i8** %4
store i8* %11, i8** %5
br label %12
12: ; preds = %32, %9
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %37
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 23644
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i8*, i8** %4
store i8 92, i8* %23
br label %24
24: ; preds = %22, %17
%25 = load i8*, i8** %5
%26 = load i8*, i8** %4
%27 = icmp ult i8* %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = load i8*, i8** %5
store i8 %30, i8* %31
br label %32
32: ; preds = %28, %24
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %12
37: ; preds = %12
%38 = load i8*, i8** %5
store i8 0, i8* %38
store i32 1, i32* %2
br label %39
39: ; preds = %37, %8
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @transfer_mean(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %8, %6 ], [ %0, %3 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %6
11: ; preds = %6, %3
%12 = phi i8* [ %0, %3 ], [ %8, %6 ]
store i8 0, i8* %12
br label %13
13: ; preds = %1, %11
%14 = phi i32 [ 1, %11 ], [ 0, %1 ]
ret i32 %14
}