#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 */

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int virt_close(int);
int virt_open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int virt_write(int, char *, int);
int flush_cache() {
  int res;
  int fd;
  fd = virt_open("/#avfsstat/cache/clear", O_WRONLY, 0);
  if (fd == -1)
    return -1;
  res = virt_write(fd, "1", 1);
  if (res == -1)
    return -1;
  res = virt_close(fd);
  if (res == -1)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<flush_cache>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdi
xor    %edx,%edx
call   1040 <virt_open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1168 <flush_cache+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <flush_cache+0x8d>
mov    -0xc(%rbp),%edi
lea    0xea5(%rip),%rsi
mov    $0x1,%edx
call   1030 <virt_write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1195 <flush_cache+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <flush_cache+0x8d>
mov    -0xc(%rbp),%edi
call   1050 <virt_close@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11b6 <flush_cache+0x86>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <flush_cache+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flush_cache>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
lea    0xebd(%rip),%rdi
xor    %edx,%edx
call   1040 <virt_open@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     117f <flush_cache+0x4f>
mov    %eax,%ebp
lea    0xeba(%rip),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1030 <virt_write@plt>
cmp    $0xffffffff,%eax
je     117f <flush_cache+0x4f>
mov    %ebp,%edi
call   1050 <virt_close@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
neg    %ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"/#avfsstat/cache/clear\00"
@O_WRONLY = global i32 0
@.str.1 = [2 x i8] c"1\00"
define i32 @flush_cache() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @O_WRONLY
%5 = call i32 @virt_open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %22
9: ; preds = %0
%10 = load i32, i32* %3
%11 = call i32 @virt_write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 -1, i32* %1
br label %22
15: ; preds = %9
%16 = load i32, i32* %3
%17 = call i32 @virt_close(i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %1
br label %22
21: ; preds = %15
store i32 0, i32* %1
br label %22
22: ; preds = %21, %20, %14, %8
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [23 x i8] c"/#avfsstat/cache/clear\00"
@O_WRONLY = global i32 0
@.str.1 = [2 x i8] c"1\00"
define i32 @flush_cache() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 @virt_open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %1, i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %11, label %4
4: ; preds = %0
%5 = tail call i32 @virt_write(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @virt_close(i32 %2)
%9 = icmp eq i32 %8, -1
%10 = sext i1 %9 to i32
br label %11
11: ; preds = %7, %4, %0
%12 = phi i32 [ -1, %0 ], [ -1, %4 ], [ %10, %7 ]
ret i32 %12
}