#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_nlink;
  scalar_t__ st_size;
  scalar_t__ st_ino;
  scalar_t__ st_dev;
};

/* Variables and functions */
int /*<<< orphan*/ Print_AccessModifyChangeTime(struct stat *);
int /*<<< orphan*/ Print_FileTypeAndPermissions(struct stat *);
int /*<<< orphan*/ Print_UserAndGroup(struct stat *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int stat(char *, struct stat *);
int main(int argc, char *argv[]) {
  struct stat stbuf;
  if (stat(argv[1], &stbuf) == -1) {
    perror(argv[1]);
    return 1;
  }
  printf("Name of file: 5s\n", argv[1]);
  printf("\tDevice: %d\n", (int)stbuf.st_dev);
  printf("\ti_number; %d\n", (int)stbuf.st_ino);
  Print_FileTypeAndPermissions(&stbuf);
  printf("\tLinks: %d\n", stbuf.st_nlink);
  printf("\tFile size: %d\n", (int)stbuf.st_size);
  Print_UserAndGroup(&stbuf);
  Print_AccessModifyChangeTime(&stbuf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
jne    11a9 <main+0x49>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    122e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <Print_FileTypeAndPermissions@plt>
mov    -0x30(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1070 <Print_UserAndGroup@plt>
lea    -0x30(%rbp),%rdi
call   1060 <Print_AccessModifyChangeTime@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
cmp    $0xffffffff,%eax
je     1208 <main+0x98>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
mov    0x20(%rsp),%esi
lea    0xe5d(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <Print_FileTypeAndPermissions@plt>
mov    0x8(%rsp),%esi
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <Print_UserAndGroup@plt>
mov    %rbx,%rdi
call   1070 <Print_AccessModifyChangeTime@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x8(%rbx),%rdi
call   1090 <perror@plt>
mov    $0x1,%ebp
jmp    11ff <main+0x8f>

LLVM IR (-O0):
%struct.stat = type { i32, i64, i64, i64 }
@.str = [18 x i8] c"Name of file: 5s\0A\00"
@.str.1 = [13 x i8] c"\09Device: %d\0A\00"
@.str.2 = [15 x i8] c"\09i_number; %d\0A\00"
@.str.3 = [12 x i8] c"\09Links: %d\0A\00"
@.str.4 = [16 x i8] c"\09File size: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @stat(i8* %9, %struct.stat* %6)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @perror(i8* %15)
store i32 1, i32* %3
br label %40
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 3
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = call i32 @Print_FileTypeAndPermissions(%struct.stat* %6)
%31 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%35 = load i64, i64* %34
%36 = trunc i64 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = call i32 @Print_UserAndGroup(%struct.stat* %6)
%39 = call i32 @Print_AccessModifyChangeTime(%struct.stat* %6)
store i32 0, i32* %3
br label %40
40: ; preds = %17, %12
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.stat = type { i32, i64, i64, i64 }
@.str.1 = [13 x i8] c"\09Device: %d\0A\00"
@.str.2 = [15 x i8] c"\09i_number; %d\0A\00"
@.str.3 = [12 x i8] c"\09Links: %d\0A\00"
@.str.4 = [16 x i8] c"\09File size: %d\0A\00"
@str = [17 x i8] c"Name of file: 5s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i32 @stat(i8* %6, %struct.stat* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = tail call i32 @perror(i8* %10)
br label %32
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 3
%15 = load i64, i64* %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 @Print_FileTypeAndPermissions(%struct.stat* %3)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = call i32 @Print_UserAndGroup(%struct.stat* %3)
%31 = call i32 @Print_AccessModifyChangeTime(%struct.stat* %3)
br label %32
32: ; preds = %12, %9
%33 = phi i32 [ 1, %9 ], [ 0, %12 ]
ret i32 %33
}