#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
void copyFile(char *old_file, char *new_file) {
  FILE *fp1;
  char *command = (char *)malloc(200 * sizeof(char));
  sprintf(command, "cp db/stage1_input/%s db/stage1_input/%s", old_file,
          new_file);
  fp1 = popen(command, "r");
  if (fp1 == 0)
    perror(command);
  free(command);
  pclose(fp1);
}


x86 assembly (clang, -O0):
<copyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6f(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11be <copyFile+0x5e>
mov    -0x20(%rbp),%rdi
call   1070 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyFile>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0xc8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe81(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1080 <sprintf@plt>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1060 <popen@plt>
mov    %rax,%r14
test   %rax,%rax
je     11b9 <copyFile+0x59>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <pclose@plt>
mov    %rbx,%rdi
call   1070 <perror@plt>
jmp    11a4 <copyFile+0x44>

LLVM IR (-O0):
@.str = [41 x i8] c"cp db/stage1_input/%s db/stage1_input/%s\00"
@.str.1 = [2 x i8] c"r\00"
define void @copyFile(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i64 @malloc(i32 200)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %3
%11 = load i8*, i8** %4
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %6
%14 = call i32* @popen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i32 @perror(i8* %18)
br label %20
20: ; preds = %17, %2
%21 = load i8*, i8** %6
%22 = call i32 @free(i8* %21)
%23 = load i32*, i32** %5
%24 = call i32 @pclose(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"cp db/stage1_input/%s db/stage1_input/%s\00"
@.str.1 = [2 x i8] c"r\00"
define void @copyFile(i8* %0, i8* %1) {
%3 = tail call i64 @malloc(i32 200)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = tail call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* %4)
br label %10
10: ; preds = %8, %2
%11 = tail call i32 @free(i8* %4)
%12 = tail call i32 @pclose(i32* %6)
ret void
}