#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 */
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ copy_file(char *, char *);
int /*<<< orphan*/ free(struct dirent *);
int /*<<< orphan*/ get_cur_time(char *);
int get_run_time(char *);
int /*<<< orphan*/ make_dir(char *);
int modified(char *, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int r1, r2, count = 0, index = 1;
  char lastrun[20];
  char curtime[20];
  r1 = get_run_time(lastrun);
  if (argc > 1) {
    while (index++ < argc) {
      r2 = modified(argv[index - 1], lastrun);
      if (r2 == 1) {
        count++;
        if (count == 1) {
          get_cur_time(curtime);
          make_dir(curtime);
        }
        copy_file(argv[index - 1], curtime);
      } else if (r2 == -1)
        printf("%s does not exist", argv[index - 1]);
      else
        continue;
    }
  } else {
    DIR *d;
    d = opendir(".");
    struct dirent *dir;
    dir = readdir(d);
    dir = readdir(d);
    while ((dir = readdir(d)) != NULL) {
      if (strcmp(dir->d_name, "assignment3.c") != 0 &&
          strcmp(dir->d_name, "backup") != 0 &&
          strcmp(dir->d_name, "last.txt") != 0) {
        if (modified(dir->d_name, lastrun) == 1) {
          count++;
          if (count == 1) {
            get_cur_time(curtime);
            make_dir(curtime);
          }
          copy_file(dir->d_name, curtime);
        }
      }
    }
    free(dir);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
call   10b0 <get_run_time@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    129e <main+0xfe>
jmp    11df <main+0x3f>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cmp    -0x8(%rbp),%eax
jge    1299 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <modified@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    125e <main+0xbe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    123f <main+0x9f>
lea    -0x60(%rbp),%rdi
call   1090 <get_cur_time@plt>
lea    -0x60(%rbp),%rdi
call   10c0 <make_dir@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <copy_file@plt>
jmp    1294 <main+0xf4>
cmpl   $0xffffffff,-0x18(%rbp)
jne    128a <main+0xea>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd80(%rip),%rdi
call   1070 <printf@plt>
jmp    128f <main+0xef>
jmp    11df <main+0x3f>
jmp    1294 <main+0xf4>
jmp    11df <main+0x3f>
jmp    1397 <main+0x1f7>
lea    0xd6d(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
je     138e <main+0x1ee>
mov    -0x70(%rbp),%rax
mov    (%rax),%rdi
lea    0xd27(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1389 <main+0x1e9>
mov    -0x70(%rbp),%rax
mov    (%rax),%rdi
lea    0xd18(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1389 <main+0x1e9>
mov    -0x70(%rbp),%rax
mov    (%rax),%rdi
lea    0xd02(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1389 <main+0x1e9>
mov    -0x70(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <modified@plt>
cmp    $0x1,%eax
jne    1384 <main+0x1e4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1374 <main+0x1d4>
lea    -0x60(%rbp),%rdi
call   1090 <get_cur_time@plt>
lea    -0x60(%rbp),%rdi
call   10c0 <make_dir@plt>
mov    -0x70(%rbp),%rax
mov    (%rax),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <copy_file@plt>
jmp    1389 <main+0x1e9>
jmp    12c8 <main+0x128>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
mov    %edi,%r15d
lea    0x40(%rsp),%rdi
call   10b0 <get_run_time@plt>
cmp    $0x2,%r15d
jl     1292 <main+0xf2>
add    $0xfffffffffffffff8,%rbp
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    $0x1,%eax
lea    0x40(%rsp),%rbx
mov    %rbp,0x18(%rsp)
mov    %eax,0xc(%rsp)
cltq
cmp    %r15d,%eax
mov    %r15d,%ecx
cmovg  %eax,%ecx
movslq %ecx,%r14
lea    0x0(,%rax,8),%r13
add    %rbp,%r13
sub    %rax,%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r12,%r14
je     1389 <main+0x1e9>
mov    0x8(%r13,%r12,8),%rdi
mov    %rbx,%rsi
call   1060 <modified@plt>
add    $0x1,%r12
cmp    $0xffffffff,%eax
je     1270 <main+0xd0>
cmp    $0x1,%eax
jne    1210 <main+0x70>
mov    0x10(%rsp),%rbp
test   %ebp,%ebp
jne    1252 <main+0xb2>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1090 <get_cur_time@plt>
mov    %r14,%rdi
call   10c0 <make_dir@plt>
add    $0x1,%ebp
mov    %rbp,0x10(%rsp)
mov    0x0(%r13,%r12,8),%rdi
lea    0x20(%rsp),%rsi
call   1040 <copy_file@plt>
jmp    1281 <main+0xe1>
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%r12,8),%rsi
lea    0xd84(%rip),%rdi
call   1070 <printf@plt>
mov    0xc(%rsp),%eax
add    %r12d,%eax
mov    0x18(%rsp),%rbp
jmp    11e2 <main+0x42>
lea    0xd79(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <readdir@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    %rbx,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     1382 <main+0x1e2>
mov    %rax,%r13
xor    %r12d,%r12d
lea    0xd45(%rip),%r14
lea    0xd4c(%rip),%r15
lea    0xd4c(%rip),%rbp
jmp    1310 <main+0x170>
add    $0x1,%r12d
mov    0x0(%r13),%rdi
lea    0x20(%rsp),%rsi
call   1040 <copy_file@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
je     1382 <main+0x1e2>
mov    0x0(%r13),%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1300 <main+0x160>
mov    0x0(%r13),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1300 <main+0x160>
mov    0x0(%r13),%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1300 <main+0x160>
mov    0x0(%r13),%rdi
lea    0x40(%rsp),%rsi
call   1060 <modified@plt>
cmp    $0x1,%eax
jne    1300 <main+0x160>
test   %r12d,%r12d
jne    12df <main+0x13f>
mov    %r15,%rbp
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1090 <get_cur_time@plt>
mov    %r15,%rdi
mov    %rbp,%r15
lea    0xcb1(%rip),%rbp
call   10c0 <make_dir@plt>
jmp    12df <main+0x13f>
xor    %edi,%edi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [18 x i8] c"%s does not exist\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [14 x i8] c"assignment3.c\00"
@.str.3 = [7 x i8] c"backup\00"
@.str.4 = [9 x i8] c"last.txt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [20 x i8]
%11 = alloca [20 x i8]
%12 = alloca i32*
%13 = alloca %struct.dirent*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 1, i32* %9
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%15 = call i32 @get_run_time(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %69
18: ; preds = %2
br label %19
19: ; preds = %67, %65, %18
%20 = load i32, i32* %9
%21 = add nsw i32 %20, 1
store i32 %21, i32* %9
%22 = load i32, i32* %4
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %68
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = load i32, i32* %9
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %25, i64 %28
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%32 = call i32 @modified(i8* %30, i8* %31)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %54
35: ; preds = %24
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%42 = call i32 @get_cur_time(i8* %41)
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%44 = call i32 @make_dir(i8* %43)
br label %45
45: ; preds = %40, %35
%46 = load i8**, i8*** %5
%47 = load i32, i32* %9
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%53 = call i32 @copy_file(i8* %51, i8* %52)
br label %67
54: ; preds = %24
%55 = load i32, i32* %7
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %65
57: ; preds = %54
%58 = load i8**, i8*** %5
%59 = load i32, i32* %9
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %58, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %63)
br label %66
65: ; preds = %54
br label %19
66: ; preds = %57
br label %67
67: ; preds = %66, %45
br label %19
68: ; preds = %19
br label %125
69: ; preds = %2
%70 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %70, i32** %12
%71 = load i32*, i32** %12
%72 = call %struct.dirent* @readdir(i32* %71)
store %struct.dirent* %72, %struct.dirent** %13
%73 = load i32*, i32** %12
%74 = call %struct.dirent* @readdir(i32* %73)
store %struct.dirent* %74, %struct.dirent** %13
br label %75
75: ; preds = %121, %69
%76 = load i32*, i32** %12
%77 = call %struct.dirent* @readdir(i32* %76)
store %struct.dirent* %77, %struct.dirent** %13
%78 = icmp ne %struct.dirent* %77, null
br i1 %78, label %79, label %122
79: ; preds = %75
%80 = load %struct.dirent*, %struct.dirent** %13
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 0
%82 = load i8*, i8** %81
%83 = call i64 @strcmp(i8* %82, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %121
85: ; preds = %79
%86 = load %struct.dirent*, %struct.dirent** %13
%87 = getelementptr inbounds %struct.dirent, %struct.dirent* %86, i32 0, i32 0
%88 = load i8*, i8** %87
%89 = call i64 @strcmp(i8* %88, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %121
91: ; preds = %85
%92 = load %struct.dirent*, %struct.dirent** %13
%93 = getelementptr inbounds %struct.dirent, %struct.dirent* %92, i32 0, i32 0
%94 = load i8*, i8** %93
%95 = call i64 @strcmp(i8* %94, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %121
97: ; preds = %91
%98 = load %struct.dirent*, %struct.dirent** %13
%99 = getelementptr inbounds %struct.dirent, %struct.dirent* %98, i32 0, i32 0
%100 = load i8*, i8** %99
%101 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%102 = call i32 @modified(i8* %100, i8* %101)
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %120
104: ; preds = %97
%105 = load i32, i32* %8
%106 = add nsw i32 %105, 1
store i32 %106, i32* %8
%107 = load i32, i32* %8
%108 = icmp eq i32 %107, 1
br i1 %108, label %109, label %114
109: ; preds = %104
%110 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%111 = call i32 @get_cur_time(i8* %110)
%112 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%113 = call i32 @make_dir(i8* %112)
br label %114
114: ; preds = %109, %104
%115 = load %struct.dirent*, %struct.dirent** %13
%116 = getelementptr inbounds %struct.dirent, %struct.dirent* %115, i32 0, i32 0
%117 = load i8*, i8** %116
%118 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%119 = call i32 @copy_file(i8* %117, i8* %118)
br label %120
120: ; preds = %114, %97
br label %121
121: ; preds = %120, %91, %85, %79
br label %75
122: ; preds = %75
%123 = load %struct.dirent*, %struct.dirent** %13
%124 = call i32 @free(%struct.dirent* %123)
br label %125
125: ; preds = %122, %68
%126 = load i32, i32* %3
ret i32 %126
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [18 x i8] c"%s does not exist\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [14 x i8] c"assignment3.c\00"
@.str.3 = [7 x i8] c"backup\00"
@.str.4 = [9 x i8] c"last.txt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = call i32 @get_run_time(i8* %5)
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %40
9: ; preds = %2, %37
%10 = phi i32 [ %39, %37 ], [ 1, %2 ]
%11 = phi i32 [ %38, %37 ], [ 0, %2 ]
%12 = sext i32 %10 to i64
%13 = call i32 @llvm.smax.i32(i32 %10, i32 %0)
%14 = sext i32 %13 to i64
br label %15
15: ; preds = %9, %19
%16 = phi i64 [ %12, %9 ], [ %17, %19 ]
%17 = add nsw i64 %16, 1
%18 = icmp eq i64 %16, %14
br i1 %18, label %80, label %19
19: ; preds = %15
%20 = getelementptr inbounds i8*, i8** %1, i64 %16
%21 = load i8*, i8** %20
%22 = call i32 @modified(i8* %21, i8* %5)
switch i32 %22, label %15 [
i32 1, label %23
i32 -1, label %33
]
23: ; preds = %19
%24 = getelementptr inbounds i8*, i8** %1, i64 %16
%25 = add nsw i32 %11, 1
%26 = icmp eq i32 %11, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @get_cur_time(i8* %6)
%29 = call i32 @make_dir(i8* %6)
br label %30
30: ; preds = %27, %23
%31 = load i8*, i8** %24
%32 = call i32 @copy_file(i8* %31, i8* %6)
br label %37
33: ; preds = %19
%34 = getelementptr inbounds i8*, i8** %1, i64 %16
%35 = load i8*, i8** %34
%36 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %33, %30
%38 = phi i32 [ %25, %30 ], [ %11, %33 ]
%39 = trunc i64 %17 to i32
br label %9
40: ; preds = %2
%41 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = call %struct.dirent* @readdir(i32* %41)
%43 = call %struct.dirent* @readdir(i32* %41)
%44 = call %struct.dirent* @readdir(i32* %41)
%45 = icmp eq %struct.dirent* %44, null
br i1 %45, label %78, label %46
46: ; preds = %40, %74
%47 = phi %struct.dirent* [ %76, %74 ], [ %44, %40 ]
%48 = phi i32 [ %75, %74 ], [ 0, %40 ]
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %47, i64 0, i32 0
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %74, label %53
53: ; preds = %46
%54 = load i8*, i8** %49
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %74, label %57
57: ; preds = %53
%58 = load i8*, i8** %49
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %74, label %61
61: ; preds = %57
%62 = load i8*, i8** %49
%63 = call i32 @modified(i8* %62, i8* %5)
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = add nsw i32 %48, 1
%67 = icmp eq i32 %48, 0
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = call i32 @get_cur_time(i8* %6)
%70 = call i32 @make_dir(i8* %6)
br label %71
71: ; preds = %68, %65
%72 = load i8*, i8** %49
%73 = call i32 @copy_file(i8* %72, i8* %6)
br label %74
74: ; preds = %61, %71, %57, %53, %46
%75 = phi i32 [ %66, %71 ], [ %48, %61 ], [ %48, %57 ], [ %48, %53 ], [ %48, %46 ]
%76 = call %struct.dirent* @readdir(i32* %41)
%77 = icmp eq %struct.dirent* %76, null
br i1 %77, label %78, label %46
78: ; preds = %74, %40
%79 = call i32 @free(%struct.dirent* null)
br label %80
80: ; preds = %15, %78
ret i32 0
}