#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 /*<<< orphan*/ st_ctime;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_ino;
  int /*<<< orphan*/ st_dev;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int stat(char *, struct stat *);
int main() {
  char path;
  struct stat buf;
  if (stat("/home", &buf) == -1) {
    perror("Stat :");
    exit(EXIT_FAILURE);
  }
  printf("Major number is: %u\n and minor: %u\n", major(buf.st_dev),
         minor(buf.st_dev));
  printf("Inode number is: %ld\n", buf.st_ino);
  printf("File type: %u\n", buf.st_mode);
  printf("Time of last modification: %s\n", ctime(&buf.st_mtime));
  printf("Time of last status change: %s\n", ctime(&buf.st_ctime));
  printf("stat done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
jne    11b2 <main+0x42>
lea    0xe67(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%edi
call   1060 <major@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <minor@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
add    $0x4,%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xe73(%rip),%rdi
mov    %rsp,%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
je     1232 <main+0xb2>
mov    0x10(%rsp),%ebx
mov    %ebx,%edi
call   1070 <major@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <minor@plt>
lea    0xe54(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp),%esi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xe5e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xe62(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdcd(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32 }
@.str = [6 x i8] c"/home\00"
@.str.1 = [7 x i8] c"Stat :\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [36 x i8] c"Major number is: %u\0A and minor: %u\0A\00"
@.str.3 = [22 x i8] c"Inode number is: %ld\0A\00"
@.str.4 = [15 x i8] c"File type: %u\0A\00"
@.str.5 = [31 x i8] c"Time of last modification: %s\0A\00"
@.str.6 = [32 x i8] c"Time of last status change: %s\0A\00"
@.str.7 = [11 x i8] c"stat done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca %struct.stat
store i32 0, i32* %1
%4 = call i32 @stat(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 4
%12 = load i32, i32* %11
%13 = call i32 @major(i32 %12)
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 4
%15 = load i32, i32* %14
%16 = call i32 @minor(i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %16)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 3
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%25 = call i8* @ctime(i32* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%28 = call i8* @ctime(i32* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32 }
@.str = [6 x i8] c"/home\00"
@.str.1 = [7 x i8] c"Stat :\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [36 x i8] c"Major number is: %u\0A and minor: %u\0A\00"
@.str.3 = [22 x i8] c"Inode number is: %ld\0A\00"
@.str.4 = [15 x i8] c"File type: %u\0A\00"
@.str.5 = [31 x i8] c"Time of last modification: %s\0A\00"
@.str.6 = [32 x i8] c"Time of last status change: %s\0A\00"
@str = [10 x i8] c"stat done\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = call i32 @stat(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 4
%11 = load i32, i32* %10
%12 = tail call i32 @major(i32 %11)
%13 = tail call i32 @minor(i32 %11)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13)
%15 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%22 = call i8* @ctime(i32* %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%25 = call i8* @ctime(i32* %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
ret i32 0
}