#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_size;
  int st_atime;
  int st_mtime;
  int st_ctime;
};

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int stat(char *, struct stat *);
int main() {
  struct stat st;
  int r = stat("test.txt", &st);
  if (r) {
    perror("stat error.\n");
    return -1;
  }
  printf("st_dev=%lld\n", st.st_dev);
  printf("st_ino=%ld\n", st.st_ino);
  printf("st_mode=%d\n", st.st_mode);
  printf("st_nlink=%d\n", st.st_nlink);
  printf("st_uid=%d\n", st.st_uid);
  printf("st_gid=%d\n", st.st_gid);
  printf("st_size=%ld\n", st.st_size);
  printf("st_atime=%ld\n", st.st_atime);
  printf("st_mtime=%ld\n", st.st_mtime);
  printf("st_ctime=%ld\n", st.st_ctime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1174 <main+0x44>
lea    0xea6(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <main+0xe1>
mov    -0x30(%rbp),%esi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xec5(%rip),%rdi
mov    %rsp,%rsi
call   1040 <stat@plt>
test   %eax,%eax
jne    11f1 <main+0xc1>
mov    (%rsp),%esi
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xe11(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [13 x i8] c"stat error.\0A\00"
@.str.2 = [13 x i8] c"st_dev=%lld\0A\00"
@.str.3 = [12 x i8] c"st_ino=%ld\0A\00"
@.str.4 = [12 x i8] c"st_mode=%d\0A\00"
@.str.5 = [13 x i8] c"st_nlink=%d\0A\00"
@.str.6 = [11 x i8] c"st_uid=%d\0A\00"
@.str.7 = [11 x i8] c"st_gid=%d\0A\00"
@.str.8 = [13 x i8] c"st_size=%ld\0A\00"
@.str.9 = [14 x i8] c"st_atime=%ld\0A\00"
@.str.10 = [14 x i8] c"st_mtime=%ld\0A\00"
@.str.11 = [14 x i8] c"st_ctime=%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stat
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @stat(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.stat* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %40
9: ; preds = %0
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 1
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 2
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 3
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 4
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 5
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 6
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 7
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 8
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 9
%38 = load i32, i32* %37
%39 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i32 %38)
store i32 0, i32* %1
br label %40
40: ; preds = %9, %7
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [13 x i8] c"stat error.\0A\00"
@.str.2 = [13 x i8] c"st_dev=%lld\0A\00"
@.str.3 = [12 x i8] c"st_ino=%ld\0A\00"
@.str.4 = [12 x i8] c"st_mode=%d\0A\00"
@.str.5 = [13 x i8] c"st_nlink=%d\0A\00"
@.str.6 = [11 x i8] c"st_uid=%d\0A\00"
@.str.7 = [11 x i8] c"st_gid=%d\0A\00"
@.str.8 = [13 x i8] c"st_size=%ld\0A\00"
@.str.9 = [14 x i8] c"st_atime=%ld\0A\00"
@.str.10 = [14 x i8] c"st_mtime=%ld\0A\00"
@.str.11 = [14 x i8] c"st_ctime=%ld\0A\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = call i32 @stat(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %38
7: ; preds = %0
%8 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%12 = load i32, i32* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%15 = load i32, i32* %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%18 = load i32, i32* %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 4
%21 = load i32, i32* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 5
%24 = load i32, i32* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 6
%27 = load i32, i32* %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 7
%30 = load i32, i32* %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 8
%33 = load i32, i32* %32
%34 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 9
%36 = load i32, i32* %35
%37 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %7, %5
%39 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %39
}