#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*/ cl_must_pass_(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ shell_out(char **);
char *strdup(char const *);
size_t strlen(char *);
void fs_copy(const char *_source, const char *dest) {
  char *argv[5];
  char *source;
  size_t source_len;
  source = strdup(_source);
  source_len = strlen(source);
  if (source[source_len - 1] == '/')
    source[source_len - 1] = 0;
  argv[0] = "/bin/cp";
  argv[1] = "-R";
  argv[2] = source;
  argv[3] = (char *)dest;
  argv[4] = NULL;
  cl_must_pass_(shell_out(argv), "Failed to copy test fixtures to sandbox");
  free(source);
}


x86 assembly (clang, -O0):
<fs_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11a3 <fs_copy+0x53>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe56(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <shell_out@plt>
mov    %eax,%edi
lea    0xe28(%rip),%rsi
call   1070 <cl_must_pass_@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fs_copy>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    1176 <fs_copy+0x26>
movb   $0x0,-0x1(%rbx,%rax,1)
lea    0xe83(%rip),%rax
mov    %rax,(%rsp)
lea    0xe80(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    %rsp,%rdi
call   1040 <shell_out@plt>
lea    0xe5c(%rip),%rsi
mov    %eax,%edi
call   1070 <cl_must_pass_@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/cp\00"
@.str.1 = [3 x i8] c"-R\00"
@.str.2 = [40 x i8] c"Failed to copy test fixtures to sandbox\00"
define void @fs_copy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [5 x i8*]
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %7
%12 = load i8*, i8** %6
%13 = load i64, i64* %7
%14 = sub i64 %13, 1
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = load i64, i64* %7
%22 = sub i64 %21, 1
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %19, %2
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %26
%27 = load i8*, i8** %6
%28 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 2
store i8* %27, i8** %28
%29 = load i8*, i8** %4
%30 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 3
store i8* %29, i8** %30
%31 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 4
store i8* null, i8** %31
%32 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
%33 = call i32 @shell_out(i8** %32)
%34 = call i32 @cl_must_pass_(i32 %33, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%35 = load i8*, i8** %6
%36 = call i32 @free(i8* %35)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/cp\00"
@.str.1 = [3 x i8] c"-R\00"
@.str.2 = [40 x i8] c"Failed to copy test fixtures to sandbox\00"
define void @fs_copy(i8* nocapture %0, i8* %1) {
%3 = alloca [5 x i8*]
%4 = bitcast [5 x i8*]* %3 to i8*
%5 = tail call i8* @strdup(i8* %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%7 = add i64 %6, -1
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 47
br i1 %10, label %11, label %12
11: ; preds = %2
store i8 0, i8* %8
br label %12
12: ; preds = %11, %2
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 2
store i8* %5, i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 3
store i8* %1, i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 4
store i8* null, i8** %17
%18 = call i32 @shell_out(i8** %13)
%19 = call i32 @cl_must_pass_(i32 %18, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @free(i8* %5)
ret void
}