#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 st_mode;
  int st_uid;
  int st_gid;
  int st_nlink;
  int /*<<< orphan*/ st_atime;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_ctime;
  scalar_t__ st_size;
  int /*<<< orphan*/ st_dev;
  scalar_t__ st_ino;
};

/* Variables and functions */
int EXIT_FAILURE;
int S_IFMT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
scalar_t__ lstat(char const *, struct stat *);
int major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *timeString(int /*<<< orphan*/, char *);
int fileStats(const char *file) {
  struct stat statbuf;
  char timeBuf[50];
  if (lstat(file, &statbuf)) {
    fprintf(stderr, "Err. lstat() %s: %s\n", file, strerror(errno));
    return (EXIT_FAILURE);
  }
  printf("Filename : %s\n", file);
  printf("On device: major %d/minor %d    Inode number: %ld\n",
         major(statbuf.st_dev), minor(statbuf.st_dev),
         (long int)statbuf.st_ino);
  printf("Size     : %-10ld         Type: %07o       "
         "Permissions: %05o\n",
         (long int)statbuf.st_size, statbuf.st_mode & S_IFMT,
         statbuf.st_mode & ~(S_IFMT));
  printf("Owner    : %d                Group: %d"
         "          Number of links: %d\n",
         statbuf.st_uid, statbuf.st_gid, statbuf.st_nlink);
  printf("Creation time: %s\n", timeString(statbuf.st_ctime, timeBuf));
  printf("Modified time: %s\n", timeString(statbuf.st_mtime, timeBuf));
  printf("Access time  : %s\n", timeString(statbuf.st_atime, timeBuf));
  return 0;
}


x86 assembly (clang, -O0):
<fileStats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
je     11eb <fileStats+0x7b>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rdx
mov    %rax,%rcx
lea    0xe2b(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d1 <fileStats+0x161>
mov    -0x10(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1050 <major@plt>
mov    %eax,-0x90(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <minor@plt>
mov    -0x90(%rbp),%esi
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%edx
mov    0x2da5(%rip),%rax
and    (%rax),%edx
mov    -0x48(%rbp),%ecx
mov    0x2d99(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%ecx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x3c(%rbp),%ecx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%edi
lea    -0x80(%rbp),%rsi
call   1080 <timeString@plt>
mov    %rax,%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%edi
lea    -0x80(%rbp),%rsi
call   1080 <timeString@plt>
mov    %rax,%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%edi
lea    -0x80(%rbp),%rsi
call   1080 <timeString@plt>
mov    %rax,%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fileStats>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1060 <lstat@plt>
test   %rax,%rax
je     11c7 <fileStats+0x57>
mov    0x2e44(%rip),%rax
mov    (%rax),%ebp
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe55(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%r14d
jmp    12a4 <fileStats+0x134>
lea    0xe47(%rip),%rdi
xor    %r14d,%r14d
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%ebx
mov    %ebx,%edi
call   1050 <major@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <minor@plt>
mov    0x38(%rsp),%rcx
lea    0xe29(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%rsi
mov    0x8(%rsp),%eax
mov    0x2dca(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edx
and    %eax,%edx
not    %ecx
and    %eax,%ecx
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <timeString@plt>
lea    0xe7a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edi
mov    %rbx,%rsi
call   1080 <timeString@plt>
lea    0xe70(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edi
mov    %rbx,%rsi
call   1080 <timeString@plt>
lea    0xe66(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i64, i32, i64 }
@stderr = global i32 0
@.str = [21 x i8] c"Err. lstat() %s: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [15 x i8] c"Filename : %s\0A\00"
@.str.2 = [51 x i8] c"On device: major %d/minor %d Inode number: %ld\0A\00"
@.str.3 = [62 x i8] c"Size : %-10ld Type: %07o Permissions: %05o\0A\00"
@S_IFMT = global i32 0
@.str.4 = [69 x i8] c"Owner : %d Group: %d Number of links: %d\0A\00"
@.str.5 = [19 x i8] c"Creation time: %s\0A\00"
@.str.6 = [19 x i8] c"Modified time: %s\0A\00"
@.str.7 = [19 x i8] c"Access time : %s\0A\00"
define i32 @fileStats(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca [50 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @lstat(i8* %6, %struct.stat* %4)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %3
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %2
br label %62
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 8
%20 = load i32, i32* %19
%21 = call i32 @major(i32 %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 8
%23 = load i32, i32* %22
%24 = call i32 @minor(i32 %23)
%25 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 9
%26 = load i64, i64* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %24, i64 %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 7
%29 = load i64, i64* %28
%30 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%31 = load i32, i32* %30
%32 = load i32, i32* @S_IFMT
%33 = and i32 %31, %32
%34 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%35 = load i32, i32* %34
%36 = load i32, i32* @S_IFMT
%37 = xor i32 %36, -1
%38 = and i32 %35, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i64 %29, i32 %33, i32 %38)
%40 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 2
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 3
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %43, i32 %45)
%47 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 6
%48 = load i32, i32* %47
%49 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%50 = call i8* @timeString(i32 %48, i8* %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 5
%53 = load i32, i32* %52
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%55 = call i8* @timeString(i32 %53, i8* %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 4
%58 = load i32, i32* %57
%59 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%60 = call i8* @timeString(i32 %58, i8* %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %60)
store i32 0, i32* %2
br label %62
62: ; preds = %16, %9
%63 = load i32, i32* %2
ret i32 %63
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i64, i32, i64 }
@stderr = global i32 0
@.str = [21 x i8] c"Err. lstat() %s: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [15 x i8] c"Filename : %s\0A\00"
@.str.2 = [51 x i8] c"On device: major %d/minor %d Inode number: %ld\0A\00"
@.str.3 = [62 x i8] c"Size : %-10ld Type: %07o Permissions: %05o\0A\00"
@S_IFMT = global i32 0
@.str.4 = [69 x i8] c"Owner : %d Group: %d Number of links: %d\0A\00"
@.str.5 = [19 x i8] c"Creation time: %s\0A\00"
@.str.6 = [19 x i8] c"Modified time: %s\0A\00"
@.str.7 = [19 x i8] c"Access time : %s\0A\00"
define i32 @fileStats(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca [50 x i8]
%4 = bitcast %struct.stat* %2 to i8*
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = call i64 @lstat(i8* %0, %struct.stat* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
br label %51
14: ; preds = %1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 8
%17 = load i32, i32* %16
%18 = tail call i32 @major(i32 %17)
%19 = tail call i32 @minor(i32 %17)
%20 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 9
%21 = load i64, i64* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19, i64 %21)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 7
%24 = load i64, i64* %23
%25 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%26 = load i32, i32* %25
%27 = load i32, i32* @S_IFMT
%28 = and i32 %27, %26
%29 = xor i32 %27, -1
%30 = and i32 %26, %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i64 %24, i32 %28, i32 %30)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 3
%37 = load i32, i32* %36
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %35, i32 %37)
%39 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 6
%40 = load i32, i32* %39
%41 = call i8* @timeString(i32 %40, i8* %5)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 5
%44 = load i32, i32* %43
%45 = call i8* @timeString(i32 %44, i8* %5)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 4
%48 = load i32, i32* %47
%49 = call i8* @timeString(i32 %48, i8* %5)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %14, %8
%52 = phi i32 [ %13, %8 ], [ 0, %14 ]
ret i32 %52
}