#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 */
typedef int /*<<< orphan*/ p;
typedef int /*<<< orphan*/ offset;
typedef int /*<<< orphan*/ align;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ __mingw_aligned_free(unsigned char *);
unsigned char *__mingw_aligned_offset_realloc(unsigned char *, size_t, size_t,
                                              size_t);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ is_aligned(unsigned char *, size_t, size_t);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  unsigned char *p[1000];
  size_t size[1000];
  size_t align[] = {2, 4, 8, 16, 32, 64};
  size_t offset[20];
  unsigned i;
  srand(time(NULL));
  for (i = 0; i < (sizeof(p) / sizeof(p[0])); ++i) {
    p[i] = 0;
    size[i] = 0;
  }
  for (i = 0; i < (sizeof(offset) / sizeof(offset[0])); ++i)
    offset[i] = rand() % 512;
  for (i = 0; i < 100000U; ++i) {
    size_t oldsize;
    unsigned j, k;
    j = rand() % (sizeof(p) / sizeof(p[0]));
    oldsize = size[j];
    p[j] = __mingw_aligned_offset_realloc(
        p[j], size[j] = rand() % (1 << sizeof(unsigned char)),
        align[j % (sizeof(align) / sizeof(align[0]))],
        offset[j % (sizeof(offset) / sizeof(offset[0]))]);
    if (size[j] && !p[j]) {
      fprintf(stderr, "Returned NULL!\n");
      fprintf(stderr,
              "Iteration %u, align = %u, offset = %u, size = %u (oldsize = "
              "%u), errno = %d (%s)\n",
              i, align[j % (sizeof(align) / sizeof(align[0]))],
              offset[j % (sizeof(offset) / sizeof(offset[0]))], size[j],
              oldsize, errno, strerror(errno));
      return EXIT_FAILURE;
    }
    if (size[j] &&
        !is_aligned(p[j], align[j % (sizeof(align) / sizeof(align[0]))],
                    offset[j % (sizeof(offset) / sizeof(offset[0]))])) {
      fprintf(stderr, "Misaligned block!\n");
      fprintf(stderr,
              "Iteration %u, align = %u, offset = %u, size = %u (oldsize = "
              "%u), errno = %d (%s)\n",
              i, align[j % (sizeof(align) / sizeof(align[0]))],
              offset[j % (sizeof(offset) / sizeof(offset[0]))], size[j],
              oldsize, errno, strerror(errno));
      return EXIT_FAILURE;
    }
    if (oldsize > size[j])
      oldsize = size[j];
    for (k = 0; k < oldsize; ++k)
      if (p[j][k] != k) {
        fprintf(stderr, "Miscopied block!\n");
        fprintf(stderr,
                "Iteration %u, align = %u, offset = %u, size = %u (oldsize = "
                "%u), errno = %d (%s)\n",
                i, align[j % (sizeof(align) / sizeof(align[0]))],
                offset[j % (sizeof(offset) / sizeof(offset[0]))], size[j],
                oldsize, errno, strerror(errno));
        return EXIT_FAILURE;
      }
    for (k = 0; k < size[j]; ++k)
      p[j][k] = k;
  }
  for (i = 0; i < (sizeof(p) / sizeof(p[0])); ++i)
    __mingw_aligned_free(p[i]);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4030,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3ec0(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
movq   $0x2,-0x3ec0(%rbp)
movq   $0x4,-0x3eb8(%rbp)
movq   $0x8,-0x3eb0(%rbp)
movq   $0x10,-0x3ea8(%rbp)
movq   $0x20,-0x3ea0(%rbp)
movq   $0x40,-0x3e98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x3f64(%rbp)
mov    -0x3f64(%rbp),%eax
cmp    $0x3e8,%rax
jae    125b <main+0xcb>
mov    -0x3f64(%rbp),%eax
movq   $0x0,-0x1f50(%rbp,%rax,8)
mov    -0x3f64(%rbp),%eax
movq   $0x0,-0x3e90(%rbp,%rax,8)
mov    -0x3f64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f64(%rbp)
jmp    1211 <main+0x81>
movl   $0x0,-0x3f64(%rbp)
mov    -0x3f64(%rbp),%eax
cmp    $0x14,%rax
jae    12a9 <main+0x119>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x200,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
mov    -0x3f64(%rbp),%eax
mov    %rcx,-0x3f60(%rbp,%rax,8)
ff
mov    -0x3f64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f64(%rbp)
jmp    1265 <main+0xd5>
movl   $0x0,-0x3f64(%rbp)
cmpl   $0x186a0,-0x3f64(%rbp)
jae    182f <main+0x69f>
mov    $0x0,%al
call   10b0 <rand@plt>
cltq
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x3f74(%rbp)
mov    -0x3f74(%rbp),%eax
mov    -0x3e90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x3f70(%rbp)
mov    -0x3f74(%rbp),%eax
mov    -0x1f50(%rbp,%rax,8),%rax
mov    %rax,-0x3f88(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0x3f88(%rbp),%rdi
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %edx,%rsi
mov    -0x3f74(%rbp),%eax
mov    %rsi,-0x3e90(%rbp,%rax,8)
ff
mov    -0x3f74(%rbp),%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3ec0(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x3f80(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
mov    -0x3f80(%rbp),%rdx
mov    -0x3f60(%rbp,%rax,8),%rcx
ff
call   1030 <__mingw_aligned_offset_realloc@plt>
mov    %rax,%rcx
mov    -0x3f74(%rbp),%eax
mov    %rcx,-0x1f50(%rbp,%rax,8)
ff
mov    -0x3f74(%rbp),%eax
cmpq   $0x0,-0x3e90(%rbp,%rax,8)
je     14bc <main+0x32c>
mov    -0x3f74(%rbp),%eax
cmpq   $0x0,-0x1f50(%rbp,%rax,8)
jne    14bc <main+0x32c>
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
lea    0xc40(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3fb8(%rbp)
mov    -0x3f64(%rbp),%eax
mov    %eax,-0x3fb4(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3ec0(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x3fb0(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3f60(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x3fa8(%rbp)
mov    -0x3f74(%rbp),%eax
mov    -0x3e90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x3fa0(%rbp)
mov    -0x3f70(%rbp),%rax
mov    %rax,-0x3f98(%rbp)
mov    0x2b8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3f8c(%rbp)
mov    0x2b7f(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x3fb8(%rbp),%edi
mov    -0x3fb4(%rbp),%edx
mov    -0x3fb0(%rbp),%rcx
mov    -0x3fa8(%rbp),%r8
mov    -0x3fa0(%rbp),%r9
mov    -0x3f98(%rbp),%r11
mov    -0x3f8c(%rbp),%r10d
lea    0xb7a(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    187e <main+0x6ee>
mov    -0x3f74(%rbp),%eax
cmpq   $0x0,-0x3e90(%rbp,%rax,8)
je     1629 <main+0x499>
mov    -0x3f74(%rbp),%eax
mov    -0x1f50(%rbp,%rax,8),%rdi
ff
mov    -0x3f74(%rbp),%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3ec0(%rbp,%rdx,8),%rsi
ff
mov    -0x3f74(%rbp),%eax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3f60(%rbp,%rdx,8),%rdx
ff
call   1040 <is_aligned@plt>
cmp    $0x0,%eax
jne    1629 <main+0x499>
mov    0x2abc(%rip),%rax
mov    (%rax),%edi
lea    0xb35(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2aa5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3fe8(%rbp)
mov    -0x3f64(%rbp),%eax
mov    %eax,-0x3fe4(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3ec0(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x3fe0(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3f60(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x3fd8(%rbp)
mov    -0x3f74(%rbp),%eax
mov    -0x3e90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x3fd0(%rbp)
mov    -0x3f70(%rbp),%rax
mov    %rax,-0x3fc8(%rbp)
mov    0x2a21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3fbc(%rbp)
mov    0x2a12(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x3fe8(%rbp),%edi
mov    -0x3fe4(%rbp),%edx
mov    -0x3fe0(%rbp),%rcx
mov    -0x3fd8(%rbp),%r8
mov    -0x3fd0(%rbp),%r9
mov    -0x3fc8(%rbp),%r11
mov    -0x3fbc(%rbp),%r10d
lea    0xa0d(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x29b1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    187e <main+0x6ee>
mov    -0x3f70(%rbp),%rax
mov    -0x3f74(%rbp),%ecx
cmp    -0x3e90(%rbp,%rcx,8),%rax
ff
jbe    1659 <main+0x4c9>
mov    -0x3f74(%rbp),%eax
mov    -0x3e90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x3f70(%rbp)
movl   $0x0,-0x3f78(%rbp)
mov    -0x3f78(%rbp),%eax
cmp    -0x3f70(%rbp),%rax
jae    17bf <main+0x62f>
mov    -0x3f74(%rbp),%eax
mov    -0x1f50(%rbp,%rax,8),%rax
ff
mov    -0x3f78(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    -0x3f78(%rbp),%eax
je     17a6 <main+0x616>
mov    0x293f(%rip),%rax
mov    (%rax),%edi
lea    0x9cb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2928(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4018(%rbp)
mov    -0x3f64(%rbp),%eax
mov    %eax,-0x4014(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3ec0(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x4010(%rbp)
mov    -0x3f74(%rbp),%eax
mov    $0x14,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x3f60(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x4008(%rbp)
mov    -0x3f74(%rbp),%eax
mov    -0x3e90(%rbp,%rax,8),%rax
ff
mov    %rax,-0x4000(%rbp)
mov    -0x3f70(%rbp),%rax
mov    %rax,-0x3ff8(%rbp)
mov    0x28a4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3fec(%rbp)
mov    0x2895(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x4018(%rbp),%edi
mov    -0x4014(%rbp),%edx
mov    -0x4010(%rbp),%rcx
mov    -0x4008(%rbp),%r8
mov    -0x4000(%rbp),%r9
mov    -0x3ff8(%rbp),%r11
mov    -0x3fec(%rbp),%r10d
lea    0x890(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2834(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    187e <main+0x6ee>
jmp    17ab <main+0x61b>
mov    -0x3f78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f78(%rbp)
jmp    1663 <main+0x4d3>
movl   $0x0,-0x3f78(%rbp)
mov    -0x3f78(%rbp),%eax
mov    -0x3f74(%rbp),%ecx
cmp    -0x3e90(%rbp,%rcx,8),%rax
ff
jae    1816 <main+0x686>
mov    -0x3f78(%rbp),%eax
mov    %al,%dl
mov    -0x3f74(%rbp),%eax
mov    -0x1f50(%rbp,%rax,8),%rax
ff
mov    -0x3f78(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x3f78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f78(%rbp)
jmp    17c9 <main+0x639>
jmp    181b <main+0x68b>
mov    -0x3f64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f64(%rbp)
jmp    12b3 <main+0x123>
movl   $0x0,-0x3f64(%rbp)
mov    -0x3f64(%rbp),%eax
cmp    $0x3e8,%rax
jae    1872 <main+0x6e2>
mov    -0x3f64(%rbp),%eax
mov    -0x1f50(%rbp,%rax,8),%rdi
ff
call   1090 <__mingw_aligned_free@plt>
mov    -0x3f64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f64(%rbp)
jmp    1839 <main+0x6a9>
mov    0x274f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f68,%rsp
movaps 0xe58(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe5c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe60(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe0(%rsp),%rdi
mov    $0x1f40,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x2020(%rsp),%rdi
mov    $0x1f40,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0x1ff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffe00,%ecx
sub    %ecx,%eax
cltq
mov    %rax,0x40(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1200 <main+0x70>
movabs $0x20c49ba5e353f7cf,%rbx
9b c4 20
xor    %r12d,%r12d
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%r15
mov    %r15,%rax
shr    $0x3,%rax
mul    %rbx
shr    $0x4,%rdx
imul   $0x3e8,%rdx,%rax
sub    %rax,%r15
mov    0x2020(%rsp,%r15,8),%r14
mov    0xe0(%rsp,%r15,8),%rbp
xor    %eax,%eax
call   10b0 <rand@plt>
mov    %eax,%r13d
shr    $0x1f,%eax
add    %r13d,%eax
and    $0xfffffffe,%eax
sub    %eax,%r13d
movslq %r13d,%rbx
mov    %rbx,0x2020(%rsp,%r15,8)
imul   $0xaaab,%r15d,%eax
shr    $0x11,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,2),%eax
mov    %r15d,%ecx
sub    %eax,%ecx
movzwl %cx,%eax
mov    0x10(%rsp,%rax,8),%rdx
imul   $0xcccd,%r15d,%eax
shr    $0x12,%eax
and    $0xfffffffc,%eax
lea    (%rax,%rax,4),%eax
mov    %r15d,%ecx
sub    %eax,%ecx
movzwl %cx,%eax
mov    0x40(%rsp,%rax,8),%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %rdx,0x8(%rsp)
mov    %rcx,(%rsp)
call   1030 <__mingw_aligned_offset_realloc@plt>
mov    %rax,%rbp
mov    %rax,0xe0(%rsp,%r15,8)
test   %ebx,%ebx
je     12f1 <main+0x161>
test   %rbp,%rbp
je     1404 <main+0x274>
test   %r13d,%r13d
je     130f <main+0x17f>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
call   1040 <is_aligned@plt>
test   %eax,%eax
je     1417 <main+0x287>
cmp    %rbx,%r14
cmova  %rbx,%r14
test   %r14,%r14
je     1331 <main+0x1a1>
xor    %eax,%eax
nopl   (%rax)
movzbl 0x0(%rbp,%rax,1),%ecx
cmp    %ecx,%eax
jne    138c <main+0x1fc>
add    $0x1,%eax
cmp    %rax,%r14
ja     1320 <main+0x190>
test   %r13d,%r13d
je     134c <main+0x1bc>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    %al,0x0(%rbp,%rax,1)
add    $0x1,%eax
cmp    %rbx,%rax
jb     1340 <main+0x1b0>
add    $0x1,%r12d
cmp    $0x186a0,%r12d
movabs $0x20c49ba5e353f7cf,%rbx
9b c4 20
jne    1238 <main+0xa8>
xor    %ebp,%ebp
mov    0x2c58(%rip),%rbx
mov    0xe0(%rsp,%rbp,8),%rdi
call   1090 <__mingw_aligned_free@plt>
add    $0x1,%rbp
cmp    $0x3e8,%rbp
jne    1370 <main+0x1e0>
jmp    13f0 <main+0x260>
mov    0x2c4d(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd08(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%r13d
mov    0x2c29(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10a0 <strerror@plt>
mov    %rax,%r10
sub    $0x8,%rsp
lea    0xc7a(%rip),%rsi
mov    %r13d,%edi
mov    %r12d,%edx
mov    0x10(%rsp),%rcx
mov    0x8(%rsp),%r8
mov    %rbx,%r9
xor    %eax,%eax
push   %r10
push   %rbp
push   %r14
call   1070 <fprintf@plt>
add    $0x20,%rsp
mov    0x2be0(%rip),%rbx
mov    (%rbx),%eax
add    $0x3f68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bd5(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc1b(%rip),%rsi
jmp    139d <main+0x20d>
mov    0x2bc2(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc6a(%rip),%rsi
jmp    139d <main+0x20d>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Returned NULL!\0A\00"
@.str.1 = [82 x i8] c"Iteration %u, align = %u, offset = %u, size = %u (oldsize = %u), errno = %d (%s)\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [19 x i8] c"Misaligned block!\0A\00"
@.str.3 = [18 x i8] c"Miscopied block!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8*]
%3 = alloca [1000 x i64]
%4 = alloca [6 x i64]
%5 = alloca [20 x i64]
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [6 x i64]* %4 to i8*
%11 = bitcast i8* %10 to [6 x i64]*
%12 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i32 0, i32 0
store i64 2, i64* %12
%13 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i32 0, i32 1
store i64 4, i64* %13
%14 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i32 0, i32 2
store i64 8, i64* %14
%15 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i32 0, i32 3
store i64 16, i64* %15
%16 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i32 0, i32 4
store i64 32, i64* %16
%17 = getelementptr inbounds [6 x i64], [6 x i64]* %11, i32 0, i32 5
store i64 64, i64* %17
%18 = call i32 @time(i32* null)
%19 = call i32 @srand(i32 %18)
store i32 0, i32* %6
br label %20
20: ; preds = %31, %0
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = icmp ult i64 %22, 1000
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %26
store i8* null, i8** %27
%28 = load i32, i32* %6
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %29
store i64 0, i64* %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %6
%33 = add i32 %32, 1
store i32 %33, i32* %6
br label %20
34: ; preds = %20
store i32 0, i32* %6
br label %35
35: ; preds = %46, %34
%36 = load i32, i32* %6
%37 = zext i32 %36 to i64
%38 = icmp ult i64 %37, 20
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = call i32 (...) @rand()
%41 = srem i32 %40, 512
%42 = sext i32 %41 to i64
%43 = load i32, i32* %6
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [20 x i64], [20 x i64]* %5, i64 0, i64 %44
store i64 %42, i64* %45
br label %46
46: ; preds = %39
%47 = load i32, i32* %6
%48 = add i32 %47, 1
store i32 %48, i32* %6
br label %35
49: ; preds = %35
store i32 0, i32* %6
br label %50
50: ; preds = %252, %49
%51 = load i32, i32* %6
%52 = icmp ult i32 %51, 100000
br i1 %52, label %53, label %255
53: ; preds = %50
%54 = call i32 (...) @rand()
%55 = sext i32 %54 to i64
%56 = urem i64 %55, 1000
%57 = trunc i64 %56 to i32
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %59
%61 = load i64, i64* %60
store i64 %61, i64* %7
%62 = load i32, i32* %8
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 (...) @rand()
%67 = srem i32 %66, 2
%68 = sext i32 %67 to i64
%69 = load i32, i32* %8
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %70
store i64 %68, i64* %71
%72 = load i32, i32* %8
%73 = zext i32 %72 to i64
%74 = urem i64 %73, 6
%75 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 %74
%76 = load i64, i64* %75
%77 = load i32, i32* %8
%78 = zext i32 %77 to i64
%79 = urem i64 %78, 20
%80 = getelementptr inbounds [20 x i64], [20 x i64]* %5, i64 0, i64 %79
%81 = load i64, i64* %80
%82 = call i8* @__mingw_aligned_offset_realloc(i8* %65, i64 %68, i64 %76, i64 %81)
%83 = load i32, i32* %8
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %84
store i8* %82, i8** %85
%86 = load i32, i32* %8
%87 = zext i32 %86 to i64
%88 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %87
%89 = load i64, i64* %88
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %122
91: ; preds = %53
%92 = load i32, i32* %8
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %93
%95 = load i8*, i8** %94
%96 = icmp ne i8* %95, null
br i1 %96, label %122, label %97
97: ; preds = %91
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%100 = load i32, i32* @stderr
%101 = load i32, i32* %6
%102 = load i32, i32* %8
%103 = zext i32 %102 to i64
%104 = urem i64 %103, 6
%105 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 %104
%106 = load i64, i64* %105
%107 = load i32, i32* %8
%108 = zext i32 %107 to i64
%109 = urem i64 %108, 20
%110 = getelementptr inbounds [20 x i64], [20 x i64]* %5, i64 0, i64 %109
%111 = load i64, i64* %110
%112 = load i32, i32* %8
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %113
%115 = load i64, i64* %114
%116 = load i64, i64* %7
%117 = load i32, i32* @errno
%118 = load i32, i32* @errno
%119 = call i8* @strerror(i32 %118)
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %101, i64 %106, i64 %111, i64 %115, i64 %116, i32 %117, i8* %119)
%121 = load i32, i32* @EXIT_FAILURE
store i32 %121, i32* %1
br label %271
122: ; preds = %91, %53
%123 = load i32, i32* %8
%124 = zext i32 %123 to i64
%125 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %124
%126 = load i64, i64* %125
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %170
128: ; preds = %122
%129 = load i32, i32* %8
%130 = zext i32 %129 to i64
%131 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %130
%132 = load i8*, i8** %131
%133 = load i32, i32* %8
%134 = zext i32 %133 to i64
%135 = urem i64 %134, 6
%136 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 %135
%137 = load i64, i64* %136
%138 = load i32, i32* %8
%139 = zext i32 %138 to i64
%140 = urem i64 %139, 20
%141 = getelementptr inbounds [20 x i64], [20 x i64]* %5, i64 0, i64 %140
%142 = load i64, i64* %141
%143 = call i32 @is_aligned(i8* %132, i64 %137, i64 %142)
%144 = icmp ne i32 %143, 0
br i1 %144, label %170, label %145
145: ; preds = %128
%146 = load i32, i32* @stderr
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%148 = load i32, i32* @stderr
%149 = load i32, i32* %6
%150 = load i32, i32* %8
%151 = zext i32 %150 to i64
%152 = urem i64 %151, 6
%153 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 %152
%154 = load i64, i64* %153
%155 = load i32, i32* %8
%156 = zext i32 %155 to i64
%157 = urem i64 %156, 20
%158 = getelementptr inbounds [20 x i64], [20 x i64]* %5, i64 0, i64 %157
%159 = load i64, i64* %158
%160 = load i32, i32* %8
%161 = zext i32 %160 to i64
%162 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %161
%163 = load i64, i64* %162
%164 = load i64, i64* %7
%165 = load i32, i32* @errno
%166 = load i32, i32* @errno
%167 = call i8* @strerror(i32 %166)
%168 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %149, i64 %154, i64 %159, i64 %163, i64 %164, i32 %165, i8* %167)
%169 = load i32, i32* @EXIT_FAILURE
store i32 %169, i32* %1
br label %271
170: ; preds = %128, %122
%171 = load i64, i64* %7
%172 = load i32, i32* %8
%173 = zext i32 %172 to i64
%174 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %173
%175 = load i64, i64* %174
%176 = icmp ugt i64 %171, %175
br i1 %176, label %177, label %182
177: ; preds = %170
%178 = load i32, i32* %8
%179 = zext i32 %178 to i64
%180 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %179
%181 = load i64, i64* %180
store i64 %181, i64* %7
br label %182
182: ; preds = %177, %170
store i32 0, i32* %9
br label %183
183: ; preds = %226, %182
%184 = load i32, i32* %9
%185 = zext i32 %184 to i64
%186 = load i64, i64* %7
%187 = icmp ult i64 %185, %186
br i1 %187, label %188, label %229
188: ; preds = %183
%189 = load i32, i32* %8
%190 = zext i32 %189 to i64
%191 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %190
%192 = load i8*, i8** %191
%193 = load i32, i32* %9
%194 = zext i32 %193 to i64
%195 = getelementptr inbounds i8, i8* %192, i64 %194
%196 = load i8, i8* %195
%197 = zext i8 %196 to i32
%198 = load i32, i32* %9
%199 = icmp ne i32 %197, %198
br i1 %199, label %200, label %225
200: ; preds = %188
%201 = load i32, i32* @stderr
%202 = call i32 (i32, i8*, ...) @fprintf(i32 %201, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%203 = load i32, i32* @stderr
%204 = load i32, i32* %6
%205 = load i32, i32* %8
%206 = zext i32 %205 to i64
%207 = urem i64 %206, 6
%208 = getelementptr inbounds [6 x i64], [6 x i64]* %4, i64 0, i64 %207
%209 = load i64, i64* %208
%210 = load i32, i32* %8
%211 = zext i32 %210 to i64
%212 = urem i64 %211, 20
%213 = getelementptr inbounds [20 x i64], [20 x i64]* %5, i64 0, i64 %212
%214 = load i64, i64* %213
%215 = load i32, i32* %8
%216 = zext i32 %215 to i64
%217 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %216
%218 = load i64, i64* %217
%219 = load i64, i64* %7
%220 = load i32, i32* @errno
%221 = load i32, i32* @errno
%222 = call i8* @strerror(i32 %221)
%223 = call i32 (i32, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %204, i64 %209, i64 %214, i64 %218, i64 %219, i32 %220, i8* %222)
%224 = load i32, i32* @EXIT_FAILURE
store i32 %224, i32* %1
br label %271
225: ; preds = %188
br label %226
226: ; preds = %225
%227 = load i32, i32* %9
%228 = add i32 %227, 1
store i32 %228, i32* %9
br label %183
229: ; preds = %183
store i32 0, i32* %9
br label %230
230: ; preds = %248, %229
%231 = load i32, i32* %9
%232 = zext i32 %231 to i64
%233 = load i32, i32* %8
%234 = zext i32 %233 to i64
%235 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %234
%236 = load i64, i64* %235
%237 = icmp ult i64 %232, %236
br i1 %237, label %238, label %251
238: ; preds = %230
%239 = load i32, i32* %9
%240 = trunc i32 %239 to i8
%241 = load i32, i32* %8
%242 = zext i32 %241 to i64
%243 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %242
%244 = load i8*, i8** %243
%245 = load i32, i32* %9
%246 = zext i32 %245 to i64
%247 = getelementptr inbounds i8, i8* %244, i64 %246
store i8 %240, i8* %247
br label %248
248: ; preds = %238
%249 = load i32, i32* %9
%250 = add i32 %249, 1
store i32 %250, i32* %9
br label %230
251: ; preds = %230
br label %252
252: ; preds = %251
%253 = load i32, i32* %6
%254 = add i32 %253, 1
store i32 %254, i32* %6
br label %50
255: ; preds = %50
store i32 0, i32* %6
br label %256
256: ; preds = %266, %255
%257 = load i32, i32* %6
%258 = zext i32 %257 to i64
%259 = icmp ult i64 %258, 1000
br i1 %259, label %260, label %269
260: ; preds = %256
%261 = load i32, i32* %6
%262 = zext i32 %261 to i64
%263 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %262
%264 = load i8*, i8** %263
%265 = call i32 @__mingw_aligned_free(i8* %264)
br label %266
266: ; preds = %260
%267 = load i32, i32* %6
%268 = add i32 %267, 1
store i32 %268, i32* %6
br label %256
269: ; preds = %256
%270 = load i32, i32* @EXIT_SUCCESS
store i32 %270, i32* %1
br label %271
271: ; preds = %269, %200, %145, %97
%272 = load i32, i32* %1
ret i32 %272
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Returned NULL!\0A\00"
@.str.1 = [82 x i8] c"Iteration %u, align = %u, offset = %u, size = %u (oldsize = %u), errno = %d (%s)\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [19 x i8] c"Misaligned block!\0A\00"
@.str.3 = [18 x i8] c"Miscopied block!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [1000 x i8*]
%2 = bitcast [1000 x i8*]* %1 to i8*
%3 = alloca [1000 x i64]
%4 = bitcast [1000 x i64]* %3 to i8*
%5 = alloca [6 x i64]
%6 = alloca [20 x i64]
%7 = bitcast [6 x i64]* %5 to i8*
%8 = bitcast [6 x i64]* %5 to <2 x i64>*
store <2 x i64> <i64 2, i64 4>, <2 x i64>* %8
%9 = getelementptr inbounds [6 x i64], [6 x i64]* %5, i64 0, i64 2
%10 = bitcast i64* %9 to <2 x i64>*
store <2 x i64> <i64 8, i64 16>, <2 x i64>* %10
%11 = getelementptr inbounds [6 x i64], [6 x i64]* %5, i64 0, i64 4
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 32, i64 64>, <2 x i64>* %12
%13 = bitcast [20 x i64]* %6 to i8*
%14 = tail call i32 @time(i32* null)
%15 = tail call i32 @srand(i32 %14)
br label %16
16: ; preds = %0, %16
%17 = phi i64 [ 0, %0 ], [ %22, %16 ]
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 512
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20 x i64], [20 x i64]* %6, i64 0, i64 %17
store i64 %20, i64* %21
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, 20
br i1 %23, label %24, label %16
24: ; preds = %16, %98
%25 = phi i32 [ %99, %98 ], [ 0, %16 ]
%26 = tail call i32 (...) @rand()
%27 = sext i32 %26 to i64
%28 = urem i64 %27, 1000
%29 = getelementptr inbounds [1000 x i64], [1000 x i64]* %3, i64 0, i64 %28
%30 = load i64, i64* %29
%31 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %1, i64 0, i64 %28
%32 = load i8*, i8** %31
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 2
%35 = sext i32 %34 to i64
store i64 %35, i64* %29
%36 = trunc i64 %28 to i16
%37 = urem i16 %36, 6
%38 = zext i16 %37 to i64
%39 = getelementptr inbounds [6 x i64], [6 x i64]* %5, i64 0, i64 %38
%40 = load i64, i64* %39
%41 = urem i16 %36, 20
%42 = zext i16 %41 to i64
%43 = getelementptr inbounds [20 x i64], [20 x i64]* %6, i64 0, i64 %42
%44 = load i64, i64* %43
%45 = tail call i8* @__mingw_aligned_offset_realloc(i8* %32, i64 %35, i64 %40, i64 %44)
store i8* %45, i8** %31
%46 = icmp ne i32 %34, 0
%47 = icmp eq i8* %45, null
%48 = select i1 %46, i1 %47, i1 false
br i1 %48, label %49, label %56
49: ; preds = %24
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = tail call i8* @strerror(i32 %53)
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %25, i64 %40, i64 %44, i64 %35, i64 %30, i32 %53, i8* %54)
br label %108
56: ; preds = %24
%57 = icmp eq i32 %34, 0
br i1 %57, label %68, label %58
58: ; preds = %56
%59 = tail call i32 @is_aligned(i8* %45, i64 %40, i64 %44)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %68
61: ; preds = %58
%62 = load i32, i32* @stderr
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%64 = load i32, i32* @stderr
%65 = load i32, i32* @errno
%66 = tail call i8* @strerror(i32 %65)
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %25, i64 %40, i64 %44, i64 %35, i64 %30, i32 %65, i8* %66)
br label %108
68: ; preds = %58, %56
%69 = icmp ugt i64 %30, %35
%70 = select i1 %69, i64 %35, i64 %30
%71 = icmp eq i64 %70, 0
br i1 %71, label %76, label %77
72: ; preds = %77
%73 = add nuw nsw i64 %78, 1
%74 = and i64 %73, 4294967295
%75 = icmp ugt i64 %70, %74
br i1 %75, label %77, label %76
76: ; preds = %72, %68
br i1 %57, label %98, label %91
77: ; preds = %68, %72
%78 = phi i64 [ %74, %72 ], [ 0, %68 ]
%79 = trunc i64 %78 to i32
%80 = getelementptr inbounds i8, i8* %45, i64 %78
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = icmp eq i32 %79, %82
br i1 %83, label %72, label %84
84: ; preds = %77
%85 = load i32, i32* @stderr
%86 = tail call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%87 = load i32, i32* @stderr
%88 = load i32, i32* @errno
%89 = tail call i8* @strerror(i32 %88)
%90 = tail call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %25, i64 %40, i64 %44, i64 %35, i64 %70, i32 %88, i8* %89)
br label %108
91: ; preds = %76, %91
%92 = phi i64 [ %96, %91 ], [ 0, %76 ]
%93 = trunc i64 %92 to i8
%94 = getelementptr inbounds i8, i8* %45, i64 %92
store i8 %93, i8* %94
%95 = add nuw nsw i64 %92, 1
%96 = and i64 %95, 4294967295
%97 = icmp ult i64 %96, %35
br i1 %97, label %91, label %98
98: ; preds = %91, %76
%99 = add nuw nsw i32 %25, 1
%100 = icmp eq i32 %99, 100000
br i1 %100, label %101, label %24
101: ; preds = %98, %101
%102 = phi i64 [ %106, %101 ], [ 0, %98 ]
%103 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %1, i64 0, i64 %102
%104 = load i8*, i8** %103
%105 = tail call i32 @__mingw_aligned_free(i8* %104)
%106 = add nuw nsw i64 %102, 1
%107 = icmp eq i64 %106, 1000
br i1 %107, label %108, label %101
108: ; preds = %101, %49, %61, %84
%109 = phi i32* [ @EXIT_FAILURE, %49 ], [ @EXIT_FAILURE, %61 ], [ @EXIT_FAILURE, %84 ], [ @EXIT_SUCCESS, %101 ]
%110 = load i32, i32* %109
ret i32 %110
}