// File: Quinny[P]IteratedPrisoners/./ipd/hill_climb.h
// Function: ipd::hill_climb::restart_climb(ipd::prisoner_t, int, std::function<std::vector<std::pair<ipd::prisoner_t, int>, std::allocator<std::pair<ipd::prisoner_t, int>>> (std::vector<ipd::prisoner_t, std::allocator<ipd::prisoner_t>> const&)>, int)
prisoner_t restart_climb(
    prisoner_t init,
    const int rate,
    genetic::fitness_fn fitness_func,
    int restarts
) {
    std::vector<prisoner_t> candidates;

    do {
        candidates.push_back(climb(init, rate, fitness_func));
        init = genetic::random_prisoner_t(config::mem_first, config::mem_last);
        --restarts;
    } while (restarts > 0);

    auto eval = fitness_func(candidates);
    auto max = std::max_element(eval.begin(), eval.end(), std::less<score_t>());
    return max->first;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rcx, -0x188(%rbp)
movq %rsi, -0x180(%rbp)
movq %rdi, -0x178(%rbp)
movq %rdi, %rax
movq %rax, -0x170(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xa3f0
movq -0x180(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x9360
jmp 0x7fbb
movq -0x188(%rbp), %rsi
movl -0x14(%rbp), %eax
movl %eax, -0x18c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xb5e0
jmp 0x7fd9
movl -0x18c(%rbp), %edx
leaq -0x80(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0xf0(%rbp), %rcx
callq 0x7c20
jmp 0x7ff8
leaq -0x40(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xa410
jmp 0x8007
leaq -0x80(%rbp), %rdi
callq 0x9450
leaq -0xf0(%rbp), %rdi
callq 0xb690
leaq -0xc0(%rbp), %rdi
callq 0x9450
movslq 0x2a37d(%rip), %rsi     # 0x323ac
movslq 0x2a37a(%rip), %rdx     # 0x323b0
leaq -0x130(%rbp), %rdi
callq 0x68a0
jmp 0x8044
movq -0x180(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xb6b0
leaq -0x130(%rbp), %rdi
callq 0x9450
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jg 0x7fa6
movq -0x188(%rbp), %rsi
leaq -0x148(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0xaa70
jmp 0x808f
leaq -0x148(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x94c0
movq -0x1a0(%rbp), %rdi
movq %rax, -0x158(%rbp)
callq 0x94f0
movq %rax, -0x160(%rbp)
movq -0x158(%rbp), %rdi
movq -0x160(%rbp), %rsi
callq 0xb470
movq %rax, -0x198(%rbp)
jmp 0x80d8
movq -0x198(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x150(%rbp), %rdi
callq 0xb540
movq -0x178(%rbp), %rdi
movq %rax, %rsi
callq 0x9360
jmp 0x8103
leaq -0x148(%rbp), %rdi
callq 0x9520
leaq -0x40(%rbp), %rdi
callq 0x9890
movq -0x170(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x81b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x818b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x817f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x9450
leaq -0xf0(%rbp), %rdi
callq 0xb690
leaq -0xc0(%rbp), %rdi
callq 0x9450
jmp 0x81b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x9520
leaq -0x40(%rbp), %rdi
callq 0x9890
movq -0xc8(%rbp), %rdi
callq 0x45c0
nopl (%rax)