#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 */
struct timespec {
  long tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int anneal(int, int *, int *, int, int, int *);
int /*<<< orphan*/ census(char *, int, int *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fill(int, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int, int, int,
                           int, int);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ path_mutate(int *, int *, int, int, int *);
int penalty(int *, int *, int, int *);
int /*<<< orphan*/ printf(char *, int, int /*<<< orphan*/, long);
int random();
int /*<<< orphan*/ show(int /*<<< orphan*/, int, int, int *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ timespec_subtract(struct timespec *, struct timespec *,
                                     struct timespec *);
void evolution(int size, int asteps, int *lhs, int *rhs, int mcount,
               int mwidth) {
  int s = mcount * mwidth * mwidth;
  int *pop = malloc(size * s * sizeof(int));
  int *pen = malloc(size * sizeof(int));
  int *age = malloc(size * sizeof(int));
  for (int p = 0; p < size; p++) {
    int *individuum = pop + p * mcount * mwidth * mwidth;
    for (int c = 0; c < mcount; c++) {
      fill(mwidth, individuum + c * mwidth * mwidth);
    }
    pen[p] = penalty(lhs, rhs, mwidth, individuum);
    age[p] = 0;
  }
  int globally_best = pen[0];
  struct timespec before, after, elapsed;
  clock_gettime(CLOCK_MONOTONIC, &before);
  for (int step = 0;; step++) {
    int parent = random() % size;
    int *individuum = malloc(s * sizeof(int));
    memcpy(individuum, pop + parent * s, s * sizeof(int));
    path_mutate(lhs, rhs, mcount, mwidth, individuum);
    int best = anneal(asteps, lhs, rhs, mcount, mwidth, individuum);
    int child = random() % size;
    if (best < pen[child]) {
      if (best < globally_best) {
        fprintf(stdout,
                "step %5d: parent from %d with fit %d age %d replaces child at "
                "%d with fit %d age %d\n",
                step, parent, best, age[parent], child, pen[child], age[child]);
        globally_best = best;
      }
      memcpy(pop + child * s, individuum, s * sizeof(int));
      pen[child] = best;
      age[child] = age[parent] + 1;
    }
    if (0 == best) {
      show(stdout, mcount, mwidth, individuum);
      exit(0);
    }
    if (0 == step % 1000) {
      clock_gettime(CLOCK_MONOTONIC, &after);
      timespec_subtract(&elapsed, &after, &before);
      printf("step %d need %ld.%03lds\n", step, elapsed.tv_sec,
             elapsed.tv_nsec / (long int)1e6);
      census("penalty", size, pen);
      census("age", size, age);
      clock_gettime(CLOCK_MONOTONIC, &before);
    }
    free(individuum);
  }
  free(age);
  free(pop);
}


x86 assembly (clang, -O0):
<evolution>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1310 <evolution+0x120>
mov    -0x30(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x20(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12d2 <evolution+0xe2>
mov    -0x20(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1090 <fill@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1298 <evolution+0xa8>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x50(%rbp),%rcx
call   10c0 <penalty@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1264 <evolution+0x74>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
lea    -0x68(%rbp),%rsi
call   1040 <clock_gettime@plt>
movl   $0x0,-0x8c(%rbp)
mov    $0x0,%al
call   10d0 <random@plt>
cltd
idivl  -0x4(%rbp)
mov    %edx,-0x90(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x90(%rbp),%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   10b0 <memcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x98(%rbp),%r8
call   10f0 <path_mutate@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x98(%rbp),%r9
call   1100 <anneal@plt>
mov    %eax,-0x9c(%rbp)
mov    $0x0,%al
call   10d0 <random@plt>
cltd
idivl  -0x4(%rbp)
mov    %edx,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
mov    -0x38(%rbp),%rcx
movslq -0xa0(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    14d2 <evolution+0x2e2>
mov    -0x9c(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    1472 <evolution+0x282>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
mov    -0x8c(%rbp),%edx
mov    -0x90(%rbp),%ecx
mov    -0x9c(%rbp),%r8d
mov    -0x40(%rbp),%rax
movslq -0x90(%rbp),%rsi
mov    (%rax,%rsi,4),%r9d
mov    -0xa0(%rbp),%r11d
mov    -0x38(%rbp),%rax
movslq -0xa0(%rbp),%rsi
mov    (%rax,%rsi,4),%r10d
mov    -0x40(%rbp),%rax
movslq -0xa0(%rbp),%rsi
mov    (%rax,%rsi,4),%eax
lea    0xba9(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   10a0 <fprintf@plt>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0xa0(%rbp),%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x98(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   10b0 <memcpy@plt>
mov    -0x9c(%rbp),%edx
mov    -0x38(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
movslq -0x90(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    -0x40(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %eax,%eax
cmp    -0x9c(%rbp),%eax
jne    1502 <evolution+0x312>
mov    0x2af1(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x98(%rbp),%rcx
call   1080 <show@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x8c(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    15ad <evolution+0x3bd>
mov    0x2ac7(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
call   1040 <clock_gettime@plt>
lea    -0x88(%rbp),%rdi
lea    -0x78(%rbp),%rsi
lea    -0x68(%rbp),%rdx
call   1050 <timespec_subtract@plt>
mov    -0x8c(%rbp),%esi
mov    -0x80(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x88(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    -0xa4(%rbp),%edx
mov    %rax,%rcx
lea    0xae5(%rip),%rdi
call   1070 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x38(%rbp),%rdx
lea    0xaeb(%rip),%rdi
call   1060 <census@plt>
mov    -0x4(%rbp),%esi
mov    -0x40(%rbp),%rdx
lea    0xae0(%rip),%rdi
call   1060 <census@plt>
mov    0x2a46(%rip),%rax
mov    (%rax),%edi
lea    -0x68(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1335 <evolution+0x145>

x86 assembly (clang, -O2):
<evolution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9d,%r15d
mov    %rcx,0x60(%rsp)
mov    %rdx,0x58(%rsp)
mov    %esi,0x48(%rsp)
mov    %edi,%r14d
mov    %r9d,%ebx
imul   %r9d,%ebx
mov    %ebx,%ecx
mov    %r8d,(%rsp)
imul   %r8d,%ecx
lea    0x0(,%r14,4),%ebp
mov    %ebp,%edi
mov    %rcx,0x30(%rsp)
imul   %ecx,%edi
call   10e0 <malloc@plt>
mov    %rax,0x40(%rsp)
mov    %ebp,%edi
call   10e0 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %ebp,%edi
call   10e0 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %r14,0x38(%rsp)
test   %r14d,%r14d
jle    1304 <evolution+0x114>
mov    0x38(%rsp),%eax
mov    %rax,0x18(%rsp)
mov    (%rsp),%eax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
jmp    12b6 <evolution+0xc6>
xchg   %ax,%ax
mov    0x58(%rsp),%rdi
mov    0x60(%rsp),%rsi
mov    %r15d,%edx
mov    %rbp,%rcx
call   10c0 <penalty@plt>
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx,%r13,4)
mov    0x28(%rsp),%rax
movl   $0x0,(%rax,%r13,4)
add    $0x1,%r13
cmp    0x18(%rsp),%r13
je     1304 <evolution+0x114>
mov    0x30(%rsp),%rax
imul   %r13d,%eax
cltq
mov    0x40(%rsp),%rcx
lea    (%rcx,%rax,4),%rbp
cmpl   $0x0,(%rsp)
jle    1280 <evolution+0x90>
xor    %r12d,%r12d
mov    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
movslq %r12d,%r12
lea    0x0(,%r12,4),%rsi
add    %rbp,%rsi
mov    %r15d,%edi
call   1090 <fill@plt>
add    %ebx,%r12d
add    $0xffffffffffffffff,%r14
jne    12e0 <evolution+0xf0>
jmp    1280 <evolution+0x90>
mov    0x10(%rsp),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
lea    0x78(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    0x30(%rsp),%rax
lea    0x0(,%rax,4),%eax
mov    %eax,0x24(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
jmp    136a <evolution+0x17a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
add    $0x1,%r13d
mov    %r13d,0x4(%rsp)
add    $0xffffffff,%ebp
mov    %ebp,0x8(%rsp)
xor    %eax,%eax
call   10d0 <random@plt>
cltd
mov    0x38(%rsp),%r12
idiv   %r12d
mov    %edx,%ebp
mov    0x24(%rsp),%ebx
mov    %ebx,%edi
call   10e0 <malloc@plt>
mov    %rax,%r13
mov    %ebp,0x4c(%rsp)
imul   0x30(%rsp),%ebp
movslq %ebp,%rax
mov    0x40(%rsp),%rcx
lea    (%rcx,%rax,4),%rsi
mov    %r13,%rdi
mov    %ebx,%edx
call   10b0 <memcpy@plt>
mov    0x58(%rsp),%r14
mov    %r14,%rdi
mov    0x60(%rsp),%rbp
mov    %rbp,%rsi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r13,%r8
call   10f0 <path_mutate@plt>
mov    0x48(%rsp),%edi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    %ebx,%ecx
mov    %r15d,%r8d
mov    %r13,0x18(%rsp)
mov    %r13,%r9
call   1100 <anneal@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   10d0 <random@plt>
cltd
idiv   %r12d
movslq %edx,%rbx
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,4),%eax
cmp    %eax,%r14d
jge    1460 <evolution+0x270>
mov    0x4c(%rsp),%edx
cmp    0x20(%rsp),%r14d
jge    1480 <evolution+0x290>
mov    0x2bc3(%rip),%rcx
mov    (%rcx),%edi
mov    %edx,%ecx
movslq %edx,%rdx
mov    0x28(%rsp),%r12
mov    %rdx,0x50(%rsp)
mov    (%r12,%rdx,4),%r9d
mov    (%r12,%rbx,4),%r10d
sub    $0x8,%rsp
lea    0xbc7(%rip),%rsi
mov    0xc(%rsp),%r13d
mov    %r13d,%edx
mov    %r14d,%r8d
push   %r10
push   %rax
push   %rbx
call   10a0 <fprintf@plt>
add    $0x20,%rsp
mov    %r14d,0x20(%rsp)
mov    0x8(%rsp),%ebp
jmp    1496 <evolution+0x2a6>
nopl   0x0(%rax)
mov    0x28(%rsp),%r12
mov    0x8(%rsp),%ebp
mov    0x4(%rsp),%r13d
test   %r14d,%r14d
jne    14d8 <evolution+0x2e8>
jmp    1597 <evolution+0x3a7>
nopl   0x0(%rax,%rax,1)
movslq %edx,%rax
mov    %rax,0x50(%rsp)
mov    0x28(%rsp),%r12
mov    0x8(%rsp),%ebp
mov    0x4(%rsp),%r13d
mov    %ebx,%eax
imul   0x30(%rsp),%eax
cltq
mov    0x40(%rsp),%rcx
lea    (%rcx,%rax,4),%rdi
mov    0x18(%rsp),%rsi
mov    0x24(%rsp),%edx
call   10b0 <memcpy@plt>
mov    0x10(%rsp),%rax
mov    %r14d,(%rax,%rbx,4)
mov    0x50(%rsp),%rax
mov    (%r12,%rax,4),%eax
add    $0x1,%eax
mov    %eax,(%r12,%rbx,4)
test   %r14d,%r14d
je     1597 <evolution+0x3a7>
mov    %r13d,%eax
imul   $0x10624dd3,%rax,%rax
shr    $0x26,%rax
imul   $0x3e8,%eax,%eax
add    %ebp,%eax
jne    1350 <evolution+0x160>
mov    0x2aed(%rip),%r14
mov    (%r14),%edi
lea    0x88(%rsp),%rbx
mov    %rbx,%rsi
mov    %r12,%r14
call   1040 <clock_gettime@plt>
lea    0x68(%rsp),%rdi
mov    %rbx,%rsi
lea    0x78(%rsp),%r12
mov    %r12,%rdx
call   1050 <timespec_subtract@plt>
movabs $0x431bde82d7b634db,%rax
de 1b 43
imulq  0x68(%rsp)
mov    0x70(%rsp),%eax
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x12,%rdx
add    %rdx,%rcx
lea    0xb07(%rip),%rdi
mov    %r13d,%esi
mov    %eax,%edx
call   1070 <printf@plt>
lea    0xb0f(%rip),%rdi
mov    0x38(%rsp),%rbx
mov    %ebx,%esi
mov    0x10(%rsp),%rdx
call   1060 <census@plt>
lea    0xaff(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
call   1060 <census@plt>
mov    0x2a60(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
jmp    1350 <evolution+0x160>
mov    0x2a3a(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%esi
mov    %r15d,%edx
mov    0x18(%rsp),%rcx
call   1080 <show@plt>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i64, i32 }
@CLOCK_MONOTONIC = global i32 0
@stdout = global i32 0
@.str = [85 x i8] c"step %5d: parent from %d with fit %d age %d replaces child at %d with fit %d age %d\0A\00"
@.str.1 = [25 x i8] c"step %d need %ld.%03lds\0A\00"
@.str.2 = [8 x i8] c"penalty\00"
@.str.3 = [4 x i8] c"age\00"
define void @evolution(i32 %0, i32 %1, i32* %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i32
%21 = alloca %struct.timespec
%22 = alloca %struct.timespec
%23 = alloca %struct.timespec
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32*
%27 = alloca i32
%28 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%29 = load i32, i32* %11
%30 = load i32, i32* %12
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %12
%33 = mul nsw i32 %31, %32
store i32 %33, i32* %13
%34 = load i32, i32* %7
%35 = load i32, i32* %13
%36 = mul nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = trunc i64 %38 to i32
%40 = call i32* @malloc(i32 %39)
store i32* %40, i32** %14
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = mul i64 %42, 4
%44 = trunc i64 %43 to i32
%45 = call i32* @malloc(i32 %44)
store i32* %45, i32** %15
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 4
%49 = trunc i64 %48 to i32
%50 = call i32* @malloc(i32 %49)
store i32* %50, i32** %16
store i32 0, i32* %17
br label %51
51: ; preds = %98, %6
%52 = load i32, i32* %17
%53 = load i32, i32* %7
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %101
55: ; preds = %51
%56 = load i32*, i32** %14
%57 = load i32, i32* %17
%58 = load i32, i32* %11
%59 = mul nsw i32 %57, %58
%60 = load i32, i32* %12
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %12
%63 = mul nsw i32 %61, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %56, i64 %64
store i32* %65, i32** %18
store i32 0, i32* %19
br label %66
66: ; preds = %81, %55
%67 = load i32, i32* %19
%68 = load i32, i32* %11
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %84
70: ; preds = %66
%71 = load i32, i32* %12
%72 = load i32*, i32** %18
%73 = load i32, i32* %19
%74 = load i32, i32* %12
%75 = mul nsw i32 %73, %74
%76 = load i32, i32* %12
%77 = mul nsw i32 %75, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %72, i64 %78
%80 = call i32 @fill(i32 %71, i32* %79)
br label %81
81: ; preds = %70
%82 = load i32, i32* %19
%83 = add nsw i32 %82, 1
store i32 %83, i32* %19
br label %66
84: ; preds = %66
%85 = load i32*, i32** %9
%86 = load i32*, i32** %10
%87 = load i32, i32* %12
%88 = load i32*, i32** %18
%89 = call i32 @penalty(i32* %85, i32* %86, i32 %87, i32* %88)
%90 = load i32*, i32** %15
%91 = load i32, i32* %17
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %90, i64 %92
store i32 %89, i32* %93
%94 = load i32*, i32** %16
%95 = load i32, i32* %17
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %94, i64 %96
store i32 0, i32* %97
br label %98
98: ; preds = %84
%99 = load i32, i32* %17
%100 = add nsw i32 %99, 1
store i32 %100, i32* %17
br label %51
101: ; preds = %51
%102 = load i32*, i32** %15
%103 = getelementptr inbounds i32, i32* %102, i64 0
%104 = load i32, i32* %103
store i32 %104, i32* %20
%105 = load i32, i32* @CLOCK_MONOTONIC
%106 = call i32 @clock_gettime(i32 %105, %struct.timespec* %21)
store i32 0, i32* %24
br label %107
107: ; preds = %242, %101
%108 = call i32 (...) @random()
%109 = load i32, i32* %7
%110 = srem i32 %108, %109
store i32 %110, i32* %25
%111 = load i32, i32* %13
%112 = sext i32 %111 to i64
%113 = mul i64 %112, 4
%114 = trunc i64 %113 to i32
%115 = call i32* @malloc(i32 %114)
store i32* %115, i32** %26
%116 = load i32*, i32** %26
%117 = load i32*, i32** %14
%118 = load i32, i32* %25
%119 = load i32, i32* %13
%120 = mul nsw i32 %118, %119
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i32, i32* %117, i64 %121
%123 = load i32, i32* %13
%124 = sext i32 %123 to i64
%125 = mul i64 %124, 4
%126 = trunc i64 %125 to i32
%127 = call i32 @memcpy(i32* %116, i32* %122, i32 %126)
%128 = load i32*, i32** %9
%129 = load i32*, i32** %10
%130 = load i32, i32* %11
%131 = load i32, i32* %12
%132 = load i32*, i32** %26
%133 = call i32 @path_mutate(i32* %128, i32* %129, i32 %130, i32 %131, i32* %132)
%134 = load i32, i32* %8
%135 = load i32*, i32** %9
%136 = load i32*, i32** %10
%137 = load i32, i32* %11
%138 = load i32, i32* %12
%139 = load i32*, i32** %26
%140 = call i32 @anneal(i32 %134, i32* %135, i32* %136, i32 %137, i32 %138, i32* %139)
store i32 %140, i32* %27
%141 = call i32 (...) @random()
%142 = load i32, i32* %7
%143 = srem i32 %141, %142
store i32 %143, i32* %28
%144 = load i32, i32* %27
%145 = load i32*, i32** %15
%146 = load i32, i32* %28
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i32, i32* %145, i64 %147
%149 = load i32, i32* %148
%150 = icmp slt i32 %144, %149
br i1 %150, label %151, label %206
151: ; preds = %107
%152 = load i32, i32* %27
%153 = load i32, i32* %20
%154 = icmp slt i32 %152, %153
br i1 %154, label %155, label %178
155: ; preds = %151
%156 = load i32, i32* @stdout
%157 = load i32, i32* %24
%158 = load i32, i32* %25
%159 = load i32, i32* %27
%160 = load i32*, i32** %16
%161 = load i32, i32* %25
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i32, i32* %160, i64 %162
%164 = load i32, i32* %163
%165 = load i32, i32* %28
%166 = load i32*, i32** %15
%167 = load i32, i32* %28
%168 = sext i32 %167 to i64
%169 = getelementptr inbounds i32, i32* %166, i64 %168
%170 = load i32, i32* %169
%171 = load i32*, i32** %16
%172 = load i32, i32* %28
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds i32, i32* %171, i64 %173
%175 = load i32, i32* %174
%176 = call i32 @fprintf(i32 %156, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0), i32 %157, i32 %158, i32 %159, i32 %164, i32 %165, i32 %170, i32 %175)
%177 = load i32, i32* %27
store i32 %177, i32* %20
br label %178
178: ; preds = %155, %151
%179 = load i32*, i32** %14
%180 = load i32, i32* %28
%181 = load i32, i32* %13
%182 = mul nsw i32 %180, %181
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i32, i32* %179, i64 %183
%185 = load i32*, i32** %26
%186 = load i32, i32* %13
%187 = sext i32 %186 to i64
%188 = mul i64 %187, 4
%189 = trunc i64 %188 to i32
%190 = call i32 @memcpy(i32* %184, i32* %185, i32 %189)
%191 = load i32, i32* %27
%192 = load i32*, i32** %15
%193 = load i32, i32* %28
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds i32, i32* %192, i64 %194
store i32 %191, i32* %195
%196 = load i32*, i32** %16
%197 = load i32, i32* %25
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds i32, i32* %196, i64 %198
%200 = load i32, i32* %199
%201 = add nsw i32 %200, 1
%202 = load i32*, i32** %16
%203 = load i32, i32* %28
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds i32, i32* %202, i64 %204
store i32 %201, i32* %205
br label %206
206: ; preds = %178, %107
%207 = load i32, i32* %27
%208 = icmp eq i32 0, %207
br i1 %208, label %209, label %216
209: ; preds = %206
%210 = load i32, i32* @stdout
%211 = load i32, i32* %11
%212 = load i32, i32* %12
%213 = load i32*, i32** %26
%214 = call i32 @show(i32 %210, i32 %211, i32 %212, i32* %213)
%215 = call i32 @exit(i32 0)
unreachable
216: ; preds = %206
%217 = load i32, i32* %24
%218 = srem i32 %217, 1000
%219 = icmp eq i32 0, %218
br i1 %219, label %220, label %239
220: ; preds = %216
%221 = load i32, i32* @CLOCK_MONOTONIC
%222 = call i32 @clock_gettime(i32 %221, %struct.timespec* %22)
%223 = call i32 @timespec_subtract(%struct.timespec* %23, %struct.timespec* %22, %struct.timespec* %21)
%224 = load i32, i32* %24
%225 = getelementptr inbounds %struct.timespec, %struct.timespec* %23, i32 0, i32 1
%226 = load i32, i32* %225
%227 = getelementptr inbounds %struct.timespec, %struct.timespec* %23, i32 0, i32 0
%228 = load i64, i64* %227
%229 = sdiv i64 %228, 1000000
%230 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %224, i32 %226, i64 %229)
%231 = load i32, i32* %7
%232 = load i32*, i32** %15
%233 = call i32 @census(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %231, i32* %232)
%234 = load i32, i32* %7
%235 = load i32*, i32** %16
%236 = call i32 @census(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %234, i32* %235)
%237 = load i32, i32* @CLOCK_MONOTONIC
%238 = call i32 @clock_gettime(i32 %237, %struct.timespec* %21)
br label %239
239: ; preds = %220, %216
%240 = load i32*, i32** %26
%241 = call i32 @free(i32* %240)
br label %242
242: ; preds = %239
%243 = load i32, i32* %24
%244 = add nsw i32 %243, 1
store i32 %244, i32* %24
br label %107
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32 }
@CLOCK_MONOTONIC = global i32 0
@stdout = global i32 0
@.str = [85 x i8] c"step %5d: parent from %d with fit %d age %d replaces child at %d with fit %d age %d\0A\00"
@.str.1 = [25 x i8] c"step %d need %ld.%03lds\0A\00"
@.str.2 = [8 x i8] c"penalty\00"
@.str.3 = [4 x i8] c"age\00"
define void @evolution(i32 %0, i32 %1, i32* %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca %struct.timespec
%8 = alloca %struct.timespec
%9 = alloca %struct.timespec
%10 = mul i32 %5, %5
%11 = mul i32 %10, %4
%12 = shl i32 %0, 2
%13 = mul i32 %12, %11
%14 = tail call i32* @malloc(i32 %13)
%15 = tail call i32* @malloc(i32 %12)
%16 = tail call i32* @malloc(i32 %12)
%17 = icmp sgt i32 %0, 0
br i1 %17, label %18, label %22
18: ; preds = %6
%19 = icmp sgt i32 %4, 0
%20 = zext i32 %0 to i64
%21 = zext i32 %4 to i64
br label %32
22: ; preds = %38, %6
%23 = load i32, i32* %15
%24 = bitcast %struct.timespec* %7 to i8*
%25 = bitcast %struct.timespec* %8 to i8*
%26 = bitcast %struct.timespec* %9 to i8*
%27 = load i32, i32* @CLOCK_MONOTONIC
%28 = call i32 @clock_gettime(i32 %27, %struct.timespec* %7)
%29 = shl i32 %11, 2
%30 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i64 0, i32 1
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i64 0, i32 0
br label %53
32: ; preds = %18, %38
%33 = phi i64 [ 0, %18 ], [ %42, %38 ]
%34 = trunc i64 %33 to i32
%35 = mul i32 %11, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %14, i64 %36
br i1 %19, label %44, label %38
38: ; preds = %44, %32
%39 = tail call i32 @penalty(i32* %2, i32* %3, i32 %5, i32* %37)
%40 = getelementptr inbounds i32, i32* %15, i64 %33
store i32 %39, i32* %40
%41 = getelementptr inbounds i32, i32* %16, i64 %33
store i32 0, i32* %41
%42 = add nuw nsw i64 %33, 1
%43 = icmp eq i64 %42, %20
br i1 %43, label %22, label %32
44: ; preds = %32, %44
%45 = phi i64 [ %51, %44 ], [ 0, %32 ]
%46 = trunc i64 %45 to i32
%47 = mul i32 %10, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %37, i64 %48
%50 = tail call i32 @fill(i32 %5, i32* %49)
%51 = add nuw nsw i64 %45, 1
%52 = icmp eq i64 %51, %21
br i1 %52, label %38, label %44
53: ; preds = %116, %22
%54 = phi i32 [ 0, %22 ], [ %118, %116 ]
%55 = phi i32 [ %23, %22 ], [ %95, %116 ]
%56 = call i32 (...) @random()
%57 = srem i32 %56, %0
%58 = call i32* @malloc(i32 %29)
%59 = mul nsw i32 %57, %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %14, i64 %60
%62 = call i32 @memcpy(i32* %58, i32* %61, i32 %29)
%63 = call i32 @path_mutate(i32* %2, i32* %3, i32 %4, i32 %5, i32* %58)
%64 = call i32 @anneal(i32 %1, i32* %2, i32* %3, i32 %4, i32 %5, i32* %58)
%65 = call i32 (...) @random()
%66 = srem i32 %65, %0
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %15, i64 %67
%69 = load i32, i32* %68
%70 = icmp slt i32 %64, %69
br i1 %70, label %71, label %94
71: ; preds = %53
%72 = icmp slt i32 %64, %55
br i1 %72, label %75, label %73
73: ; preds = %71
%74 = sext i32 %57 to i64
br label %83
75: ; preds = %71
%76 = load i32, i32* @stdout
%77 = sext i32 %57 to i64
%78 = getelementptr inbounds i32, i32* %16, i64 %77
%79 = load i32, i32* %78
%80 = getelementptr inbounds i32, i32* %16, i64 %67
%81 = load i32, i32* %80
%82 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0), i32 %54, i32 %57, i32 %64, i32 %79, i32 %66, i32 %69, i32 %81)
br label %83
83: ; preds = %73, %75
%84 = phi i64 [ %74, %73 ], [ %77, %75 ]
%85 = phi i32 [ %55, %73 ], [ %64, %75 ]
%86 = mul nsw i32 %66, %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %14, i64 %87
%89 = call i32 @memcpy(i32* %88, i32* %58, i32 %29)
store i32 %64, i32* %68
%90 = getelementptr inbounds i32, i32* %16, i64 %84
%91 = load i32, i32* %90
%92 = add nsw i32 %91, 1
%93 = getelementptr inbounds i32, i32* %16, i64 %67
store i32 %92, i32* %93
br label %94
94: ; preds = %83, %53
%95 = phi i32 [ %85, %83 ], [ %55, %53 ]
%96 = icmp eq i32 %64, 0
br i1 %96, label %97, label %101
97: ; preds = %94
%98 = load i32, i32* @stdout
%99 = call i32 @show(i32 %98, i32 %4, i32 %5, i32* %58)
%100 = call i32 @exit(i32 0)
unreachable
101: ; preds = %94
%102 = urem i32 %54, 1000
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %116
104: ; preds = %101
%105 = load i32, i32* @CLOCK_MONOTONIC
%106 = call i32 @clock_gettime(i32 %105, %struct.timespec* %8)
%107 = call i32 @timespec_subtract(%struct.timespec* %9, %struct.timespec* %8, %struct.timespec* %7)
%108 = load i32, i32* %30
%109 = load i64, i64* %31
%110 = sdiv i64 %109, 1000000
%111 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %108, i64 %110)
%112 = call i32 @census(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32* %15)
%113 = call i32 @census(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %0, i32* %16)
%114 = load i32, i32* @CLOCK_MONOTONIC
%115 = call i32 @clock_gettime(i32 %114, %struct.timespec* %7)
br label %116
116: ; preds = %104, %101
%117 = call i32 @free(i32* %58)
%118 = add nuw nsw i32 %54, 1
br label %53
}