#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_uid;
  int st_mode;
  int /*<<< orphan*/ st_size;
};
struct passwd {
  int /*<<< orphan*/ pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ erreur_grave(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct passwd *getpwuid(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int stat(char *, struct stat *);
int main(int argc, char **argv) {
  struct stat *buffer = (struct stat *)malloc(sizeof(struct stat));
  int r;
  r = stat(argv[1], buffer);
  if (r < 0)
    erreur_grave("Stat");
  struct passwd *passw = getpwuid(buffer->st_uid);
  struct passwd *passwFaux = getpwuid(1000);
  printf("Fichier %s:  mode: %X  Taille: %ld  Proprietaire: %s faux : %s\n ",
         argv[1], buffer->st_mode, buffer->st_size, passw->pw_name,
         passwFaux->pw_name);
  exit(EXIT_SUCCESS);
}


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    $0xc,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ae <main+0x4e>
lea    0xe57(%rip),%rdi
call   1060 <erreur_grave@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x28(%rbp)
mov    $0x3e8,%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x28(%rbp),%rax
mov    (%rax),%r8d
mov    -0x30(%rbp),%rax
mov    (%rax),%r9d
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    $0xc,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
mov    %rax,%rsi
call   1050 <stat@plt>
test   %eax,%eax
jns    1191 <main+0x31>
lea    0xe74(%rip),%rdi
call   1060 <erreur_grave@plt>
mov    (%rbx),%edi
call   1030 <getpwuid@plt>
mov    %rax,%r15
mov    $0x3e8,%edi
call   1030 <getpwuid@plt>
mov    0x8(%r14),%rsi
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%ecx
mov    (%r15),%r8d
mov    (%rax),%r9d
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
%struct.passwd = type { i32 }
@.str = [5 x i8] c"Stat\00"
@.str.1 = [65 x i8] c"Fichier %s: mode: %X Taille: %ld Proprietaire: %s faux : %s\0A \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat*
%7 = alloca i32
%8 = alloca %struct.passwd*
%9 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 @malloc(i32 12)
%11 = inttoptr i64 %10 to %struct.stat*
store %struct.stat* %11, %struct.stat** %6
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = load %struct.stat*, %struct.stat** %6
%16 = call i32 @stat(i8* %14, %struct.stat* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @erreur_grave(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %2
%22 = load %struct.stat*, %struct.stat** %6
%23 = getelementptr inbounds %struct.stat, %struct.stat* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call %struct.passwd* @getpwuid(i32 %24)
store %struct.passwd* %25, %struct.passwd** %8
%26 = call %struct.passwd* @getpwuid(i32 1000)
store %struct.passwd* %26, %struct.passwd** %9
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load %struct.stat*, %struct.stat** %6
%31 = getelementptr inbounds %struct.stat, %struct.stat* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = load %struct.stat*, %struct.stat** %6
%34 = getelementptr inbounds %struct.stat, %struct.stat* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = load %struct.passwd*, %struct.passwd** %8
%37 = getelementptr inbounds %struct.passwd, %struct.passwd* %36, i32 0, i32 0
%38 = load i32, i32* %37
%39 = load %struct.passwd*, %struct.passwd** %9
%40 = getelementptr inbounds %struct.passwd, %struct.passwd* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %32, i32 %35, i32 %38, i32 %41)
%43 = load i32, i32* @EXIT_SUCCESS
%44 = call i32 @exit(i32 %43)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
%struct.passwd = type { i32 }
@.str = [5 x i8] c"Stat\00"
@.str.1 = [65 x i8] c"Fichier %s: mode: %X Taille: %ld Proprietaire: %s faux : %s\0A \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 @malloc(i32 12)
%4 = inttoptr i64 %3 to %struct.stat*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @stat(i8* %6, %struct.stat* %4)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @erreur_grave(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%13 = load i32, i32* %12
%14 = tail call %struct.passwd* @getpwuid(i32 %13)
%15 = tail call %struct.passwd* @getpwuid(i32 1000)
%16 = load i8*, i8** %5
%17 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 2
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %14, i64 0, i32 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 0
%24 = load i32, i32* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %18, i32 %20, i32 %22, i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
%27 = tail call i32 @exit(i32 %26)
unreachable
}