#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 *);
void mem_test6() {
  rtx_dbug_outs("Starting Memory Test 6\r\n");
  void *testArray[16];
  int i;
  for (i = 0; i < 16; i++) {
    testArray[i] = request_memory_block();
  }
  rtx_dbug_outs("Blocks requested\r\n");
  release_memory_block(testArray[4]);
  release_memory_block(testArray[10]);
  for (i = 0; i < 16; i++) {
    if (i != 4 && i != 10) {
      release_memory_block(testArray[i]);
    }
  }
  rtx_dbug_outs("Finished Memory Test 6\r\n");
}


x86 assembly (clang, -O0):
<mem_test6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xebe(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x10,-0x84(%rbp)
jge    1188 <mem_test6+0x58>
mov    $0x0,%al
call   1040 <request_memory_block@plt>
mov    %rax,%rcx
movslq -0x84(%rbp),%rax
mov    %rcx,-0x80(%rbp,%rax,8)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1151 <mem_test6+0x21>
lea    0xe8a(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    -0x60(%rbp),%rdi
call   1050 <release_memory_block@plt>
mov    -0x30(%rbp),%rdi
call   1050 <release_memory_block@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x10,-0x84(%rbp)
jge    1201 <mem_test6+0xd1>
cmpl   $0x4,-0x84(%rbp)
je     11e8 <mem_test6+0xb8>
cmpl   $0xa,-0x84(%rbp)
je     11e8 <mem_test6+0xb8>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
call   1050 <release_memory_block@plt>
jmp    11ed <mem_test6+0xbd>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11b0 <mem_test6+0x80>
lea    0xe24(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_test6>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xebb(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x50(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x48(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x40(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x38(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x30(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x28(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x20(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%r15
lea    0xe14(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    %r12,%rdi
call   1050 <release_memory_block@plt>
mov    %r13,%rdi
call   1050 <release_memory_block@plt>
mov    0x50(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x48(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x40(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x38(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x30(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x28(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x20(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x18(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x10(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    0x8(%rsp),%rdi
call   1050 <release_memory_block@plt>
mov    %rbx,%rdi
call   1050 <release_memory_block@plt>
mov    %rbp,%rdi
call   1050 <release_memory_block@plt>
mov    %r14,%rdi
call   1050 <release_memory_block@plt>
mov    %r15,%rdi
call   1050 <release_memory_block@plt>
lea    0xd87(%rip),%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <rtx_dbug_outs@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Starting Memory Test 6\0D\0A\00"
@.str.1 = [19 x i8] c"Blocks requested\0D\0A\00"
@.str.2 = [25 x i8] c"Finished Memory Test 6\0D\0A\00"
define void @mem_test6() {
%1 = alloca [16 x i8*]
%2 = alloca i32
%3 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = call i8* (...) @request_memory_block()
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [16 x i8*], [16 x i8*]* %1, i64 0, i64 %10
store i8* %8, i8** %11
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
%16 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [16 x i8*], [16 x i8*]* %1, i64 0, i64 4
%18 = load i8*, i8** %17
%19 = call i32 @release_memory_block(i8* %18)
%20 = getelementptr inbounds [16 x i8*], [16 x i8*]* %1, i64 0, i64 10
%21 = load i8*, i8** %20
%22 = call i32 @release_memory_block(i8* %21)
store i32 0, i32* %2
br label %23
23: ; preds = %39, %15
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 16
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 4
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, 10
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [16 x i8*], [16 x i8*]* %1, i64 0, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @release_memory_block(i8* %36)
br label %38
38: ; preds = %32, %29, %26
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %23
42: ; preds = %23
%43 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Starting Memory Test 6\0D\0A\00"
@.str.1 = [19 x i8] c"Blocks requested\0D\0A\00"
@.str.2 = [25 x i8] c"Finished Memory Test 6\0D\0A\00"
define void @mem_test6() {
%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 i8* (...) @request_memory_block()
%4 = tail call i8* (...) @request_memory_block()
%5 = tail call i8* (...) @request_memory_block()
%6 = tail call i8* (...) @request_memory_block()
%7 = tail call i8* (...) @request_memory_block()
%8 = tail call i8* (...) @request_memory_block()
%9 = tail call i8* (...) @request_memory_block()
%10 = tail call i8* (...) @request_memory_block()
%11 = tail call i8* (...) @request_memory_block()
%12 = tail call i8* (...) @request_memory_block()
%13 = tail call i8* (...) @request_memory_block()
%14 = tail call i8* (...) @request_memory_block()
%15 = tail call i8* (...) @request_memory_block()
%16 = tail call i8* (...) @request_memory_block()
%17 = tail call i8* (...) @request_memory_block()
%18 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @release_memory_block(i8* %6)
%20 = tail call i32 @release_memory_block(i8* %12)
%21 = tail call i32 @release_memory_block(i8* %2)
%22 = tail call i32 @release_memory_block(i8* %3)
%23 = tail call i32 @release_memory_block(i8* %4)
%24 = tail call i32 @release_memory_block(i8* %5)
%25 = tail call i32 @release_memory_block(i8* %7)
%26 = tail call i32 @release_memory_block(i8* %8)
%27 = tail call i32 @release_memory_block(i8* %9)
%28 = tail call i32 @release_memory_block(i8* %10)
%29 = tail call i32 @release_memory_block(i8* %11)
%30 = tail call i32 @release_memory_block(i8* %13)
%31 = tail call i32 @release_memory_block(i8* %14)
%32 = tail call i32 @release_memory_block(i8* %15)
%33 = tail call i32 @release_memory_block(i8* %16)
%34 = tail call i32 @release_memory_block(i8* %17)
%35 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
ret void
}