#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*/ execv(char *, char **);
int /*<<< orphan*/ lockAllFiles(char *);
int /*<<< orphan*/ logInfoMessage(char *);
int /*<<< orphan*/ unlockAllFiles(char *);
void update_folder(char *sourceFile, char *targetFile) {
  lockAllFiles(targetFile);
  char *args[] = {"cp", "-R", sourceFile, targetFile, NULL};
  execv("/bin/cp", args);
  logInfoMessage("backup completed");
  unlockAllFiles(targetFile);
}


x86 assembly (clang, -O0):
<update_folder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <lockAllFiles@plt>
lea    0xea8(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1060 <execv@plt>
lea    0xe6d(%rip),%rdi
call   1040 <logInfoMessage@plt>
mov    -0x10(%rbp),%rdi
call   1050 <unlockAllFiles@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_folder>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <lockAllFiles@plt>
lea    0xeac(%rip),%rax
mov    %rax,(%rsp)
lea    0xe99(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe7d(%rip),%rdi
mov    %rsp,%rsi
call   1060 <execv@plt>
lea    0xe76(%rip),%rdi
call   1040 <logInfoMessage@plt>
mov    %rbx,%rdi
call   1050 <unlockAllFiles@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cp\00"
@.str.1 = [3 x i8] c"-R\00"
@.str.2 = [8 x i8] c"/bin/cp\00"
@.str.3 = [17 x i8] c"backup completed\00"
define void @update_folder(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [5 x i8*]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @lockAllFiles(i8* %6)
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds i8*, i8** %8, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %3
store i8* %11, i8** %10
%12 = getelementptr inbounds i8*, i8** %10, i64 1
%13 = load i8*, i8** %4
store i8* %13, i8** %12
%14 = getelementptr inbounds i8*, i8** %12, i64 1
store i8* null, i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
%16 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %15)
%17 = call i32 @logInfoMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%18 = load i8*, i8** %4
%19 = call i32 @unlockAllFiles(i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"cp\00"
@.str.1 = [3 x i8] c"-R\00"
@.str.2 = [8 x i8] c"/bin/cp\00"
@.str.3 = [17 x i8] c"backup completed\00"
define void @update_folder(i8* %0, i8* %1) {
%3 = alloca [5 x i8*]
%4 = tail call i32 @lockAllFiles(i8* %1)
%5 = bitcast [5 x i8*]* %3 to i8*
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = 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** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 2
store i8* %0, i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 3
store i8* %1, i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 4
store i8* null, i8** %10
%11 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %6)
%12 = call i32 @logInfoMessage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @unlockAllFiles(i8* %1)
ret void
}