#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 {
  scalar_t__ st_dev;
  scalar_t__ st_ino;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int fflush(int /*<<< orphan*/ *);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int fstat(int, struct stat *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ malloc(int);
int /*<<< orphan*/ malloc_info(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ malloc_stats();
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ *tmpfile();
char *tmpnam(int /*<<< orphan*/ *);
int main(void) {
  malloc(123);
  fprintf(stderr, "malloc_stats():\n");
  malloc_stats();
  fprintf(stderr, "\nmalloc_info():\n");
  malloc_info(0, stdout);
  {
    FILE *fp;
    char buf[256];
    struct stat st;
    putenv("TMPDIR=/tmp/fullfs/tmp/");
    printf("%s\n", tmpnam(NULL));
    fp = tmpfile();
    printf("%p\n", fp);
    printf("%d\n", fstat(fileno(fp), &st));
    printf("ino %ld dev %ld\n", (long)st.st_ino, (long)st.st_dev);
    printf("%d\n", fwrite("hello", 1, 2048, fp));
    printf("%d\n", fflush(fp));
    rewind(fp);
    printf("%d\n", fread(buf, 1, 5, fp));
  }
  {
    int fd;
    struct stat st;
    fd = open("/tmp/fullfs/yes", O_RDONLY);
    printf("%d\n", fstat(fd, &st));
    printf("ino %ld dev %ld\n", (long)st.st_ino, (long)st.st_dev);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x7b,%edi
call   10b0 <malloc@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10d0 <malloc_stats@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1030 <malloc_info@plt>
lea    0xdce(%rip),%rdi
call   1070 <putenv@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1100 <tmpnam@plt>
mov    %rax,%rsi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <tmpfile@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <fileno@plt>
mov    %eax,%edi
lea    -0x120(%rbp),%rsi
call   1110 <fstat@plt>
mov    %eax,%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x118(%rbp),%rsi
mov    -0x120(%rbp),%rdx
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rcx
lea    0xd79(%rip),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
call   10f0 <fwrite@plt>
mov    %eax,%esi
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <fflush@plt>
mov    %eax,%esi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x5,%edx
call   1040 <fread@plt>
mov    %eax,%esi
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%esi
lea    0xd04(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%edi
lea    -0x138(%rbp),%rsi
call   1110 <fstat@plt>
mov    %eax,%esi
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x130(%rbp),%rsi
mov    -0x138(%rbp),%rdx
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    $0x7b,%edi
call   10c0 <malloc@plt>
mov    0x2dbb(%rip),%rbx
mov    (%rbx),%edi
lea    0xdda(%rip),%rsi
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   10e0 <malloc_stats@plt>
mov    (%rbx),%edi
lea    0xdd6(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1030 <malloc_info@plt>
lea    0xdcb(%rip),%rdi
call   1080 <putenv@plt>
xor    %edi,%edi
call   1110 <tmpnam@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <tmpfile@plt>
mov    %rax,%rbx
lea    0xdbe(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10b0 <fileno@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1120 <fstat@plt>
lea    0xd9f(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp),%rdx
mov    0x8(%rsp),%rsi
lea    0xd87(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    %rbx,%rcx
call   1100 <fwrite@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10d0 <fflush@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <rewind@plt>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2cb8(%rip),%rax
mov    (%rax),%esi
lea    0xd20(%rip),%rdi
call   10f0 <open@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   1120 <fstat@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@stderr = global i32 0
@.str = [17 x i8] c"malloc_stats():\0A\00"
@.str.1 = [17 x i8] c"\0Amalloc_info():\0A\00"
@stdout = global i32 0
@.str.2 = [24 x i8] c"TMPDIR=/tmp/fullfs/tmp/\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c"%p\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [17 x i8] c"ino %ld dev %ld\0A\00"
@.str.7 = [6 x i8] c"hello\00"
@.str.8 = [16 x i8] c"/tmp/fullfs/yes\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca %struct.stat
store i32 0, i32* %1
%7 = call i32 @malloc(i32 123)
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @malloc_stats()
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = call i32 @malloc_info(i32 0, i32 %13)
%15 = call i32 @putenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%16 = call i8* @tmpnam(i32* null)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = call i32* (...) @tmpfile()
store i32* %18, i32** %2
%19 = load i32*, i32** %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %19)
%21 = load i32*, i32** %2
%22 = call i32 @fileno(i32* %21)
%23 = call i32 @fstat(i32 %22, %struct.stat* %4)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%28 = load i64, i64* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i64 %26, i64 %28)
%30 = load i32*, i32** %2
%31 = call i32 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 1, i32 2048, i32* %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = load i32*, i32** %2
%34 = call i32 @fflush(i32* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = load i32*, i32** %2
%37 = call i32 @rewind(i32* %36)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%39 = load i32*, i32** %2
%40 = call i32 @fread(i8* %38, i32 1, i32 5, i32* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @O_RDONLY
%43 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %42)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = call i32 @fstat(i32 %44, %struct.stat* %6)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%48 = load i64, i64* %47
%49 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%50 = load i64, i64* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i64 %48, i64 %50)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@stderr = global i32 0
@.str = [17 x i8] c"malloc_stats():\0A\00"
@.str.1 = [17 x i8] c"\0Amalloc_info():\0A\00"
@stdout = global i32 0
@.str.2 = [24 x i8] c"TMPDIR=/tmp/fullfs/tmp/\00"
@.str.4 = [4 x i8] c"%p\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [17 x i8] c"ino %ld dev %ld\0A\00"
@.str.7 = [6 x i8] c"hello\00"
@.str.8 = [16 x i8] c"/tmp/fullfs/yes\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca %struct.stat
%3 = alloca %struct.stat
%4 = tail call i32 @malloc(i32 123)
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @malloc_stats()
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = tail call i32 @malloc_info(i32 0, i32 %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%13 = bitcast %struct.stat* %2 to i8*
%14 = tail call i32 @putenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i8* @tmpnam(i32* null)
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
%17 = tail call i32* (...) @tmpfile()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %17)
%19 = tail call i32 @fileno(i32* %17)
%20 = call i32 @fstat(i32 %19, %struct.stat* %2)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%23 = load i64, i64* %22
%24 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%25 = load i64, i64* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i64 %23, i64 %25)
%27 = tail call i32 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 1, i32 2048, i32* %17)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = tail call i32 @fflush(i32* %17)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = tail call i32 @rewind(i32* %17)
%32 = call i32 @fread(i8* %12, i32 1, i32 5, i32* %17)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = bitcast %struct.stat* %3 to i8*
%35 = load i32, i32* @O_RDONLY
%36 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %35)
%37 = call i32 @fstat(i32 %36, %struct.stat* %3)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%40 = load i64, i64* %39
%41 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%42 = load i64, i64* %41
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i64 %40, i64 %42)
ret i32 0
}