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

/* Variables and functions */
int S_IFMT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ lstat(char *, 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 statFile(char *file) {
  struct stat statbuf;
  char timeBuf[50];
  if (lstat(file, &statbuf)) {
    fprintf(stderr, "could not lstat %s: %s\n", file, strerror(errno));
    return 1;
  }
  printf("Filename : %s\n", file);
  printf("On device: major %d/minor %d    Inode number: %ld\n",
         major(statbuf.st_dev), minor(statbuf.st_dev), statbuf.st_ino);
  printf("Size     : %-10ld         Type: %07o       "
         "Permissions: %05o\n",
         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):
<statFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
je     11da <statFile+0x6a>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    %rax,%rcx
lea    0xe37(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b8 <statFile+0x148>
mov    -0x10(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <major@plt>
mov    %eax,-0x80(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <minor@plt>
mov    -0x80(%rbp),%esi
mov    %eax,%edx
mov    -0x14(%rbp),%ecx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    0x2dbe(%rip),%rax
and    (%rax),%edx
mov    -0x34(%rbp),%ecx
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%ecx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1080 <timeString@plt>
mov    %rax,%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1080 <timeString@plt>
mov    %rax,%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1080 <timeString@plt>
mov    %rax,%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<statFile>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1060 <lstat@plt>
test   %rax,%rax
je     11c0 <statFile+0x50>
mov    0x2e47(%rip),%rax
mov    (%rax),%ebp
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe58(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    $0x1,%r14d
jmp    129b <statFile+0x12b>
lea    0xe51(%rip),%rdi
xor    %r14d,%r14d
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%ebx
mov    %ebx,%edi
call   1050 <major@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <minor@plt>
mov    0x2c(%rsp),%ecx
lea    0xe34(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%eax
mov    0x2dd3(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edx
and    %eax,%edx
not    %ecx
and    %eax,%ecx
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%ecx
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%edi
lea    0x30(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <timeString@plt>
lea    0xe86(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edi
mov    %rbx,%rsi
call   1080 <timeString@plt>
lea    0xe7c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edi
mov    %rbx,%rsi
call   1080 <timeString@plt>
lea    0xe72(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"could not lstat %s: %s\0A\00"
@errno = 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 @statFile(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 %15
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 ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13)
store i32 1, i32* %2
br label %61
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 8
%19 = load i32, i32* %18
%20 = call i32 @major(i32 %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 8
%22 = load i32, i32* %21
%23 = call i32 @minor(i32 %22)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 9
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %23, i32 %25)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%30 = load i32, i32* %29
%31 = load i32, i32* @S_IFMT
%32 = and i32 %30, %31
%33 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%34 = load i32, i32* %33
%35 = load i32, i32* @S_IFMT
%36 = xor i32 %35, -1
%37 = and i32 %34, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %32, i32 %37)
%39 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 2
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 3
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 4
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %42, i32 %44)
%46 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 7
%47 = load i32, i32* %46
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%49 = call i8* @timeString(i32 %47, i8* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 6
%52 = load i32, i32* %51
%53 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%54 = call i8* @timeString(i32 %52, i8* %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %54)
%56 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 5
%57 = load i32, i32* %56
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%59 = call i8* @timeString(i32 %57, i8* %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %59)
store i32 0, i32* %2
br label %61
61: ; preds = %15, %9
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [24 x i8] c"could not lstat %s: %s\0A\00"
@errno = 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 @statFile(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 %13, 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 ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %11)
br label %50
13: ; preds = %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 8
%16 = load i32, i32* %15
%17 = tail call i32 @major(i32 %16)
%18 = tail call i32 @minor(i32 %16)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 9
%20 = load i32, i32* %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18, i32 %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%25 = load i32, i32* %24
%26 = load i32, i32* @S_IFMT
%27 = and i32 %26, %25
%28 = xor i32 %26, -1
%29 = and i32 %25, %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %27, i32 %29)
%31 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 3
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 4
%36 = load i32, i32* %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %34, i32 %36)
%38 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 7
%39 = load i32, i32* %38
%40 = call i8* @timeString(i32 %39, i8* %5)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 6
%43 = load i32, i32* %42
%44 = call i8* @timeString(i32 %43, i8* %5)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 5
%47 = load i32, i32* %46
%48 = call i8* @timeString(i32 %47, i8* %5)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %13, %8
%51 = phi i32 [ 1, %8 ], [ 0, %13 ]
ret i32 %51
}