// File: /workspace/github_c_makefile_star2_O1/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
movslq %edi, %rax
leaq 0x8(,%rax,8), %rdi
callq 0x1100
movq 0x28a8(%rip), %rbx      # 0x3ff8
movq (%rbx), %rcx
testq %rax, %rax
je 0x19f8
movq %rax, %r14
leaq 0x9ce(%rip), %rdi       # 0x2134
movl $0x1, %r15d
movl $0x7, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rdi
leaq 0x9b7(%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 0x185c
movq (%rsp), %rax
leal 0x1(%rax), %ebp
movl $0x100000, %edi         # imm = 0x100000
callq 0x1100
movq %rax, %r13
movq %rax, (%r14,%r15,8)
testq %rax, %rax
je 0x1936
callq 0x10f0
cmpq $0x7fffffe7, %rax       # imm = 0x7FFFFFE7
jg 0x17d4
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 0x9af(%rip), %rax       # 0x21b4
movzbl (%rcx,%rax), %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r13, %rdi
callq 0x10b0
movq (%rbx), %rcx
movl $0x7, %esi
movl $0x1, %edx
leaq 0x90a(%rip), %rdi       # 0x2134
callq 0x1140
movq (%rbx), %rdi
leaq 0x92e(%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 0x17ba
movq (%rbx), %rcx
leaq 0x8ce(%rip), %r15       # 0x2134
movl $0x7, %esi
movl $0x1, %edx
movq %r15, %rdi
callq 0x1140
movq (%rbx), %rcx
leaq 0x902(%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 0x8d9(%rip), %rdi       # 0x2196
movl $0x1d, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
movl (%rsp), %r13d
leaq 0x8d0(%rip), %rbp       # 0x21b4
cmpl $0x0, (%rsp)
jle 0x18e4
xorl %ebx, %ebx
movq 0x8(%r14,%rbx,8), %r15
incq %rbx
callq 0x10f0
cmpq $0x7fffffe7, %rax       # imm = 0x7FFFFFE7
jg 0x18f4
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 0x18ec
jmp 0x18e4
movq (%rbx), %rcx
leaq 0x6e0(%rip), %rdi       # 0x2020
movl $0x9, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x6cd(%rip), %rdi       # 0x2026
movl $0x3, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x7e2(%rip), %rdi       # 0x2154
movl $0x12, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x6c2(%rip), %rdi       # 0x204d
movl $0x2, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rdi
leaq 0x6ac(%rip), %rsi       # 0x2050
leaq 0x77c(%rip), %rdx       # 0x2127
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rdi
leaq 0x6b0(%rip), %rsi       # 0x206c
movl $0x29, %edx
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x10c0
movq (%rbx), %rcx
leaq 0x69a(%rip), %rdi       # 0x2079
movl $0xa, %esi
movl $0x1, %edx
callq 0x1140
movl $0x1, %edi
callq 0x1130
leaq 0x621(%rip), %rdi       # 0x2020
movl $0x9, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x60e(%rip), %rdi       # 0x2026
movl $0x3, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x6d7(%rip), %rdi       # 0x2108
movl $0x1e, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rcx
leaq 0x603(%rip), %rdi       # 0x204d
movl $0x2, %esi
movl $0x1, %edx
callq 0x1140
movq (%rbx), %rdi
leaq 0x5ed(%rip), %rsi       # 0x2050
leaq 0x6bd(%rip), %rdx       # 0x2127
xorl %eax, %eax
callq 0x10e0
movq (%rbx), %rdi
leaq 0x5f1(%rip), %rsi       # 0x206c
movl $0x23, %edx
jmp 0x19c1