#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*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ execv(char *, char **);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  time_t rawtime;
  struct tm *timeinfo;
  char buffer[80];
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  strftime(buffer, 80, "%d_%m_%Y/", timeinfo);
  puts(buffer);
  char source_file[255] =
      "/Users/timothybarnard/Documents/SystemSoftware/Assignment1/html";
  char target_file[255] =
      "/Users/timothybarnard/Documents/SystemSoftware/Assignment1/folder/";
  strcat(target_file, buffer);
  char *args[] = {"cp", "-R", source_file, target_file, NULL};
  execv("/bin/cp", args);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <time@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x50,%esi
lea    0xe54(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x60(%rbp),%rdi
call   1040 <puts@plt>
lea    -0x160(%rbp),%rdi
lea    0xe58(%rip),%rsi
mov    $0xff,%edx
call   1050 <memcpy@plt>
lea    -0x260(%rbp),%rdi
lea    0xf40(%rip),%rsi
mov    $0xff,%edx
call   1050 <memcpy@plt>
lea    -0x260(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <strcat@plt>
lea    0xe11(%rip),%rax
mov    %rax,-0x290(%rbp)
lea    0xdfb(%rip),%rax
mov    %rax,-0x288(%rbp)
lea    -0x160(%rbp),%rax
mov    %rax,-0x280(%rbp)
lea    -0x260(%rbp),%rax
mov    %rax,-0x278(%rbp)
movq   $0x0,-0x270(%rbp)
lea    -0x290(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   1090 <execv@plt>
xor    %eax,%eax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x290,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe68(%rip),%rdx
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    $0x50,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
lea    0xe64(%rip),%rsi
lea    0x190(%rsp),%r14
mov    $0xff,%edx
mov    %r14,%rdi
call   1050 <memcpy@plt>
lea    0xf48(%rip),%rsi
lea    0x90(%rsp),%rbx
mov    $0xff,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
lea    0xe13(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xdff(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %r14,0x20(%rsp)
mov    %rbx,0x28(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xde3(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1090 <execv@plt>
xor    %eax,%eax
add    $0x290,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [10 x i8] c"%d_%m_%Y/\00"
@__const.main.source_file = [255 x i8] c"/Users/timothybarnard/Documents/SystemSoftware/Assignment1/html\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.target_file = [255 x i8] c"/Users/timothybarnard/Documents/SystemSoftware/Assignment1/folder/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [3 x i8] c"cp\00"
@.str.2 = [3 x i8] c"-R\00"
@.str.3 = [8 x i8] c"/bin/cp\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [80 x i8]
%5 = alloca [255 x i8]
%6 = alloca [255 x i8]
%7 = alloca [5 x i8*]
store i32 0, i32* %1
%8 = call i32 @time(i32* %2)
%9 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %9, %struct.tm** %3
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = load %struct.tm*, %struct.tm** %3
%12 = call i32 @strftime(i8* %10, i32 80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%14 = call i32 @puts(i8* %13)
%15 = bitcast [255 x i8]* %5 to i8*
%16 = bitcast [255 x i8]* %6 to i8*
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds i8*, i8** %20, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
store i8* %23, i8** %22
%24 = getelementptr inbounds i8*, i8** %22, i64 1
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
store i8* %25, i8** %24
%26 = getelementptr inbounds i8*, i8** %24, i64 1
store i8* null, i8** %26
%27 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i64 0, i64 0
%28 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %27)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [10 x i8] c"%d_%m_%Y/\00"
@__const.main.source_file = [255 x i8] c"/Users/timothybarnard/Documents/SystemSoftware/Assignment1/html\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.target_file = [255 x i8] c"/Users/timothybarnard/Documents/SystemSoftware/Assignment1/folder/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [3 x i8] c"cp\00"
@.str.2 = [3 x i8] c"-R\00"
@.str.3 = [8 x i8] c"/bin/cp\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [5 x i8*]
%6 = bitcast i32* %1 to i8*
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%8 = call i32 @time(i32* %1)
%9 = call %struct.tm* @localtime(i32* %1)
%10 = call i32 @strftime(i8* %7, i32 80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = call i32 @puts(i8* %7)
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%14 = call i32 @strcat(i8* %13, i8* %7)
%15 = bitcast [5 x i8*]* %5 to i8*
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 2
store i8* %12, i8** %18
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 3
store i8* %13, i8** %19
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 4
store i8* null, i8** %20
%21 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %16)
ret i32 0
}