#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*/ basic_test(int);
int /*<<< orphan*/ cleanup_test();
int cmp_data_log_rd_phys1_wr(size_t);
int /*<<< orphan*/ flush_disk_buffers();
int /*<<< orphan*/ init_test();
int /*<<< orphan*/ log_read_start(size_t);
int /*<<< orphan*/ phys1_write_start(size_t);
int /*<<< orphan*/ phys2_write_start(size_t);
int /*<<< orphan*/ phys_fill_buffer(size_t);
void read_one_page_after_write(void) {
  int rc;
  size_t len = 4096;
  init_test();
  phys_fill_buffer(len);
  phys1_write_start(len);
  phys2_write_start(len);
  flush_disk_buffers();
  log_read_start(len);
  rc = cmp_data_log_rd_phys1_wr(len);
  basic_test(rc == 0);
  cleanup_test();
}


x86 assembly (clang, -O0):
<read_one_page_after_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x1000,-0x10(%rbp)
mov    $0x0,%al
call   10a0 <init_test@plt>
mov    -0x10(%rbp),%rdi
call   1070 <phys_fill_buffer@plt>
mov    -0x10(%rbp),%rdi
call   1030 <phys1_write_start@plt>
mov    -0x10(%rbp),%rdi
call   1060 <phys2_write_start@plt>
mov    $0x0,%al
call   10b0 <flush_disk_buffers@plt>
mov    -0x10(%rbp),%rdi
call   1080 <log_read_start@plt>
mov    -0x10(%rbp),%rdi
call   1050 <cmp_data_log_rd_phys1_wr@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <basic_test@plt>
mov    $0x0,%al
call   1090 <cleanup_test@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_one_page_after_write>:
push   %rax
xor    %eax,%eax
call   10a0 <init_test@plt>
mov    $0x1000,%edi
call   1070 <phys_fill_buffer@plt>
mov    $0x1000,%edi
call   1030 <phys1_write_start@plt>
mov    $0x1000,%edi
call   1060 <phys2_write_start@plt>
xor    %eax,%eax
call   10b0 <flush_disk_buffers@plt>
mov    $0x1000,%edi
call   1080 <log_read_start@plt>
mov    $0x1000,%edi
call   1050 <cmp_data_log_rd_phys1_wr@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <basic_test@plt>
xor    %eax,%eax
pop    %rcx
jmp    1090 <cleanup_test@plt>

LLVM IR (-O0):
define void @read_one_page_after_write() {
%1 = alloca i32
%2 = alloca i64
store i64 4096, i64* %2
%3 = call i32 (...) @init_test()
%4 = load i64, i64* %2
%5 = call i32 @phys_fill_buffer(i64 %4)
%6 = load i64, i64* %2
%7 = call i32 @phys1_write_start(i64 %6)
%8 = load i64, i64* %2
%9 = call i32 @phys2_write_start(i64 %8)
%10 = call i32 (...) @flush_disk_buffers()
%11 = load i64, i64* %2
%12 = call i32 @log_read_start(i64 %11)
%13 = load i64, i64* %2
%14 = call i32 @cmp_data_log_rd_phys1_wr(i64 %13)
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @basic_test(i32 %17)
%19 = call i32 (...) @cleanup_test()
ret void
}

LLVM IR (-O2):
define void @read_one_page_after_write() {
%1 = tail call i32 (...) @init_test()
%2 = tail call i32 @phys_fill_buffer(i64 4096)
%3 = tail call i32 @phys1_write_start(i64 4096)
%4 = tail call i32 @phys2_write_start(i64 4096)
%5 = tail call i32 (...) @flush_disk_buffers()
%6 = tail call i32 @log_read_start(i64 4096)
%7 = tail call i32 @cmp_data_log_rd_phys1_wr(i64 4096)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @basic_test(i32 %9)
%11 = tail call i32 (...) @cleanup_test()
ret void
}