// File: /workspace/github_c_makefile_star2_O3/cirocosta[P]stress/src/mem-rw.c
// Function: allocate_and_use
void
allocate_and_use(int n)
{
	void** p;

	_STRESS_MUST((p = malloc((n + 1) * sizeof(void*))),
	             "couldn't allocate memory array");

	_STRESS_INFO("%d MB will be allocated", n);

	for (int i = 0; i++ < n;) {
		_STRESS_MUST((p[i] = malloc(CHUNK_SIZE * sizeof(char))),
		             "Couldn't allocate.");
		memset(p[i], randoml26(), CHUNK_SIZE);
		_STRESS_INFO("Allocated 1MB at position %p", p[i]);
	}

	_STRESS_INFO("Memory allocated.");
	_STRESS_INFO("Starting dumb memory setting.");

	while (1) {
		for (int i = 0; i++ < n;) {
			memset(p[i], randoml26(), CHUNK_SIZE);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r13d
leal 0x1(%r13), %ebp
movslq %ebp, %rdi
shlq $0x3, %rdi
callq 0x1100
movq 0x28a5(%rip), %rbx      # 0x3ff8
movq (%rbx), %rcx
testq %rax, %rax
je 0x1a0b
movq %rax, %r14
leaq 0x9cb(%rip), %rdi       # 0x2134
movl $0x1, %r15d
movl $0x7, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rdi
leaq 0x9b4(%rip), %rsi       # 0x213c
movl %r13d, %edx
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
movabsq $0x4ec4ec4ec4ec4ec5, %r12 # imm = 0x4EC4EC4EC4EC4EC5
movq %r13, (%rsp)
testl %r13d, %r13d
jle 0x1861
movl %ebp, %ebp
movl $0x100000, %edi         # imm = 0x100000
callq 0x1100
movq %rax, %r13
movq %rax, (%r14,%r15,8)
testq %rax, %rax
je 0x1942
callq 0x10f0
cmpq $0x7fffffe7, %rax       # imm = 0x7FFFFFE7
jg 0x17d2
movq %rax, %rcx
imulq %r12
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x3, %rdx
addl %eax, %edx
leal (%rdx,%rdx,4), %eax
leal (%rax,%rax,4), %eax
addl %edx, %eax
subl %eax, %ecx
leaq 0x9b1(%rip), %rax       # 0x21b4
movzbl (%rcx,%rax), %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r13, %rdi
callq 0x10b0
movq 0x27dd(%rip), %rbx      # 0x3ff8
movq (%rbx), %rcx
movl $0x7, %esi
movl $0x1, %edx
leaq 0x905(%rip), %rdi       # 0x2134
callq 0x1140
movq (%rbx), %rdi
leaq 0x929(%rip), %rsi       # 0x2167
movq %r13, %rdx
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
incq %r15
cmpq %rbp, %r15
jne 0x17b8
movq 0x2790(%rip), %rbx      # 0x3ff8
movq (%rbx), %rcx
leaq 0x8c2(%rip), %r15       # 0x2134
movl $0x7, %esi
movl $0x1, %edx
movq %r15, %rdi
callq 0x1140
movq (%rbx), %rcx
leaq 0x8f6(%rip), %rdi       # 0x2184
movl $0x11, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
movq (%rbx), %rcx
movl $0x7, %esi
movl $0x1, %edx
movq %r15, %rdi
callq 0x1140
movq (%rbx), %rcx
leaq 0x8cd(%rip), %rdi       # 0x2196
movl $0x1d, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
movl (%rsp), %r13d
leaq 0x8c4(%rip), %rbp       # 0x21b4
cmpl $0x0, (%rsp)
jle 0x18f0
xorl %ebx, %ebx
movq 0x8(%r14,%rbx,8), %r15
incq %rbx
callq 0x10f0
cmpq $0x7fffffe7, %rax       # imm = 0x7FFFFFE7
jg 0x1900
movq %rax, %rcx
imulq %r12
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x3, %rdx
addl %eax, %edx
leal (%rdx,%rdx,4), %eax
leal (%rax,%rax,4), %eax
addl %edx, %eax
subl %eax, %ecx
movzbl (%rcx,%rbp), %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r15, %rdi
callq 0x10b0
cmpq %r13, %rbx
jne 0x18f8
jmp 0x18f0
movq 0x26af(%rip), %rbx      # 0x3ff8
movq (%rbx), %rcx
leaq 0x6cd(%rip), %rdi       # 0x2020
movl $0x9, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x6ba(%rip), %rdi       # 0x2026
movl $0x3, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x7cf(%rip), %rdi       # 0x2154
movl $0x12, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x6af(%rip), %rdi       # 0x204d
movl $0x2, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rdi
leaq 0x699(%rip), %rsi       # 0x2050
leaq 0x769(%rip), %rdx       # 0x2127
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rdi
leaq 0x69d(%rip), %rsi       # 0x206c
movl $0x29, %edx
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
movq (%rbx), %rcx
leaq 0x687(%rip), %rdi       # 0x2079
movl $0xa, %esi
movl $0x1, %edx
callq 0x1140
movl $0x1, %edi
callq 0x1130
leaq 0x60e(%rip), %rdi       # 0x2020
movl $0x9, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x5fb(%rip), %rdi       # 0x2026
movl $0x3, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x6c4(%rip), %rdi       # 0x2108
movl $0x1e, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x5f0(%rip), %rdi       # 0x204d
movl $0x2, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rdi
leaq 0x5da(%rip), %rsi       # 0x2050
leaq 0x6aa(%rip), %rdx       # 0x2127
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rdi
leaq 0x5de(%rip), %rsi       # 0x206c
movl $0x23, %edx
jmp 0x19d4