#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_crc_log_wr_phys1_rd(size_t);
int cmp_crc_log_wr_phys2_rd(size_t);
int /*<<< orphan*/ flush_disk_buffers();
int /*<<< orphan*/ init_test();
int /*<<< orphan*/ log_fill_buffer(size_t);
int /*<<< orphan*/ log_write_start(size_t);
int /*<<< orphan*/ phys1_read_start(size_t);
int /*<<< orphan*/ phys2_read_start(size_t);
void write_two_pages_check_phys_crc(void) {
  int rc1, rc2;
  size_t len = 8192;
  init_test();
  log_fill_buffer(len);
  log_write_start(len);
  flush_disk_buffers();
  phys1_read_start(len);
  phys2_read_start(len);
  rc1 = cmp_crc_log_wr_phys1_rd(len);
  rc2 = cmp_crc_log_wr_phys2_rd(len);
  basic_test(rc1 == 0 && rc2 == 0);
  cleanup_test();
}


x86 assembly (clang, -O0):
<write_two_pages_check_phys_crc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x2000,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <init_test@plt>
mov    -0x10(%rbp),%rdi
call   1040 <log_fill_buffer@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <log_write_start@plt>
mov    $0x0,%al
call   10c0 <flush_disk_buffers@plt>
mov    -0x10(%rbp),%rdi
call   1030 <phys1_read_start@plt>
mov    -0x10(%rbp),%rdi
call   1070 <phys2_read_start@plt>
mov    -0x10(%rbp),%rdi
call   1080 <cmp_crc_log_wr_phys1_rd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <cmp_crc_log_wr_phys2_rd@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x11(%rbp)
jne    1213 <write_two_pages_check_phys_crc+0x73>
cmpl   $0x0,-0x8(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <basic_test@plt>
mov    $0x0,%al
call   1090 <cleanup_test@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_two_pages_check_phys_crc>:
push   %rbx
xor    %eax,%eax
call   10b0 <init_test@plt>
mov    $0x2000,%edi
call   1040 <log_fill_buffer@plt>
mov    $0x2000,%edi
call   10a0 <log_write_start@plt>
xor    %eax,%eax
call   10c0 <flush_disk_buffers@plt>
mov    $0x2000,%edi
call   1030 <phys1_read_start@plt>
mov    $0x2000,%edi
call   1070 <phys2_read_start@plt>
mov    $0x2000,%edi
call   1080 <cmp_crc_log_wr_phys1_rd@plt>
mov    %eax,%ebx
mov    $0x2000,%edi
call   1060 <cmp_crc_log_wr_phys2_rd@plt>
xor    %edi,%edi
or     %ebx,%eax
sete   %dil
call   1050 <basic_test@plt>
xor    %eax,%eax
pop    %rbx
jmp    1090 <cleanup_test@plt>

LLVM IR (-O0):
define void @write_two_pages_check_phys_crc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i64 8192, i64* %3
%4 = call i32 (...) @init_test()
%5 = load i64, i64* %3
%6 = call i32 @log_fill_buffer(i64 %5)
%7 = load i64, i64* %3
%8 = call i32 @log_write_start(i64 %7)
%9 = call i32 (...) @flush_disk_buffers()
%10 = load i64, i64* %3
%11 = call i32 @phys1_read_start(i64 %10)
%12 = load i64, i64* %3
%13 = call i32 @phys2_read_start(i64 %12)
%14 = load i64, i64* %3
%15 = call i32 @cmp_crc_log_wr_phys1_rd(i64 %14)
store i32 %15, i32* %1
%16 = load i64, i64* %3
%17 = call i32 @cmp_crc_log_wr_phys2_rd(i64 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 0
br label %23
23: ; preds = %20, %0
%24 = phi i1 [ false, %0 ], [ %22, %20 ]
%25 = zext i1 %24 to i32
%26 = call i32 @basic_test(i32 %25)
%27 = call i32 (...) @cleanup_test()
ret void
}

LLVM IR (-O2):
define void @write_two_pages_check_phys_crc() {
%1 = tail call i32 (...) @init_test()
%2 = tail call i32 @log_fill_buffer(i64 8192)
%3 = tail call i32 @log_write_start(i64 8192)
%4 = tail call i32 (...) @flush_disk_buffers()
%5 = tail call i32 @phys1_read_start(i64 8192)
%6 = tail call i32 @phys2_read_start(i64 8192)
%7 = tail call i32 @cmp_crc_log_wr_phys1_rd(i64 8192)
%8 = tail call i32 @cmp_crc_log_wr_phys2_rd(i64 8192)
%9 = icmp eq i32 %7, 0
%10 = icmp eq i32 %8, 0
%11 = select i1 %9, i1 %10, i1 false
%12 = zext i1 %11 to i32
%13 = tail call i32 @basic_test(i32 %12)
%14 = tail call i32 (...) @cleanup_test()
ret void
}