#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ basic_test(int);
int /*<<< orphan*/ cleanup_test();
int /*<<< orphan*/ flush_disk_buffers();
int /*<<< orphan*/ init_test();
scalar_t__ log_read_start(size_t);
int /*<<< orphan*/ phys1_corrupt_and_write_start(size_t, int);
int /*<<< orphan*/ phys2_corrupt_and_write_start(size_t, int);
int /*<<< orphan*/ phys_fill_buffer(size_t);
void dual_error(void) {
  ssize_t n;
  size_t len = 512;
  init_test();
  phys_fill_buffer(len);
  phys1_corrupt_and_write_start(len, 1);
  phys2_corrupt_and_write_start(len, 1);
  flush_disk_buffers();
  n = log_read_start(len);
  basic_test(n <= 0);
  cleanup_test();
}


x86 assembly (clang, -O0):
<dual_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x200,-0x10(%rbp)
mov    $0x0,%al
call   1090 <init_test@plt>
mov    -0x10(%rbp),%rdi
call   1050 <phys_fill_buffer@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <phys1_corrupt_and_write_start@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1080 <phys2_corrupt_and_write_start@plt>
mov    $0x0,%al
call   10a0 <flush_disk_buffers@plt>
mov    -0x10(%rbp),%rdi
call   1060 <log_read_start@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <basic_test@plt>
mov    $0x0,%al
call   1070 <cleanup_test@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dual_error>:
push   %rax
xor    %eax,%eax
call   1090 <init_test@plt>
mov    $0x200,%edi
call   1050 <phys_fill_buffer@plt>
mov    $0x200,%edi
mov    $0x1,%esi
call   1040 <phys1_corrupt_and_write_start@plt>
mov    $0x200,%edi
mov    $0x1,%esi
call   1080 <phys2_corrupt_and_write_start@plt>
xor    %eax,%eax
call   10a0 <flush_disk_buffers@plt>
mov    $0x200,%edi
call   1060 <log_read_start@plt>
xor    %edi,%edi
test   %rax,%rax
setle  %dil
call   1030 <basic_test@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <cleanup_test@plt>

LLVM IR (-O0):
define void @dual_error() {
%1 = alloca i64
%2 = alloca i64
store i64 512, 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_corrupt_and_write_start(i64 %6, i32 1)
%8 = load i64, i64* %2
%9 = call i32 @phys2_corrupt_and_write_start(i64 %8, i32 1)
%10 = call i32 (...) @flush_disk_buffers()
%11 = load i64, i64* %2
%12 = call i64 @log_read_start(i64 %11)
store i64 %12, i64* %1
%13 = load i64, i64* %1
%14 = icmp sle i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @basic_test(i32 %15)
%17 = call i32 (...) @cleanup_test()
ret void
}

LLVM IR (-O2):
define void @dual_error() {
%1 = tail call i32 (...) @init_test()
%2 = tail call i32 @phys_fill_buffer(i64 512)
%3 = tail call i32 @phys1_corrupt_and_write_start(i64 512, i32 1)
%4 = tail call i32 @phys2_corrupt_and_write_start(i64 512, i32 1)
%5 = tail call i32 (...) @flush_disk_buffers()
%6 = tail call i64 @log_read_start(i64 512)
%7 = icmp slt i64 %6, 1
%8 = zext i1 %7 to i32
%9 = tail call i32 @basic_test(i32 %8)
%10 = tail call i32 (...) @cleanup_test()
ret void
}