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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strncat(char *, int /*<<< orphan*/, int);
scalar_t__ strncmp(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int time(int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
main() {
  char *popauthdir = "/var/spool/popauth/";
  char filename[1024];
  DIR *Popdir;
  struct dirent *entry;
  struct stat fileinfo;
  time_t age;
  if ((Popdir = opendir(popauthdir)) == NULL) {
    printf("Could not open %s", popauthdir);
    exit(1);
  }
  while ((entry = readdir(Popdir)) != NULL) {
    if (strncmp(entry->d_name, ".", 1) != 0) {
      bzero(filename, 1024);
      strncpy(filename, popauthdir, 256);
      strncat(filename, entry->d_name, 256);
      if (stat(filename, &fileinfo) == 0)
        ;
      {
        age = time(NULL) - fileinfo.st_mtime;
        if (age > 1800)
          unlink(filename);
      }
    }
  }
  closedir(Popdir);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe27(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
jne    1211 <main+0x51>
mov    -0x10(%rbp),%rsi
lea    0xe12(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    1216 <main+0x56>
mov    -0x418(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x420(%rbp)
cmp    $0x0,%rax
je     12f4 <main+0x134>
mov    -0x420(%rbp),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
mov    $0x1,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     12ef <main+0x12f>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   10d0 <bzero@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rax
mov    (%rax),%esi
mov    $0x100,%edx
call   1080 <strncat@plt>
lea    -0x410(%rbp),%rdi
lea    -0x428(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0x0,%rax
jne    12b9 <main+0xf9>
jmp    12b9 <main+0xf9>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
sub    -0x428(%rbp),%eax
mov    %eax,-0x42c(%rbp)
cmpl   $0x708,-0x42c(%rbp)
jle    12ea <main+0x12a>
lea    -0x410(%rbp),%rdi
call   1030 <unlink@plt>
jmp    12ef <main+0x12f>
jmp    1216 <main+0x56>
mov    -0x418(%rbp),%rdi
call   1090 <closedir@plt>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xe28(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     12b5 <main+0xf5>
mov    %rax,%r15
mov    %rax,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1299 <main+0xd9>
mov    %rax,%rbp
lea    0xe22(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xdf0(%rip),%r12
lea    0x8(%rsp),%r13
jmp    1230 <main+0x70>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1299 <main+0xd9>
mov    0x0(%rbp),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1220 <main+0x60>
mov    %rbx,%rdi
mov    $0x400,%esi
call   10d0 <bzero@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
mov    $0x100,%edx
call   1080 <strncat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <stat@plt>
xor    %edi,%edi
call   10b0 <time@plt>
sub    0x8(%rsp),%eax
cmp    $0x709,%eax
jl     1220 <main+0x60>
mov    %rbx,%rdi
call   1030 <unlink@plt>
jmp    1220 <main+0x60>
mov    %r15,%rdi
call   1090 <closedir@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd58(%rip),%rdi
lea    0xd3d(%rip),%rsi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i32 }
%struct.stat = type { i32 }
@.str = [20 x i8] c"/var/spool/popauth/\00"
@.str.1 = [18 x i8] c"Could not open %s\00"
@.str.2 = [2 x i8] c".\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32*
%5 = alloca %struct.dirent*
%6 = alloca %struct.stat
%7 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %2
%8 = load i8*, i8** %2
%9 = call i32* @opendir(i8* %8)
store i32* %9, i32** %4
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
br label %16
16: ; preds = %52, %15
%17 = load i32*, i32** %4
%18 = call %struct.dirent* @readdir(i32* %17)
store %struct.dirent* %18, %struct.dirent** %5
%19 = icmp ne %struct.dirent* %18, null
br i1 %19, label %20, label %53
20: ; preds = %16
%21 = load %struct.dirent*, %struct.dirent** %5
%22 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i64 @strncmp(i32 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %52
26: ; preds = %20
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%28 = call i32 @bzero(i8* %27, i32 1024)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%30 = load i8*, i8** %2
%31 = call i32 @strncpy(i8* %29, i8* %30, i32 256)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%33 = load %struct.dirent*, %struct.dirent** %5
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @strncat(i8* %32, i32 %35, i32 256)
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%38 = call i64 @stat(i8* %37, %struct.stat* %6)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %26
br label %41
41: ; preds = %40, %26
%42 = call i32 @time(i32* null)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%44 = load i32, i32* %43
%45 = sub nsw i32 %42, %44
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = icmp sgt i32 %46, 1800
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%50 = call i32 @unlink(i8* %49)
br label %51
51: ; preds = %48, %41
br label %52
52: ; preds = %51, %20
br label %16
53: ; preds = %16
%54 = load i32*, i32** %4
%55 = call i32 @closedir(i32* %54)
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i32 }
@.str = [20 x i8] c"/var/spool/popauth/\00"
@.str.1 = [18 x i8] c"Could not open %s\00"
@.str.2 = [2 x i8] c".\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca %struct.stat
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.stat* %2 to i8*
%5 = tail call i32* @opendir(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %12, label %7
7: ; preds = %0
%8 = call %struct.dirent* @readdir(i32* %5)
%9 = icmp eq %struct.dirent* %8, null
br i1 %9, label %36, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
br label %15
12: ; preds = %0
%13 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %10, %33
%16 = phi %struct.dirent* [ %8, %10 ], [ %34, %33 ]
%17 = getelementptr inbounds %struct.dirent, %struct.dirent* %16, i64 0, i32 0
%18 = load i32, i32* %17
%19 = call i64 @strncmp(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %15
%22 = call i32 @bzero(i8* %3, i32 1024)
%23 = call i32 @strncpy(i8* %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 256)
%24 = load i32, i32* %17
%25 = call i32 @strncat(i8* %3, i32 %24, i32 256)
%26 = call i64 @stat(i8* %3, %struct.stat* %2)
%27 = call i32 @time(i32* null)
%28 = load i32, i32* %11
%29 = sub nsw i32 %27, %28
%30 = icmp sgt i32 %29, 1800
br i1 %30, label %31, label %33
31: ; preds = %21
%32 = call i32 @unlink(i8* %3)
br label %33
33: ; preds = %21, %31, %15
%34 = call %struct.dirent* @readdir(i32* %5)
%35 = icmp eq %struct.dirent* %34, null
br i1 %35, label %36, label %15
36: ; preds = %33, %7
%37 = call i32 @closedir(i32* %5)
ret i32 0
}