#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*/ release_memory_block(void *);
void *request_memory_block();
int /*<<< orphan*/ rtx_dbug_outs(char *);
int /*<<< orphan*/ rtx_dbug_outs_int(char *, int);
void mem_test7() {
  rtx_dbug_outs("Starting Memory Test 7\r\n");
  void *block = request_memory_block();
  rtx_dbug_outs("Writing one's to the block\r\n");
  unsigned char *start = (unsigned char *)(block);
  int i;
  for (i = 0; i < 128; i++) {
    *(start + i) = 0x0001;
  }
  rtx_dbug_outs("Wrote one's\r\n");
  for (i = 0; i < 128; i++) {
    rtx_dbug_outs_int("BLOCK VALUE: ", *(int *)(start + i));
  }
  release_memory_block(block);
  rtx_dbug_outs("Writing zeros\r\n");
  for (i = 0; i < 128; i++) {
    rtx_dbug_outs_int("BLOCK VALUE: ", *(int *)(start + i));
  }
  rtx_dbug_outs("Finished Memory Test 7\r\n");
}


x86 assembly (clang, -O0):
<mem_test7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    $0x0,%al
call   1040 <request_memory_block@plt>
mov    %rax,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    11a1 <mem_test7+0x61>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117a <mem_test7+0x3a>
lea    0xe8e(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    11e6 <mem_test7+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%esi
lea    0xe71(%rip),%rdi
call   1060 <rtx_dbug_outs_int@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <mem_test7+0x74>
mov    -0x8(%rbp),%rdi
call   1050 <release_memory_block@plt>
lea    0xe5c(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    1234 <mem_test7+0xf4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%esi
lea    0xe23(%rip),%rdi
call   1060 <rtx_dbug_outs_int@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1202 <mem_test7+0xc2>
lea    0xe27(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_test7>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%r15
lea    0xec5(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
movaps 0xe90(%rip),%xmm0
movups %xmm0,(%r15)
movups %xmm0,0x10(%r15)
movups %xmm0,0x20(%r15)
movups %xmm0,0x30(%r15)
movups %xmm0,0x40(%r15)
movups %xmm0,0x50(%r15)
movups %xmm0,0x60(%r15)
movups %xmm0,0x70(%r15)
lea    0xea8(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
lea    0xeaa(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1060 <rtx_dbug_outs_int@plt>
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    11b0 <mem_test7+0x70>
mov    %r15,%rdi
call   1050 <release_memory_block@plt>
lea    0xe8a(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
xor    %ebx,%ebx
lea    0xe6e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1060 <rtx_dbug_outs_int@plt>
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    11f0 <mem_test7+0xb0>
lea    0xe62(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <rtx_dbug_outs@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Starting Memory Test 7\0D\0A\00"
@.str.1 = [29 x i8] c"Writing one's to the block\0D\0A\00"
@.str.2 = [14 x i8] c"Wrote one's\0D\0A\00"
@.str.3 = [14 x i8] c"BLOCK VALUE: \00"
@.str.4 = [16 x i8] c"Writing zeros\0D\0A\00"
@.str.5 = [25 x i8] c"Finished Memory Test 7\0D\0A\00"
define void @mem_test7() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = call i8* (...) @request_memory_block()
store i8* %5, i8** %1
%6 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%7 = load i8*, i8** %1
store i8* %7, i8** %2
store i32 0, i32* %3
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 128
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 1, i8* %15
br label %16
16: ; preds = %11
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %8
19: ; preds = %8
%20 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %21
21: ; preds = %32, %19
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 128
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = bitcast i8* %28 to i32*
%30 = load i32, i32* %29
%31 = call i32 @rtx_dbug_outs_int(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %24
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %21
35: ; preds = %21
%36 = load i8*, i8** %1
%37 = call i32 @release_memory_block(i8* %36)
%38 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %39
39: ; preds = %50, %35
%40 = load i32, i32* %3
%41 = icmp slt i32 %40, 128
br i1 %41, label %42, label %53
42: ; preds = %39
%43 = load i8*, i8** %2
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = bitcast i8* %46 to i32*
%48 = load i32, i32* %47
%49 = call i32 @rtx_dbug_outs_int(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %42
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %39
53: ; preds = %39
%54 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Starting Memory Test 7\0D\0A\00"
@.str.1 = [29 x i8] c"Writing one's to the block\0D\0A\00"
@.str.2 = [14 x i8] c"Wrote one's\0D\0A\00"
@.str.3 = [14 x i8] c"BLOCK VALUE: \00"
@.str.4 = [16 x i8] c"Writing zeros\0D\0A\00"
@.str.5 = [25 x i8] c"Finished Memory Test 7\0D\0A\00"
define void @mem_test7() {
%1 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* (...) @request_memory_block()
%3 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %11, %5 ]
%7 = getelementptr inbounds i8, i8* %2, i64 %6
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = tail call i32 @rtx_dbug_outs_int(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = add nuw nsw i64 %6, 1
%12 = icmp eq i64 %11, 128
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = tail call i32 @release_memory_block(i8* %2)
%15 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ 0, %13 ], [ %22, %16 ]
%18 = getelementptr inbounds i8, i8* %2, i64 %17
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
%21 = tail call i32 @rtx_dbug_outs_int(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, 128
br i1 %23, label %24, label %16
24: ; preds = %16
%25 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
ret void
}