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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
char *ctime(int /*<<< orphan*/ *);
int difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "utilisation: %s chemin nbjours\n", argv[0]);
    exit(1);
  }
  int nbjours = atoi(argv[2]);
  DIR *rep = opendir(argv[1]);
  if (rep == NULL) {
    fprintf(stderr, "Impossible d'ouvrir le répertoire : %s\n", argv[1]);
    exit(2);
  }
  struct dirent *entree;
  char chemin[512];
  struct stat etat;
  struct timeval now;
  if (gettimeofday(&now, NULL) < 0) {
    fprintf(stderr, "Impossible d'obtenir la date système :!\n");
    exit(3);
  }
  while ((entree = readdir(rep)) != NULL) {
    strcat(strcat(strcpy(chemin, argv[1]), "/"), entree->d_name);
    if (lstat(chemin, &etat) < 0) {
      fprintf(stderr, "Impossible d'ouvrir le fichier : %s\n", chemin);
      exit(4);
    }
    if (difftime(now.tv_sec, etat.st_mtime) < nbjours * 24 * 60 * 60) {
      printf("%s %s", entree->d_name, ctime(&(etat.st_mtime)));
    }
  }
  closedir(rep);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     121b <main+0x4b>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1270 <main+0xa0>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>
lea    -0x240(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
cmp    $0x0,%rax
jge    12ab <main+0xdb>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x3,%edi
call   10f0 <exit@plt>
jmp    12b0 <main+0xe0>
mov    -0x20(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1394 <main+0x1c4>
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    0xd8f(%rip),%rsi
call   10e0 <strcat@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
call   10e0 <strcat@plt>
lea    -0x230(%rbp),%rdi
lea    -0x238(%rbp),%rsi
call   10a0 <lstat@plt>
cmp    $0x0,%rax
jge    133c <main+0x16c>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
lea    -0x230(%rbp),%rdx
lea    0xd4a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x4,%edi
call   10f0 <exit@plt>
mov    -0x240(%rbp),%edi
mov    -0x238(%rbp),%esi
call   1070 <difftime@plt>
imul   $0x18,-0x14(%rbp),%ecx
imul   $0x3c,%ecx,%ecx
imul   $0x3c,%ecx,%ecx
cmp    %ecx,%eax
jge    138f <main+0x1bf>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x248(%rbp)
lea    -0x238(%rbp),%rdi
call   1050 <ctime@plt>
mov    -0x248(%rbp),%rsi
mov    %rax,%rdx
lea    0xd10(%rip),%rdi
call   1060 <printf@plt>
jmp    12b0 <main+0xe0>
mov    -0x20(%rbp),%rdi
call   1090 <closedir@plt>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
jne    130c <main+0x13c>
mov    0x10(%r15),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%r15),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     1330 <main+0x160>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
test   %rax,%rax
js     1355 <main+0x185>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     12ca <main+0xfa>
mov    %rax,%r12
mov    0x8(%rsp),%r13d
imul   $0x15180,%r14d,%r14d
lea    0x10(%rsp),%rbp
jmp    1260 <main+0x90>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     12ca <main+0xfa>
mov    0x8(%r15),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    0xdfe(%rip),%rsi
call   10e0 <strcat@plt>
mov    (%r12),%rsi
mov    %eax,%edi
call   10e0 <strcat@plt>
mov    %rbp,%rdi
mov    %rsp,%rsi
call   10a0 <lstat@plt>
test   %rax,%rax
js     12e6 <main+0x116>
mov    (%rsp),%esi
mov    %r13d,%edi
call   1070 <difftime@plt>
cmp    %r14d,%eax
jge    1250 <main+0x80>
mov    (%r12),%rbp
mov    %rsp,%rdi
call   1050 <ctime@plt>
lea    0xde2(%rip),%rdi
mov    %rbp,%rsi
lea    0x10(%rsp),%rbp
mov    %rax,%rdx
call   1060 <printf@plt>
jmp    1250 <main+0x80>
mov    %rbx,%rdi
call   1090 <closedir@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x4,%edi
call   10f0 <exit@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xce1(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xcdc(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x3,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"utilisation: %s chemin nbjours\0A\00"
@.str.1 = [41 x i8] c"Impossible d'ouvrir le r\C3\A9pertoire : %s\0A\00"
@.str.2 = [42 x i8] c"Impossible d'obtenir la date syst\C3\A8me :!\0A\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [37 x i8] c"Impossible d'ouvrir le fichier : %s\0A\00"
@.str.5 = [6 x i8] c"%s %s\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 %struct.dirent*
%9 = alloca [512 x i8]
%10 = alloca %struct.stat
%11 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @opendir(i8* %28)
store i32* %29, i32** %7
%30 = load i32*, i32** %7
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %39
32: ; preds = %21
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = call i32 @exit(i32 2)
unreachable
39: ; preds = %21
%40 = call i64 @gettimeofday(%struct.timeval* %11, i32* null)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @exit(i32 3)
unreachable
46: ; preds = %39
br label %47
47: ; preds = %88, %46
%48 = load i32*, i32** %7
%49 = call %struct.dirent* @readdir(i32* %48)
store %struct.dirent* %49, %struct.dirent** %8
%50 = icmp ne %struct.dirent* %49, null
br i1 %50, label %51, label %89
51: ; preds = %47
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 @strcpy(i8* %52, i8* %55)
%57 = call i32 @strcat(i32 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%58 = load %struct.dirent*, %struct.dirent** %8
%59 = getelementptr inbounds %struct.dirent, %struct.dirent* %58, i32 0, i32 0
%60 = load i8*, i8** %59
%61 = call i32 @strcat(i32 %57, i8* %60)
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%63 = call i64 @lstat(i8* %62, %struct.stat* %10)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %51
%66 = load i32, i32* @stderr
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 4)
unreachable
70: ; preds = %51
%71 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%72 = load i32, i32* %71
%73 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%74 = load i32, i32* %73
%75 = call i32 @difftime(i32 %72, i32 %74)
%76 = load i32, i32* %6
%77 = mul nsw i32 %76, 24
%78 = mul nsw i32 %77, 60
%79 = mul nsw i32 %78, 60
%80 = icmp slt i32 %75, %79
br i1 %80, label %81, label %88
81: ; preds = %70
%82 = load %struct.dirent*, %struct.dirent** %8
%83 = getelementptr inbounds %struct.dirent, %struct.dirent* %82, i32 0, i32 0
%84 = load i8*, i8** %83
%85 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%86 = call i8* @ctime(i32* %85)
%87 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %84, i8* %86)
br label %88
88: ; preds = %81, %70
br label %47
89: ; preds = %47
%90 = load i32*, i32** %7
%91 = call i32 @closedir(i32* %90)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.timeval = type { i32 }
%struct.dirent = type { i8* }
@stderr = global i32 0
@.str = [32 x i8] c"utilisation: %s chemin nbjours\0A\00"
@.str.1 = [41 x i8] c"Impossible d'ouvrir le r\C3\A9pertoire : %s\0A\00"
@.str.2 = [42 x i8] c"Impossible d'obtenir la date syst\C3\A8me :!\0A\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [37 x i8] c"Impossible d'ouvrir le fichier : %s\0A\00"
@.str.5 = [6 x i8] c"%s %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca %struct.stat
%5 = alloca %struct.timeval
%6 = icmp eq i32 %0, 3
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @opendir(i8* %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %12
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %16
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = tail call i32 @exit(i32 2)
unreachable
25: ; preds = %12
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%27 = bitcast %struct.stat* %4 to i8*
%28 = bitcast %struct.timeval* %5 to i8*
%29 = call i64 @gettimeofday(%struct.timeval* %5, i32* null)
%30 = icmp slt i64 %29, 0
br i1 %30, label %39, label %31
31: ; preds = %25
%32 = call %struct.dirent* @readdir(i32* %18)
%33 = icmp eq %struct.dirent* %32, null
br i1 %33, label %68, label %34
34: ; preds = %31
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%38 = mul i32 %15, 86400
br label %43
39: ; preds = %25
%40 = load i32, i32* @stderr
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%42 = tail call i32 @exit(i32 3)
unreachable
43: ; preds = %34, %65
%44 = phi %struct.dirent* [ %32, %34 ], [ %66, %65 ]
%45 = load i8*, i8** %16
%46 = call i32 @strcpy(i8* %26, i8* %45)
%47 = call i32 @strcat(i32 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = getelementptr inbounds %struct.dirent, %struct.dirent* %44, i64 0, i32 0
%49 = load i8*, i8** %48
%50 = call i32 @strcat(i32 %47, i8* %49)
%51 = call i64 @lstat(i8* %26, %struct.stat* %4)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %43
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %26)
%56 = call i32 @exit(i32 4)
unreachable
57: ; preds = %43
%58 = load i32, i32* %37
%59 = call i32 @difftime(i32 %36, i32 %58)
%60 = icmp slt i32 %59, %38
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = load i8*, i8** %48
%63 = call i8* @ctime(i32* %37)
%64 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %62, i8* %63)
br label %65
65: ; preds = %61, %57
%66 = call %struct.dirent* @readdir(i32* %18)
%67 = icmp eq %struct.dirent* %66, null
br i1 %67, label %68, label %43
68: ; preds = %65, %31
%69 = call i32 @closedir(i32* %18)
ret i32 0
}