#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;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int stat(char *, struct stat *);
int main(int argc, char **argv) {
  struct stat info;
  int result = stat("code/test_stat.c", &info);
  printf("%d %o\n", result, info.st_mode);
  result = stat("/usr/include/limits.h", &info);
  printf("%d %o\n", result, info.st_mode);
  result = stat("test_stat", &info);
  printf("%d %o\n", result, info.st_mode);
  result = stat("../Make.header", &info);
  printf("%d %o\n", result, info.st_mode);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <stat@plt>
mov    (%rsp),%edx
lea    0xed1(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %r14,%rsi
call   1040 <stat@plt>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    %r14,%rsi
call   1040 <stat@plt>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    %r14,%rsi
call   1040 <stat@plt>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [17 x i8] c"code/test_stat.c\00"
@.str.1 = [7 x i8] c"%d %o\0A\00"
@.str.2 = [22 x i8] c"/usr/include/limits.h\00"
@.str.3 = [10 x i8] c"test_stat\00"
@.str.4 = [15 x i8] c"../Make.header\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @stat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %struct.stat* %6)
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11)
%13 = call i32 @stat(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), %struct.stat* %6)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %16)
%18 = call i32 @stat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %struct.stat* %6)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %21)
%23 = call i32 @stat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %struct.stat* %6)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %26)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [17 x i8] c"code/test_stat.c\00"
@.str.1 = [7 x i8] c"%d %o\0A\00"
@.str.2 = [22 x i8] c"/usr/include/limits.h\00"
@.str.3 = [10 x i8] c"test_stat\00"
@.str.4 = [15 x i8] c"../Make.header\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i32 @stat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
%6 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %7)
%9 = call i32 @stat(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), %struct.stat* %3)
%10 = load i32, i32* %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %10)
%12 = call i32 @stat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %struct.stat* %3)
%13 = load i32, i32* %6
%14 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
%15 = call i32 @stat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %struct.stat* %3)
%16 = load i32, i32* %6
%17 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
ret i32 0
}