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


x86 assembly (clang, -O0):
<test_counter>:
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
xor    %esi,%esi
mov    $0xffffffff,%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    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_counter>:
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
xor    %esi,%esi
mov    $0xffffffff,%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>
lea    0xe60(%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_counter(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 0, i32 -1)
%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 = 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_counter(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 0, i32 -1)
%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 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret void
}