// File: /workspace/github_c_makefile_star2_O2/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, %ebx
movslq %edi, %rax
leaq 0x8(,%rax,8), %rdi
callq 0x1100
movq 0x2946(%rip), %r12      # 0x3ff8
movq (%r12), %rcx
testq %rax, %rax
je 0x18d9
movq %rax, %r14
leaq 0xa6b(%rip), %rdi       # 0x2134
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x1140
movq (%r12), %rdi
leaq 0xa5d(%rip), %rsi       # 0x213c
xorl %r15d, %r15d
movl %ebx, %edx
xorl %eax, %eax
callq 0x10e0
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x10c0
testl %ebx, %ebx
cmovlel %r15d, %ebx
leaq 0xa63(%rip), %r15       # 0x2167
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x177b
movl $0x100000, %edi         # imm = 0x100000
callq 0x1100
movq %rax, 0x8(%r14,%r13,8)
testq %rax, %rax
je 0x1827
movq %rax, %r12
callq 0x19bd
movzbl %al, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r12, %rdi
callq 0x10b0
movq 0x28b5(%rip), %rbp      # 0x3ff8
movq (%rbp), %rcx
leaq 0x9e6(%rip), %rdi       # 0x2134
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x1140
movq (%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x10e0
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0x10c0
incq %r13
jmp 0x1707
movq 0x2876(%rip), %r13      # 0x3ff8
movq (%r13), %rcx
leaq 0x9a7(%rip), %r12       # 0x2134
pushq $0x7
popq %rsi
pushq $0x1
popq %r15
movq %r12, %rdi
movq %r15, %rdx
callq 0x1140
movq (%r13), %rcx
leaq 0x9da(%rip), %rdi       # 0x2184
pushq $0x11
popq %rsi
movq %r15, %rdx
callq 0x1140
movq (%r13), %rsi
pushq $0xa
popq %rbp
movl %ebp, %edi
callq 0x10c0
movq (%r13), %rcx
movq %r12, %rdi
pushq $0x7
popq %rsi
movq %r15, %rdx
callq 0x1140
movq (%r13), %rcx
leaq 0x9b6(%rip), %rdi       # 0x2196
pushq $0x1d
popq %rsi
movq %r15, %rdx
callq 0x1140
movq (%r13), %rsi
movl %ebp, %edi
callq 0x10c0
xorl %eax, %eax
movq %rax, %r12
movl $0x0, %eax
cmpq %rbx, %r12
je 0x17f8
movq 0x8(%r14,%r12,8), %r15
incq %r12
callq 0x19bd
movzbl %al, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r15, %rdi
callq 0x10b0
movq %r12, %rax
jmp 0x17f8
movq 0x27ca(%rip), %r14      # 0x3ff8
movq (%r14), %rcx
leaq 0x7e8(%rip), %rdi       # 0x2020
pushq $0x9
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1140
movq (%r14), %rcx
leaq 0x7d6(%rip), %rdi       # 0x2026
pushq $0x3
popq %rsi
movq %rbx, %rdx
callq 0x1140
movq (%r14), %rcx
leaq 0x8ef(%rip), %rdi       # 0x2154
pushq $0x12
popq %rsi
movq %rbx, %rdx
callq 0x1140
movq (%r14), %rcx
leaq 0x7d3(%rip), %rdi       # 0x204d
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x1140
movq (%r14), %rdi
leaq 0x7c1(%rip), %rsi       # 0x2050
leaq 0x891(%rip), %rdx       # 0x2127
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rdi
leaq 0x7c5(%rip), %rsi       # 0x206c
pushq $0x29
popq %rdx
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x10c0
movq (%r14), %rcx
leaq 0x7b3(%rip), %rdi       # 0x2079
pushq $0xa
popq %rsi
movq %rbx, %rdx
callq 0x1140
pushq $0x1
popq %rdi
callq 0x1130
leaq 0x740(%rip), %rdi       # 0x2020
pushq $0x9
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1140
movq (%r12), %rcx
leaq 0x72d(%rip), %rdi       # 0x2026
pushq $0x3
popq %rsi
movq %rbx, %rdx
callq 0x1140
movq (%r12), %rcx
leaq 0x7f9(%rip), %rdi       # 0x2108
pushq $0x1e
popq %rsi
movq %rbx, %rdx
callq 0x1140
movq (%r12), %rcx
leaq 0x728(%rip), %rdi       # 0x204d
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x1140
movq (%r12), %rdi
leaq 0x715(%rip), %rsi       # 0x2050
leaq 0x7e5(%rip), %rdx       # 0x2127
xorl %eax, %eax
callq 0x10e0
movq (%r12), %rdi
leaq 0x718(%rip), %rsi       # 0x206c
pushq $0x23
popq %rdx
xorl %eax, %eax
callq 0x10e0
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x10c0
movq (%r12), %rcx
jmp 0x18bf