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

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ lstat(char *, struct stat *);
char *malloc(int);
int /*<<< orphan*/ mode_format(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  char *path = malloc(256);
  getcwd(path, 256);
  int l = 0, a = 0;
  if (argc == 2) {
    if (argv[1][0] != '-')
      path = argv[1];
    else {
      if (strchr(argv[1], 'l') != 0)
        l = 1;
      if (strchr(argv[1], 'a') != 0)
        a = 1;
    }
  } else if (argc == 3) {
    path = argv[2];
    if (strchr(argv[1], 'l'))
      l = 1;
    if (strchr(argv[1], 'a'))
      a = 1;
  }
  DIR *dir;
  if (!(dir = opendir(path))) {
    printf("open dictionary failed!\n");
    exit(0);
  }
  struct dirent *rddir;
  while (rddir = readdir(dir)) {
    if ((rddir->d_name)[0] == '.' && !a)
      continue;
    if (!l)
      printf("%s\t", rddir->d_name);
    else {
      struct stat state;
      lstat(rddir->d_name, &state);
      char *change_time = malloc(4096);
      strftime(change_time, 4096, "%F %H", localtime(&(state.st_mtime)));
      char *buf = malloc(11);
      mode_format(state.st_mode, buf);
      printf("%s\t%s\t%ld\t", buf, change_time, state.st_size);
      printf("%s \n", rddir->d_name);
    }
  }
  printf("\n");
  closedir(dir);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x100,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x100,%esi
call   1080 <getcwd@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    127f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     122f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    127a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x6c,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     1252 <main+0x92>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x61,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     1275 <main+0xb5>
movl   $0x1,-0x20(%rbp)
jmp    127a <main+0xba>
jmp    12e5 <main+0x125>
cmpl   $0x3,-0x8(%rbp)
jne    12e0 <main+0x120>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x6c,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     12b8 <main+0xf8>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x61,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     12db <main+0x11b>
movl   $0x1,-0x20(%rbp)
jmp    12e0 <main+0x120>
jmp    12e5 <main+0x125>
mov    -0x18(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1311 <main+0x151>
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    1316 <main+0x156>
mov    -0x28(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     140a <main+0x24a>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    134f <main+0x18f>
cmpl   $0x0,-0x20(%rbp)
jne    134f <main+0x18f>
jmp    1316 <main+0x156>
cmpl   $0x0,-0x1c(%rbp)
jne    1373 <main+0x1b3>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1405 <main+0x245>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
call   10a0 <lstat@plt>
mov    $0x1000,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
add    $0x8,%rdi
call   1030 <localtime@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%ecx
mov    $0x1000,%esi
lea    0xc65(%rip),%rdx
call   10d0 <strftime@plt>
mov    $0xb,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x50(%rbp),%rsi
call   1050 <mode_format@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%ecx
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rsi
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1316 <main+0x156>
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1090 <closedir@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0x100,%edi
call   10e0 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x100,%esi
call   10a0 <getcwd@plt>
cmp    $0x3,%ebx
je     122a <main+0x4a>
cmp    $0x2,%ebx
jne    125e <main+0x7e>
mov    0x8(%rbp),%rdi
cmpb   $0x2d,(%rdi)
je     1232 <main+0x52>
xor    %ebp,%ebp
xor    %r14d,%r14d
mov    %rdi,%r15
jmp    1263 <main+0x83>
mov    0x8(%rbp),%rdi
mov    0x10(%rbp),%r15
add    $0x8,%rbp
mov    $0x6c,%esi
call   1080 <strchr@plt>
test   %rax,%rax
setne  %r14b
mov    0x0(%rbp),%rdi
mov    $0x61,%esi
call   1080 <strchr@plt>
test   %rax,%rax
setne  %bpl
jmp    1263 <main+0x83>
xor    %ebp,%ebp
xor    %r14d,%r14d
mov    %r15,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     136f <main+0x18f>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     134c <main+0x16c>
mov    %rax,%r15
not    %bpl
jmp    132c <main+0x14c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rsi,%rdi
lea    0x8(%rsp),%rsi
call   10c0 <lstat@plt>
mov    $0x1000,%edi
call   10e0 <malloc@plt>
mov    %rax,%r12
lea    0x10(%rsp),%rdi
call   1040 <localtime@plt>
mov    %r12,%rdi
mov    $0x1000,%esi
lea    0xd31(%rip),%rdx
mov    %eax,%ecx
call   10f0 <strftime@plt>
mov    $0xb,%edi
call   10e0 <malloc@plt>
mov    %rax,%r13
mov    0xc(%rsp),%edi
mov    %rax,%rsi
call   1070 <mode_format@plt>
mov    0x8(%rsp),%ecx
lea    0xd0c(%rip),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%r15),%rsi
lea    0xd00(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
je     134c <main+0x16c>
mov    (%r15),%rsi
cmpb   $0x2e,(%rsi)
sete   %al
test   %al,%bpl
jne    131c <main+0x13c>
test   %r14b,%r14b
jne    12a0 <main+0xc0>
lea    0xcb6(%rip),%rdi
jmp    1315 <main+0x135>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   10b0 <closedir@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xca4(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1100 <exit@plt>

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

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
%struct.dirent = type { i8* }
@.str.1 = [4 x i8] c"%s\09\00"
@.str.2 = [6 x i8] c"%F %H\00"
@.str.3 = [11 x i8] c"%s\09%s\09%ld\09\00"
@.str.4 = [5 x i8] c"%s \0A\00"
@str = [24 x i8] c"open dictionary failed!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%5 = tail call i32 @getcwd(i8* %4, i32 256)
switch i32 %0, label %27 [
i32 2, label %6
i32 3, label %13
]
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %27
11: ; preds = %6
%12 = tail call i64 @strchr(i8* %8, i8 signext 108)
br label %19
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i64 @strchr(i8* %17, i8 signext 108)
br label %19
19: ; preds = %11, %13
%20 = phi i64 [ %18, %13 ], [ %12, %11 ]
%21 = phi i8** [ %16, %13 ], [ %7, %11 ]
%22 = phi i8* [ %15, %13 ], [ %4, %11 ]
%23 = icmp ne i64 %20, 0
%24 = load i8*, i8** %21
%25 = tail call i64 @strchr(i8* %24, i8 signext 97)
%26 = icmp ne i64 %25, 0
br label %27
27: ; preds = %19, %2, %6
%28 = phi i1 [ false, %6 ], [ false, %2 ], [ %26, %19 ]
%29 = phi i1 [ false, %6 ], [ false, %2 ], [ %23, %19 ]
%30 = phi i8* [ %8, %6 ], [ %4, %2 ], [ %22, %19 ]
%31 = tail call i32* @opendir(i8* %30)
%32 = icmp eq i32* %31, null
br i1 %32, label %41, label %33
33: ; preds = %27
%34 = call %struct.dirent* @readdir(i32* %31)
%35 = icmp eq %struct.dirent* %34, null
br i1 %35, label %69, label %36
36: ; preds = %33
%37 = bitcast %struct.stat* %3 to i8*
%38 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%39 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%40 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
br label %44
41: ; preds = %27
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%43 = tail call i32 @exit(i32 0)
unreachable
44: ; preds = %36, %66
%45 = phi %struct.dirent* [ %34, %36 ], [ %67, %66 ]
%46 = getelementptr inbounds %struct.dirent, %struct.dirent* %45, i64 0, i32 0
%47 = load i8*, i8** %46
%48 = load i8, i8* %47
%49 = icmp ne i8 %48, 46
%50 = or i1 %28, %49
br i1 %50, label %51, label %66
51: ; preds = %44
br i1 %29, label %54, label %52
52: ; preds = %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %47)
br label %66
54: ; preds = %51
%55 = call i32 @lstat(i8* %47, %struct.stat* %3)
%56 = call dereferenceable_or_null(4096) i8* @malloc(i32 4096)
%57 = call i32 @localtime(i32* %38)
%58 = call i32 @strftime(i8* %56, i32 4096, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = call dereferenceable_or_null(11) i8* @malloc(i32 11)
%60 = load i32, i32* %39
%61 = call i32 @mode_format(i32 %60, i8* %59)
%62 = load i32, i32* %40
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %59, i8* %56, i32 %62)
%64 = load i8*, i8** %46
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %64)
br label %66
66: ; preds = %52, %54, %44
%67 = call %struct.dirent* @readdir(i32* %31)
%68 = icmp eq %struct.dirent* %67, null
br i1 %68, label %69, label %44
69: ; preds = %66, %33
%70 = call i32 @putchar(i32 10)
%71 = call i32 @closedir(i32* %31)
ret i32 0
}