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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int close(int);
int fstat(int, struct stat *);
int ftruncate(int, int /*<<< orphan*/);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int lstat(char *, struct stat *);
int open(char *, int /*<<< orphan*/);
int read(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int rename(char *, char *);
int stat(char *, struct stat *);
int write(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
void dummy_xio(void) {
  int i;
  struct stat tmp;
  i = open("", O_RDONLY);
  i = read(i, NULL, 0);
  i = write(i, NULL, 0);
  i = ftruncate(i, 0);
  i = lseek(i, 0, 0);
  i = fstat(i, &tmp);
  i = lstat("", &tmp);
  i = stat("", &tmp);
  i = rename("", "");
  i = close(i);
}


x86 assembly (clang, -O0):
<dummy_xio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
lea    0xe48(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <read@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1030 <write@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1040 <ftruncate@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <lseek@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   10c0 <fstat@plt>
mov    %eax,-0x4(%rbp)
lea    0xdec(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <lstat@plt>
mov    %eax,-0x4(%rbp)
lea    0xdd9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <stat@plt>
mov    %eax,-0x4(%rbp)
lea    0xdc6(%rip),%rsi
mov    %rsi,%rdi
call   10b0 <rename@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
mov    %eax,-0x4(%rbp)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dummy_xio>:
push   %r14
push   %rbx
push   %rax
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
lea    0xe4c(%rip),%r14
mov    %r14,%rdi
call   10a0 <open@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <read@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <write@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <ftruncate@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   10c0 <fstat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <lstat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <stat@plt>
mov    %r14,%rdi
mov    %r14,%rsi
call   10b0 <rename@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <close@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@O_RDONLY = global i32 0
define void @dummy_xio() {
%1 = alloca i32
%2 = alloca %struct.stat
%3 = load i32, i32* @O_RDONLY
%4 = call i32 @open(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = call i32 @read(i32 %5, i32* null, i32 0)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @write(i32 %7, i32* null, i32 0)
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = call i32 @ftruncate(i32 %9, i32 0)
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = call i32 @lseek(i32 %11, i32 0, i32 0)
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = call i32 @fstat(i32 %13, %struct.stat* %2)
store i32 %14, i32* %1
%15 = call i32 @lstat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %struct.stat* %2)
store i32 %15, i32* %1
%16 = call i32 @stat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %struct.stat* %2)
store i32 %16, i32* %1
%17 = call i32 @rename(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = call i32 @close(i32 %18)
store i32 %19, i32* %1
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [1 x i8] zeroinitializer
@O_RDONLY = global i32 0
define void @dummy_xio() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @read(i32 %4, i32* null, i32 0)
%6 = tail call i32 @write(i32 %5, i32* null, i32 0)
%7 = tail call i32 @ftruncate(i32 %6, i32 0)
%8 = tail call i32 @lseek(i32 %7, i32 0, i32 0)
%9 = call i32 @fstat(i32 %8, %struct.stat* %1)
%10 = call i32 @lstat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%11 = call i32 @stat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%12 = tail call i32 @rename(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @close(i32 %12)
ret void
}