// File: Gammelkebab[P]GameOfLife/src/actors/worker.cpp
// Function: Worker::Worker(World*, int)
Worker::Worker(World *world, int proc_num) : Actor(world, proc_num)
{
    block = new Active_block(world, proc_num);

    /* Borders */
    border_send_buffers = new unsigned char **[world->total_rounds];
    for (int r = 0; r < world->total_rounds; r++)
    {
        border_send_buffers[r] = new unsigned char *[Border_direction_count];
        for (int i = Border_direction_first; i <= Border_direction_last; i++)
        {
            Border_direction dir = (Border_direction)i;
            int buffer_size = block->get_border_size(dir);
            border_send_buffers[r][dir] = new unsigned char[buffer_size];
        }
    }
    border_send_requests = new MPI_Request *[world->total_rounds];
    for (int r = 0; r < world->total_rounds; r++)
    {
        border_send_requests[r] = new MPI_Request[Border_direction_count];
    }

    /* Block sends */
    block_send_buffers = new unsigned char *[world->total_rounds];
    for (int r = 0; r < world->total_rounds; r++)
    {
        block_send_buffers[r] = new unsigned char[block->width_byte * block->height];
    }
    block_send_requests = new MPI_Request[world->total_rounds];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x50(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xd8d0
movq -0x50(%rbp), %rax
leaq 0x91be(%rip), %rcx      # 0x16d00
movq %rcx, (%rax)
movl $0x40, %edi
callq 0x85a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xe760
jmp 0xdb67
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movslq 0x28(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x38(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xdc5e
movl $0x40, %edi
callq 0x8030
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x2c(%rbp)
cmpl $0x7, -0x2c(%rbp)
jg 0xdc4e
movq -0x50(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, -0x30(%rbp)
movq 0x20(%rax), %rdi
movl -0x30(%rbp), %esi
callq 0xe980
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rdi
callq 0x8030
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x30(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xdbe2
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x40, %esi
callq 0x85c0
jmp 0xdd87
jmp 0xdc50
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xdbae
movq -0x10(%rbp), %rax
movslq 0x28(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xdccd
movl $0x40, %edi
callq 0x8030
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdc99
movq -0x10(%rbp), %rax
movslq 0x28(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xdd4d
movq -0x50(%rbp), %rcx
movq 0x20(%rcx), %rax
movl 0x24(%rax), %eax
movq 0x20(%rcx), %rcx
imull 0x20(%rcx), %eax
movslq %eax, %rdi
callq 0x8030
movq %rax, %rdx
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xdd08
movq -0x10(%rbp), %rax
movslq 0x28(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x30(%rax)
addq $0x50, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x8a40