#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*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
void path_unix_mac_root(char *path, char mac_path[512]) {
  int i;
  memset(mac_path, 0, 512);
  if (*path == '/')
    path++;
  mac_path[0] = ':';
  for (i = 0; i < strlen(path) && i < 510; i++)
    if (path[i] == '/')
      mac_path[i + 1] = ':';
    else
      mac_path[i + 1] = path[i];
}


x86 assembly (clang, -O0):
<path_unix_mac_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    115c <path_unix_mac_root+0x3c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x3a,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jge    1198 <path_unix_mac_root+0x78>
cmpl   $0x1fe,-0x14(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11a8 <path_unix_mac_root+0x88>
jmp    1201 <path_unix_mac_root+0xe1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11d3 <path_unix_mac_root+0xb3>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x3a,(%rax,%rcx,1)
jmp    11ee <path_unix_mac_root+0xce>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11f3 <path_unix_mac_root+0xd3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <path_unix_mac_root+0x4a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_unix_mac_root>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
xor    %r12d,%r12d
cmpb   $0x2f,(%r15)
sete   %r12b
add    %r15,%r12
movb   $0x3a,(%r14)
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    119b <path_unix_mac_root+0x7b>
xor    %ebx,%ebx
mov    $0x3a,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r12,%rbx,1),%eax
cmp    $0x2f,%al
cmove  %ebp,%eax
mov    %al,0x1(%r14,%rbx,1)
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x1fc,%rbx
ja     119b <path_unix_mac_root+0x7b>
add    $0x1,%rbx
cltq
cmp    %rax,%rbx
jl     1170 <path_unix_mac_root+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @path_unix_mac_root(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @memset(i8* %6, i32 0, i32 512)
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 47
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %15
15: ; preds = %12, %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 58, i8* %17
store i32 0, i32* %5
br label %18
18: ; preds = %54, %15
%19 = load i32, i32* %5
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 510
br label %26
26: ; preds = %23, %18
%27 = phi i1 [ false, %18 ], [ %25, %23 ]
br i1 %27, label %28, label %57
28: ; preds = %26
%29 = load i8*, i8** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %42
36: ; preds = %28
%37 = load i8*, i8** %4
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 58, i8* %41
br label %53
42: ; preds = %28
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = load i8*, i8** %4
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8 %47, i8* %52
br label %53
53: ; preds = %42, %36
br label %54
54: ; preds = %53
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %18
57: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @path_unix_mac_root(i8* %0, i8* %1) {
%3 = tail call i32 @memset(i8* %1, i32 0, i32 512)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 47
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %0, i64 %6
store i8 58, i8* %1
%8 = tail call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %2, %10
%11 = phi i64 [ %15, %10 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 47
%15 = add nuw nsw i64 %11, 1
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = select i1 %14, i8 58, i8 %13
store i8 %17, i8* %16
%18 = tail call i32 @strlen(i8* %7)
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %15, %19
%21 = icmp ult i64 %11, 509
%22 = and i1 %21, %20
br i1 %22, label %10, label %23
23: ; preds = %10, %2
ret void
}