#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 */
scalar_t__ flashfsBufferIsEmpty();
int /*<<< orphan*/ flashfsClearBuffer();
int /*<<< orphan*/ flashfsGetDirtyDataBuffers(int /*<<< orphan*/ const **,
                                              int /*<<< orphan*/ *);
int /*<<< orphan*/ flashfsWriteBuffers(int /*<<< orphan*/ const **,
                                       int /*<<< orphan*/ *, int, int);
void flashfsFlushSync() {
  if (flashfsBufferIsEmpty()) {
    return;
  }
  uint8_t const *buffers[2];
  uint32_t bufferSizes[2];
  flashfsGetDirtyDataBuffers(buffers, bufferSizes);
  flashfsWriteBuffers(buffers, bufferSizes, 2, true);
  flashfsClearBuffer();
}


x86 assembly (clang, -O0):
<flashfsFlushSync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <flashfsBufferIsEmpty@plt>
cmp    $0x0,%rax
je     115e <flashfsFlushSync+0x1e>
jmp    1189 <flashfsFlushSync+0x49>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <flashfsGetDirtyDataBuffers@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x2,%edx
mov    $0x1,%ecx
call   1060 <flashfsWriteBuffers@plt>
mov    $0x0,%al
call   1030 <flashfsClearBuffer@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flashfsFlushSync>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1040 <flashfsBufferIsEmpty@plt>
test   %rax,%rax
jne    1184 <flashfsFlushSync+0x44>
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
mov    $0x1,%ecx
call   1060 <flashfsWriteBuffers@plt>
xor    %eax,%eax
call   1030 <flashfsClearBuffer@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @flashfsFlushSync() {
%1 = alloca [2 x i32*]
%2 = alloca [2 x i32]
%3 = tail call i64 (...) @flashfsBufferIsEmpty()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
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 1)
%12 = call i32 (...) @flashfsClearBuffer()
br label %13
13: ; preds = %0, %5
ret void
}