#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*/ strcpy(char *, char const *);
int strlen(char *);
void _FolderEnter(char *curpath, const char *folder) {
  int len = strlen(curpath);
  if (curpath[len - 1] != '/')
    curpath[len++] = '/';
  strcpy(curpath + len, folder);
}


x86 assembly (clang, -O0):
<_FolderEnter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     116c <_FolderEnter+0x4c>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_FolderEnter>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%rcx
cmpb   $0x2f,-0x1(%rcx,%rbx,1)
je     1140 <_FolderEnter+0x20>
lea    0x1(%rcx),%eax
movb   $0x2f,(%rbx,%rcx,1)
cltq
add    %rax,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @_FolderEnter(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** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
%8 = load i8*, i8** %3
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 47
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
store i8 47, i8* %21
br label %22
22: ; preds = %16, %2
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8*, i8** %4
%28 = call i32 @strcpy(i8* %26, i8* %27)
ret void
}

LLVM IR (-O2):
define void @_FolderEnter(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 47
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = add nsw i32 %3, 1
%11 = sext i32 %3 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 47, i8* %12
br label %13
13: ; preds = %9, %2
%14 = phi i32 [ %10, %9 ], [ %3, %2 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = tail call i32 @strcpy(i8* %16, i8* %1)
ret void
}