#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__ Malloc(int);
int strlen(char *);
char *codePackage(char *package) {
  char *p;
  int i;
  p = (char *)Malloc(strlen(package) + 2);
  for (i = 0; i < strlen(package); i++) {
    if (package[i] == '.')
      p[i] = '/';
    else
      p[i] = package[i];
  }
  p[i] = '/';
  p[i + 1] = '\0';
  return p;
}


x86 assembly (clang, -O0):
<codePackage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x2,%edi
call   1030 <Malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11b5 <codePackage+0x95>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    118c <codePackage+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
jmp    11a2 <codePackage+0x82>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11a7 <codePackage+0x87>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <codePackage+0x2a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<codePackage>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1040 <strlen@plt>
lea    0x2(%rax),%edi
call   1030 <Malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    1171 <codePackage+0x51>
mov    $0x2f,%ebp
nopl   (%rax)
movzbl (%r15,%rbx,1),%eax
cmp    $0x2e,%al
cmove  %ebp,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1150 <codePackage+0x30>
mov    %ebx,%eax
movw   $0x2f,(%r14,%rax,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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