#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 stat {
  int /*<<< orphan*/ st_atime;
  int /*<<< orphan*/ st_size;
  int /*<<< orphan*/ st_mode;
};
struct FTW {
  int dummy;
};
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
scalar_t__ S_ISREG(int /*<<< orphan*/);
int check_rights(struct stat const *);
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int checkfile(const char *path, const struct stat *buf, int flags,
              struct FTW *ftw) {
  if (S_ISREG(buf->st_mode)) {
    if (check_rights(buf) == 1) {
      off_t size = buf->st_size;
      time_t access = buf->st_atime;
      printf("- Name: %s\n- Size: %lu B\n- Last access: %s\n\n", path, size,
             ctime(&access));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
call   1050 <S_ISREG@plt>
cmp    $0x0,%rax
je     11c3 <checkfile+0x83>
mov    -0x10(%rbp),%rdi
call   1060 <check_rights@plt>
cmp    $0x1,%eax
jne    11be <checkfile+0x7e>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <ctime@plt>
mov    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
jmp    11c3 <checkfile+0x83>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkfile>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x8(%rsi),%edi
call   1050 <S_ISREG@plt>
test   %rax,%rax
je     118e <checkfile+0x4e>
mov    %rbx,%rdi
call   1060 <check_rights@plt>
cmp    $0x1,%eax
jne    118e <checkfile+0x4e>
mov    0x4(%rbx),%ebp
mov    (%rbx),%eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xe7e(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
%struct.FTW = type { i32 }
@.str = [45 x i8] c"- Name: %s\0A- Size: %lu B\0A- Last access: %s\0A\0A\00"
define i32 @checkfile(i8* %0, %struct.stat* %1, i32 %2, %struct.FTW* %3) {
%5 = alloca i8*
%6 = alloca %struct.stat*
%7 = alloca i32
%8 = alloca %struct.FTW*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store %struct.stat* %1, %struct.stat** %6
store i32 %2, i32* %7
store %struct.FTW* %3, %struct.FTW** %8
%11 = load %struct.stat*, %struct.stat** %6
%12 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 2
%13 = load i32, i32* %12
%14 = call i64 @S_ISREG(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %4
%17 = load %struct.stat*, %struct.stat** %6
%18 = call i32 @check_rights(%struct.stat* %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load %struct.stat*, %struct.stat** %6
%22 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 1
%23 = load i32, i32* %22
store i32 %23, i32* %9
%24 = load %struct.stat*, %struct.stat** %6
%25 = getelementptr inbounds %struct.stat, %struct.stat* %24, i32 0, i32 0
%26 = load i32, i32* %25
store i32 %26, i32* %10
%27 = load i8*, i8** %5
%28 = load i32, i32* %9
%29 = call i32 @ctime(i32* %10)
%30 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %28, i32 %29)
br label %31
31: ; preds = %20, %16
br label %32
32: ; preds = %31, %4
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
%struct.FTW = type { i32 }
@.str = [45 x i8] c"- Name: %s\0A- Size: %lu B\0A- Last access: %s\0A\0A\00"
define i32 @checkfile(i8* %0, %struct.stat* %1, i32 %2, %struct.FTW* nocapture readnone %3) {
%5 = alloca i32
%6 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%7 = load i32, i32* %6
%8 = tail call i64 @S_ISREG(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %4
%11 = tail call i32 @check_rights(%struct.stat* %1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%15 = load i32, i32* %14
%16 = bitcast i32* %5 to i8*
%17 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %5
%19 = call i32 @ctime(i32* %5)
%20 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %15, i32 %19)
br label %21
21: ; preds = %10, %13, %4
ret i32 0
}