#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*/ block_read(unsigned int, unsigned char *);
int /*<<< orphan*/ block_write(unsigned int, unsigned char *);
int /*<<< orphan*/ data_check(unsigned char *, unsigned char *);
int /*<<< orphan*/ data_fill(unsigned char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void test_alternate(unsigned blocknum) {
  unsigned char data[1024];
  unsigned char rdata[1024];
  printf("Testing block %u at address %06X.\n", blocknum, blocknum * 1024);
  data_fill(data, 0x55, 0xAA);
  block_write(blocknum, data);
  block_read(blocknum, rdata);
  data_check(data, rdata);
  data_fill(data, 0xAA, 0x55);
  block_write(blocknum, data);
  block_read(blocknum, rdata);
  data_check(data, rdata);
  printf("Done.\n");
}


x86 assembly (clang, -O0):
<test_alternate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
shl    $0xa,%edx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x55,%esi
mov    $0xaa,%edx
call   1030 <data_fill@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1060 <block_write@plt>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
call   1070 <block_read@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1040 <data_check@plt>
lea    -0x410(%rbp),%rdi
mov    $0xaa,%esi
mov    $0x55,%edx
call   1030 <data_fill@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1060 <block_write@plt>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
call   1070 <block_read@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1040 <data_check@plt>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_alternate>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %edi,%ebx
mov    %edi,%edx
shl    $0xa,%edx
lea    0xe86(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    $0x55,%esi
mov    $0xaa,%edx
call   1030 <data_fill@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1070 <block_write@plt>
mov    %rsp,%r15
mov    %ebx,%edi
mov    %r15,%rsi
call   1080 <block_read@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <data_check@plt>
mov    %r14,%rdi
mov    $0xaa,%esi
mov    $0x55,%edx
call   1030 <data_fill@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1070 <block_write@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1080 <block_read@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <data_check@plt>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Testing block %u at address %06X.\0A\00"
@.str.1 = [7 x i8] c"Done.\0A\00"
define void @test_alternate(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = load i32, i32* %2
%7 = mul i32 %6, 1024
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = call i32 @data_fill(i8* %9, i32 85, i32 170)
%11 = load i32, i32* %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i32 @block_write(i32 %11, i8* %12)
%14 = load i32, i32* %2
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = call i32 @block_read(i32 %14, i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%19 = call i32 @data_check(i8* %17, i8* %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @data_fill(i8* %20, i32 170, i32 85)
%22 = load i32, i32* %2
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = call i32 @block_write(i32 %22, i8* %23)
%25 = load i32, i32* %2
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%27 = call i32 @block_read(i32 %25, i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = call i32 @data_check(i8* %28, i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"Testing block %u at address %06X.\0A\00"
@str = [6 x i8] c"Done.\00"
define void @test_alternate(i32 %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = shl i32 %0, 10
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %6)
%8 = call i32 @data_fill(i8* %4, i32 85, i32 170)
%9 = call i32 @block_write(i32 %0, i8* %4)
%10 = call i32 @block_read(i32 %0, i8* %5)
%11 = call i32 @data_check(i8* %4, i8* %5)
%12 = call i32 @data_fill(i8* %4, i32 170, i32 85)
%13 = call i32 @block_write(i32 %0, i8* %4)
%14 = call i32 @block_read(i32 %0, i8* %5)
%15 = call i32 @data_check(i8* %4, i8* %5)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret void
}