#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_dev;
  int st_ino;
  int st_mode;
  int st_nlink;
  int st_uid;
  int st_gid;
  int st_rdev;
  int st_size;
  int st_atime;
  int st_mtime;
  int st_ctime;
  int st_blksize;
  int st_blocks;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ stat(char const *, struct stat *);
int /*<<< orphan*/ stderr;
void stat_file(const char *filename) {
  struct stat s;
  if (stat(filename, &s) < 0) {
    fprintf(stderr, "%s: Cannot stat\n", filename);
    return;
  }
  printf("device  %i\n", s.st_dev);
  printf("inode   %u\n", s.st_ino);
  printf("mode    %o\n", s.st_mode);
  printf("nlink   %u\n", s.st_nlink);
  printf("uid     %u\n", s.st_uid);
  printf("gid     %u\n", s.st_gid);
  printf("rdev    %i\n", s.st_rdev);
  printf("size    %i\n", s.st_size);
  printf("atime   %u\n", s.st_atime);
  printf("mtime   %u\n", s.st_mtime);
  printf("ctime   %u\n", s.st_ctime);
  printf("blksize %i\n", s.st_blksize);
  printf("blocks  %u\n", s.st_blocks);
  printf("link   \n");
}


x86 assembly (clang, -O0):
<stat_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    1171 <stat_file+0x41>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
jmp    125c <stat_file+0x12c>
mov    -0x40(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stat_file>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
js     1253 <stat_file+0x113>
mov    0x8(%rsp),%esi
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%esi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%esi
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%esi
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
jmp    126b <stat_file+0x12b>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [17 x i8] c"%s: Cannot stat\0A\00"
@.str.1 = [12 x i8] c"device %i\0A\00"
@.str.2 = [12 x i8] c"inode %u\0A\00"
@.str.3 = [12 x i8] c"mode %o\0A\00"
@.str.4 = [12 x i8] c"nlink %u\0A\00"
@.str.5 = [12 x i8] c"uid %u\0A\00"
@.str.6 = [12 x i8] c"gid %u\0A\00"
@.str.7 = [12 x i8] c"rdev %i\0A\00"
@.str.8 = [12 x i8] c"size %i\0A\00"
@.str.9 = [12 x i8] c"atime %u\0A\00"
@.str.10 = [12 x i8] c"mtime %u\0A\00"
@.str.11 = [12 x i8] c"ctime %u\0A\00"
@.str.12 = [12 x i8] c"blksize %i\0A\00"
@.str.13 = [12 x i8] c"blocks %u\0A\00"
@.str.14 = [9 x i8] c"link \0A\00"
define void @stat_file(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @stat(i8* %4, %struct.stat* %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %2
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %52
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 1
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 2
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 3
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 4
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 5
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 6
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 7
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 8
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 9
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 10
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 11
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 12
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
br label %52
52: ; preds = %11, %7
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [17 x i8] c"%s: Cannot stat\0A\00"
@.str.1 = [12 x i8] c"device %i\0A\00"
@.str.2 = [12 x i8] c"inode %u\0A\00"
@.str.3 = [12 x i8] c"mode %o\0A\00"
@.str.4 = [12 x i8] c"nlink %u\0A\00"
@.str.5 = [12 x i8] c"uid %u\0A\00"
@.str.6 = [12 x i8] c"gid %u\0A\00"
@.str.7 = [12 x i8] c"rdev %i\0A\00"
@.str.8 = [12 x i8] c"size %i\0A\00"
@.str.9 = [12 x i8] c"atime %u\0A\00"
@.str.10 = [12 x i8] c"mtime %u\0A\00"
@.str.11 = [12 x i8] c"ctime %u\0A\00"
@.str.12 = [12 x i8] c"blksize %i\0A\00"
@.str.13 = [12 x i8] c"blocks %u\0A\00"
@str = [8 x i8] c"link \00"
define void @stat_file(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @stat(i8* %0, %struct.stat* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %50
9: ; preds = %1
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 2
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 3
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 4
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 5
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 6
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 7
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 8
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 9
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 10
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 11
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 12
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %47)
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %50
50: ; preds = %9, %6
ret void
}