// File: eugene87222[P]Game-of-Life/gol.cpp
// Function: update_thd(int, int, int, int)
void update_thd(int h_begin, int h_end, int w_begin, int w_end) {
    for(int i = h_begin; i <= h_end; i++) {
        for(int j = w_begin; j <= w_end; j++) {
            int alive = board[i-1][j-1] + board[i-1][j] + board[i-1][j+1] + 
                        board[i][j-1] + board[i][j+1] + 
                        board[i+1][j-1] + board[i+1][j] + board[i+1][j+1];
            if(board[i][j] == 1) {
                if(alive != 2 && alive != 3) {
                    new_board[i][j] = 0;
                }
            }
            else {
                if(alive == 3){
                    new_board[i][j] = 1;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jg 0x3311
movl -0xc(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x3301
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq 0xb068(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x4290
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq 0xb03d(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x4290
movq %rax, %rcx
movl -0x38(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x34(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq 0xb011(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movl -0x18(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4290
movq %rax, %rcx
movl -0x34(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x30(%rbp)
movslq -0x14(%rbp), %rsi
leaq 0xafe5(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x4290
movq %rax, %rcx
movl -0x30(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x2c(%rbp)
movslq -0x14(%rbp), %rsi
leaq 0xafb9(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movl -0x18(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4290
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0xaf88(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x4290
movq %rax, %rcx
movl -0x28(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0xaf57(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x4290
movq %rax, %rcx
movl -0x24(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0xaf2b(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movl -0x18(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4290
movq %rax, %rcx
movl -0x20(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x1c(%rbp)
movslq -0x14(%rbp), %rsi
leaq 0xaeff(%rip), %rdi      # 0xe180
callq 0x4270
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x4290
cmpl $0x1, (%rax)
jne 0x32c7
cmpl $0x2, -0x1c(%rbp)
je 0x32c5
cmpl $0x3, -0x1c(%rbp)
je 0x32c5
movslq -0x14(%rbp), %rsi
leaq 0xaeea(%rip), %rdi      # 0xe198
callq 0x4270
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x4290
movl $0x0, (%rax)
jmp 0x32f1
cmpl $0x3, -0x1c(%rbp)
jne 0x32ef
movslq -0x14(%rbp), %rsi
leaq 0xaec0(%rip), %rdi      # 0xe198
callq 0x4270
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x4290
movl $0x1, (%rax)
jmp 0x32f1
jmp 0x32f3
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x30fc
jmp 0x3303
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x30ea
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)