#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ flashfsAdvanceTailInBuffer(int /*<<< orphan*/);
int flashfsBufferIsEmpty();
int /*<<< orphan*/ flashfsGetDirtyDataBuffers(int /*<<< orphan*/ const **,
                                              int /*<<< orphan*/ *);
int /*<<< orphan*/ flashfsWriteBuffers(int /*<<< orphan*/ const **,
                                       int /*<<< orphan*/ *, int, int);
bool flashfsFlushAsync(void) {
  if (flashfsBufferIsEmpty()) {
    return true;
  }
  uint8_t const *buffers[2];
  uint32_t bufferSizes[2];
  uint32_t bytesWritten;
  flashfsGetDirtyDataBuffers(buffers, bufferSizes);
  bytesWritten = flashfsWriteBuffers(buffers, bufferSizes, 2, false);
  flashfsAdvanceTailInBuffer(bytesWritten);
  return flashfsBufferIsEmpty();
}


x86 assembly (clang, -O0):
<flashfsFlushAsync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <flashfsBufferIsEmpty@plt>
cmp    $0x0,%eax
je     1164 <flashfsFlushAsync+0x24>
movl   $0x1,-0x4(%rbp)
jmp    119a <flashfsFlushAsync+0x5a>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <flashfsGetDirtyDataBuffers@plt>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1060 <flashfsWriteBuffers@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <flashfsAdvanceTailInBuffer@plt>
mov    $0x0,%al
call   1030 <flashfsBufferIsEmpty@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flashfsFlushAsync>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1030 <flashfsBufferIsEmpty@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    118e <flashfsFlushAsync+0x4e>
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <flashfsGetDirtyDataBuffers@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1060 <flashfsWriteBuffers@plt>
mov    %eax,%edi
call   1040 <flashfsAdvanceTailInBuffer@plt>
xor    %eax,%eax
call   1030 <flashfsBufferIsEmpty@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @flashfsFlushAsync() {
%1 = alloca i32
%2 = alloca [2 x i32*]
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = call i32 (...) @flashfsBufferIsEmpty()
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 1, i32* %1
br label %18
8: ; preds = %0
%9 = getelementptr inbounds [2 x i32*], [2 x i32*]* %2, i64 0, i64 0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%11 = call i32 @flashfsGetDirtyDataBuffers(i32** %9, i32* %10)
%12 = getelementptr inbounds [2 x i32*], [2 x i32*]* %2, i64 0, i64 0
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%14 = call i32 @flashfsWriteBuffers(i32** %12, i32* %13, i32 2, i32 0)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = call i32 @flashfsAdvanceTailInBuffer(i32 %15)
%17 = call i32 (...) @flashfsBufferIsEmpty()
store i32 %17, i32* %1
br label %18
18: ; preds = %8, %7
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
define i32 @flashfsFlushAsync() {
%1 = alloca [2 x i32*]
%2 = alloca [2 x i32]
%3 = tail call i32 (...) @flashfsBufferIsEmpty()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %0
%6 = bitcast [2 x i32*]* %1 to i8*
%7 = bitcast [2 x i32]* %2 to i8*
%8 = getelementptr inbounds [2 x i32*], [2 x i32*]* %1, i64 0, i64 0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%10 = call i32 @flashfsGetDirtyDataBuffers(i32** %8, i32* %9)
%11 = call i32 @flashfsWriteBuffers(i32** %8, i32* %9, i32 2, i32 0)
%12 = call i32 @flashfsAdvanceTailInBuffer(i32 %11)
%13 = call i32 (...) @flashfsBufferIsEmpty()
br label %14
14: ; preds = %0, %5
%15 = phi i32 [ %13, %5 ], [ 1, %0 ]
ret i32 %15
}