#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 */

/* Variables and functions */
int count_contig_bits(unsigned short, int);
unsigned short gen_web_stream(unsigned short, int, int);
unsigned short get_back_diag(unsigned long long, unsigned long long, int);
unsigned short get_forward_diag(unsigned long long, unsigned long long, int);
int /*<<< orphan*/ put_back_diag(unsigned long long *, unsigned long long *,
                                 unsigned short, int);
int /*<<< orphan*/ put_forward_diag(unsigned long long *, unsigned long long *,
                                    unsigned short, int);
int gen_web_board_count(unsigned long long *web_l, unsigned long long *web_u,
                        unsigned long long board_l, unsigned long long board_u,
                        int pos) {
  unsigned short row, col, fdiag, bdiag;
  unsigned short web_row, web_col, web_fdiag, web_bdiag;
  int diag;
  int row_count, col_count, fdiag_count, bdiag_count;
  if (pos > 49)
    row = (board_u >> ((int)pos / 10 % 5) * 10) & 0x3ff;
  else
    row = (board_l >> ((int)pos / 10 % 5) * 10) & 0x3ff;
  web_row = gen_web_stream(row, pos % 10, 10);
  row_count = count_contig_bits(web_row, 10);
  if (pos > 49)
    *web_u |= ((unsigned long long)web_row << ((pos / 10 % 5) * 10));
  else
    *web_l |= ((unsigned long long)web_row << ((pos / 10 % 5) * 10));
  col = ((((board_l >> pos % 10) & 0x1) | ((board_l >> (pos % 10 + 9)) & 0x2) |
          ((board_l >> (pos % 10 + 18)) & 0x4) |
          ((board_l >> (pos % 10 + 27)) & 0x8) |
          ((board_l >> (pos % 10 + 36)) & 0x10)) |
         ((((board_u >> pos % 10) & 0x1) | ((board_u >> (pos % 10 + 9)) & 0x2) |
           ((board_u >> (pos % 10 + 18)) & 0x4) |
           ((board_u >> (pos % 10 + 27)) & 0x8) |
           ((board_u >> (pos % 10 + 36)) & 0x10))
          << 5));
  web_col = gen_web_stream(col, (int)pos / 10, 10);
  col_count = count_contig_bits(web_col, 10);
  *web_l |= ((((unsigned long long)web_col & 0x1) << pos % 10) |
             (((unsigned long long)web_col & 0x2) << (pos % 10 + 9)) |
             (((unsigned long long)web_col & 0x4) << (pos % 10 + 18)) |
             (((unsigned long long)web_col & 0x8) << (pos % 10 + 27)) |
             (((unsigned long long)web_col & 0x10) << (pos % 10 + 36)));
  *web_u |= ((((unsigned long long)web_col >> 5 & 0x1) << pos % 10) |
             (((unsigned long long)web_col >> 5 & 0x2) << (pos % 10 + 9)) |
             (((unsigned long long)web_col >> 5 & 0x4) << (pos % 10 + 18)) |
             (((unsigned long long)web_col >> 5 & 0x8) << (pos % 10 + 27)) |
             (((unsigned long long)web_col >> 5 & 0x10) << (pos % 10 + 36)));
  diag =
      (pos % 10 > pos / 10) ? pos - ((pos / 10) * 11) : pos - ((pos % 10) * 11);
  fdiag = get_forward_diag(board_l, board_u, diag);
  web_fdiag = gen_web_stream(fdiag, (pos % 10 > pos / 10) ? pos / 10 : pos % 10,
                             (diag < 10) ? (10 - diag) : (10 - diag / 10));
  fdiag_count = count_contig_bits(web_fdiag,
                                  (diag < 10) ? (10 - diag) : (10 - diag / 10));
  put_forward_diag(web_l, web_u, web_fdiag, diag);
  diag = (pos / 10 < (10 - pos % 10)) ? pos - ((pos / 10) * 9)
                                      : pos - ((9 - (pos % 10)) * 9);
  bdiag = get_back_diag(board_l, board_u, diag);
  web_bdiag = gen_web_stream(
      bdiag, (pos / 10 < (10 - pos % 10)) ? pos / 10 : 9 - pos % 10,
      (diag < 10) ? diag + 1 : (10 - diag / 10));
  bdiag_count =
      count_contig_bits(web_bdiag, (diag < 10) ? diag + 1 : (10 - diag / 10));
  put_back_diag(web_l, web_u, web_bdiag, diag);
  return (row_count + col_count + fdiag_count + bdiag_count - 4);
}


x86 assembly (clang, -O0):
<gen_web_board_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpl   $0x31,-0x24(%rbp)
jle    11bf <gen_web_board_count+0x5f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x50(%rbp),%rax
imul   $0xa,%edx,%ecx
mov    %ecx,%ecx
shr    %cl,%rax
and    $0x3ff,%rax
mov    %ax,-0x26(%rbp)
jmp    11f0 <gen_web_board_count+0x90>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x58(%rbp),%rax
imul   $0xa,%edx,%ecx
mov    %ecx,%ecx
shr    %cl,%rax
and    $0x3ff,%rax
mov    %ax,-0x26(%rbp)
mov    -0x26(%rbp),%ax
mov    %ax,-0x5a(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x5a(%rbp),%ax
mov    %edx,%esi
mov    $0xa,%edx
movzwl %ax,%edi
call   1070 <gen_web_stream@plt>
mov    %ax,-0x2e(%rbp)
mov    $0xa,%esi
movzwl -0x2e(%rbp),%edi
call   1060 <count_contig_bits@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x31,-0x24(%rbp)
jle    126e <gen_web_board_count+0x10e>
movzwl -0x2e(%rbp),%eax
mov    %rax,-0x68(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x68(%rbp),%rax
imul   $0xa,%edx,%ecx
mov    %ecx,%ecx
shl    %cl,%rax
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
jmp    12a2 <gen_web_board_count+0x142>
movzwl -0x2e(%rbp),%eax
mov    %rax,-0x70(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x70(%rbp),%rax
imul   $0xa,%edx,%ecx
mov    %ecx,%ecx
shl    %cl,%rax
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1a8(%rbp),%rax
mov    %edx,%ecx
shr    %cl,%rax
and    $0x1,%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1a0(%rbp),%rax
mov    %edx,%ecx
mov    -0x198(%rbp),%rdx
add    $0x9,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x2,%rcx
or     %rcx,%rax
mov    %rax,-0x190(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x190(%rbp),%rax
mov    %edx,%ecx
mov    -0x188(%rbp),%rdx
add    $0x12,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x4,%rcx
or     %rcx,%rax
mov    %rax,-0x180(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x180(%rbp),%rax
mov    %edx,%ecx
mov    -0x178(%rbp),%rdx
add    $0x1b,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x8,%rcx
or     %rcx,%rax
mov    %rax,-0x170(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x170(%rbp),%rax
mov    %edx,%ecx
mov    -0x168(%rbp),%rdx
add    $0x24,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x10,%rcx
or     %rcx,%rax
mov    %rax,-0x128(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x160(%rbp),%rax
mov    %edx,%ecx
shr    %cl,%rax
and    $0x1,%rax
mov    %rax,-0x158(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x158(%rbp),%rax
mov    %edx,%ecx
mov    -0x150(%rbp),%rdx
add    $0x9,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x2,%rcx
or     %rcx,%rax
mov    %rax,-0x148(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x148(%rbp),%rax
mov    %edx,%ecx
mov    -0x140(%rbp),%rdx
add    $0x12,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x4,%rcx
or     %rcx,%rax
mov    %rax,-0x138(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x138(%rbp),%rax
mov    %edx,%ecx
mov    -0x130(%rbp),%rdx
add    $0x1b,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    %rdx,%rcx
and    $0x8,%rcx
or     %rcx,%rax
mov    %rax,-0x118(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x128(%rbp),%rax
mov    %edx,%ecx
mov    -0x120(%rbp),%rdx
add    $0x24,%ecx
mov    %ecx,%ecx
shr    %cl,%rdx
mov    -0x118(%rbp),%rcx
and    $0x10,%rdx
or     %rdx,%rcx
shl    $0x5,%rcx
or     %rcx,%rax
mov    %ax,-0x28(%rbp)
mov    -0x28(%rbp),%ax
mov    %ax,-0x10a(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10a(%rbp),%ax
mov    $0xa,%edx
movzwl %ax,%edi
call   1070 <gen_web_stream@plt>
mov    %ax,-0x30(%rbp)
mov    $0xa,%esi
movzwl -0x30(%rbp),%edi
call   1060 <count_contig_bits@plt>
mov    %eax,-0x40(%rbp)
movzwl -0x30(%rbp),%eax
and    $0x1,%rax
mov    %rax,-0x108(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x108(%rbp),%rax
mov    %edx,%ecx
shl    %cl,%rax
mov    %rax,-0x100(%rbp)
movzwl -0x30(%rbp),%eax
and    $0x2,%rax
mov    %rax,-0xf8(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x100(%rbp),%rax
mov    %edx,%ecx
mov    -0xf8(%rbp),%rdx
add    $0x9,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0xf0(%rbp)
movzwl -0x30(%rbp),%eax
and    $0x4,%rax
mov    %rax,-0xe8(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0xf0(%rbp),%rax
mov    %edx,%ecx
mov    -0xe8(%rbp),%rdx
add    $0x12,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0xe0(%rbp)
movzwl -0x30(%rbp),%eax
and    $0x8,%rax
mov    %rax,-0xd8(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0xe0(%rbp),%rax
mov    %edx,%ecx
mov    -0xd8(%rbp),%rdx
add    $0x1b,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0xc8(%rbp)
movzwl -0x30(%rbp),%eax
and    $0x10,%rax
mov    %rax,-0xd0(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0xd0(%rbp),%rax
add    $0x24,%edx
mov    %edx,%ecx
shl    %cl,%rax
mov    -0xc8(%rbp),%rcx
or     %rax,%rcx
mov    -0x8(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
movzwl -0x30(%rbp),%eax
shr    $0x5,%rax
and    $0x1,%rax
mov    %rax,-0xc0(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0xc0(%rbp),%rax
mov    %edx,%ecx
shl    %cl,%rax
mov    %rax,-0xb8(%rbp)
movzwl -0x30(%rbp),%eax
shr    $0x5,%rax
and    $0x2,%rax
mov    %rax,-0xb0(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0xb8(%rbp),%rax
mov    %edx,%ecx
mov    -0xb0(%rbp),%rdx
add    $0x9,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0xa8(%rbp)
movzwl -0x30(%rbp),%eax
shr    $0x5,%rax
and    $0x4,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0xa8(%rbp),%rax
mov    %edx,%ecx
mov    -0xa0(%rbp),%rdx
add    $0x12,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x98(%rbp)
movzwl -0x30(%rbp),%eax
shr    $0x5,%rax
and    $0x8,%rax
mov    %rax,-0x90(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x98(%rbp),%rax
mov    %edx,%ecx
mov    -0x90(%rbp),%rdx
add    $0x1b,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x80(%rbp)
movzwl -0x30(%rbp),%eax
shr    $0x5,%rax
and    $0x10,%rax
mov    %rax,-0x88(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x88(%rbp),%rax
add    $0x24,%edx
mov    %edx,%ecx
shl    %cl,%rax
mov    -0x80(%rbp),%rcx
or     %rax,%rcx
mov    -0x10(%rbp),%rax
or     (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x74(%rbp),%edx
cmp    %eax,%edx
jle    17e9 <gen_web_board_count+0x689>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1b0(%rbp),%eax
imul   $0xb,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x1ac(%rbp)
jmp    180e <gen_web_board_count+0x6ae>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1b4(%rbp),%eax
imul   $0xb,%edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1080 <get_forward_diag@plt>
mov    %ax,-0x2a(%rbp)
mov    -0x2a(%rbp),%ax
mov    %ax,-0x1ba(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1b8(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1b8(%rbp),%edx
cmp    %eax,%edx
jle    1878 <gen_web_board_count+0x718>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    %edx,-0x1c0(%rbp)
jmp    1889 <gen_web_board_count+0x729>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c0(%rbp)
mov    -0x1c0(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    18b2 <gen_web_board_count+0x752>
mov    $0xa,%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x1c8(%rbp)
jmp    18cc <gen_web_board_count+0x76c>
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xa,%eax
sub    %ecx,%eax
mov    %eax,-0x1c8(%rbp)
mov    -0x1c4(%rbp),%esi
mov    -0x1ba(%rbp),%ax
mov    -0x1c8(%rbp),%edx
movzwl %ax,%edi
call   1070 <gen_web_stream@plt>
mov    %ax,-0x32(%rbp)
mov    -0x32(%rbp),%ax
mov    %ax,-0x1ca(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1913 <gen_web_board_count+0x7b3>
mov    $0xa,%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x1d0(%rbp)
jmp    192d <gen_web_board_count+0x7cd>
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xa,%eax
sub    %ecx,%eax
mov    %eax,-0x1d0(%rbp)
mov    -0x1ca(%rbp),%ax
mov    -0x1d0(%rbp),%esi
movzwl %ax,%edi
call   1060 <count_contig_bits@plt>
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x32(%rbp),%ax
mov    -0x38(%rbp),%ecx
movzwl %ax,%edx
call   1030 <put_forward_diag@plt>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1d4(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1d4(%rbp),%eax
mov    $0xa,%ecx
sub    %edx,%ecx
cmp    %ecx,%eax
jge    19b9 <gen_web_board_count+0x859>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1dc(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1dc(%rbp),%eax
imul   $0x9,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x1d8(%rbp)
jmp    19e5 <gen_web_board_count+0x885>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1e0(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1e0(%rbp),%eax
mov    $0x9,%ecx
sub    %edx,%ecx
imul   $0x9,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x1d8(%rbp)
mov    -0x1d8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1040 <get_back_diag@plt>
mov    %ax,-0x2c(%rbp)
mov    -0x2c(%rbp),%ax
mov    %ax,-0x1e6(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1e4(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1e4(%rbp),%eax
mov    $0xa,%ecx
sub    %edx,%ecx
cmp    %ecx,%eax
jge    1a54 <gen_web_board_count+0x8f4>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1ec(%rbp)
jmp    1a6c <gen_web_board_count+0x90c>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x9,%eax
sub    %edx,%eax
mov    %eax,-0x1ec(%rbp)
mov    -0x1ec(%rbp),%eax
mov    %eax,-0x1f0(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1a93 <gen_web_board_count+0x933>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f4(%rbp)
jmp    1aad <gen_web_board_count+0x94d>
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xa,%eax
sub    %ecx,%eax
mov    %eax,-0x1f4(%rbp)
mov    -0x1f0(%rbp),%esi
mov    -0x1e6(%rbp),%ax
mov    -0x1f4(%rbp),%edx
movzwl %ax,%edi
call   1070 <gen_web_stream@plt>
mov    %ax,-0x34(%rbp)
mov    -0x34(%rbp),%ax
mov    %ax,-0x1f6(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1af2 <gen_web_board_count+0x992>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fc(%rbp)
jmp    1b0c <gen_web_board_count+0x9ac>
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xa,%eax
sub    %ecx,%eax
mov    %eax,-0x1fc(%rbp)
mov    -0x1f6(%rbp),%ax
mov    -0x1fc(%rbp),%esi
movzwl %ax,%edi
call   1060 <count_contig_bits@plt>
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x34(%rbp),%ax
mov    -0x38(%rbp),%ecx
movzwl %ax,%edx
call   1050 <put_back_diag@plt>
mov    -0x3c(%rbp),%eax
add    -0x40(%rbp),%eax
add    -0x44(%rbp),%eax
add    -0x48(%rbp),%eax
sub    $0x4,%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_web_board_count>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r13
mov    %rdi,0x8(%rsp)
movslq %r8d,%rbp
mov    %r8d,%r12d
cmp    $0x32,%r8d
mov    %rcx,0x30(%rsp)
mov    %rdx,0x10(%rsp)
mov    %r8,0x38(%rsp)
jl     11b6 <gen_web_board_count+0x56>
mov    $0xcccccccd,%esi
mov    %r12,%rax
imul   %rsi,%rax
shr    $0x23,%rax
mov    %rax,%rdx
imul   %rsi,%rdx
shr    $0x22,%rdx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
mov    %rcx,%rdi
jmp    11e8 <gen_web_board_count+0x88>
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x21,%rcx
add    %esi,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %rdx,%rdi
add    %eax,%eax
lea    (%rax,%rax,4),%ecx
shr    %cl,%rdi
imul   $0x66666667,%rbp,%r15
mov    %r15,%rax
shr    $0x3f,%rax
sar    $0x22,%r15
add    %eax,%r15d
lea    (%r15,%r15,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%r14d
sub    %eax,%r14d
and    $0x3ff,%edi
mov    %r14d,%esi
mov    $0xa,%edx
call   1070 <gen_web_stream@plt>
movzwl %ax,%ebx
mov    %ebx,%edi
mov    $0xa,%esi
call   1060 <count_contig_bits@plt>
mov    %rax,0x40(%rsp)
cmp    $0x32,%ebp
mov    %r13,0x18(%rsp)
jl     1274 <gen_web_board_count+0x114>
mov    $0xcccccccd,%eax
imul   %rax,%r12
shr    $0x23,%r12
mov    %r12,%rcx
imul   %rax,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%eax
mov    %r12d,%ecx
sub    %eax,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
shl    %cl,%rbx
or     %rbx,0x0(%r13)
mov    %r12d,%r15d
jmp    12a3 <gen_web_board_count+0x143>
movslq %r15d,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
mov    %r15d,%ecx
sub    %eax,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
shl    %cl,%rbx
mov    0x8(%rsp),%rax
or     %rbx,(%rax)
mov    0x10(%rsp),%rcx
mov    %rcx,%rax
mov    %rcx,%rsi
mov    %r14d,%ecx
shr    %cl,%rax
lea    0x9(%r14),%r9d
mov    %rsi,%rdx
mov    %rsi,%rdi
mov    %r9d,%ecx
mov    %r9d,0x28(%rsp)
shr    %cl,%rdx
and    $0x1,%eax
and    $0x2,%edx
or     %eax,%edx
lea    0x12(%r14),%r8d
mov    %rsi,%rax
mov    %r8d,%ecx
mov    %r8d,0x24(%rsp)
shr    %cl,%rax
and    $0x4,%eax
lea    0x1b(%r14),%ebp
mov    %ebp,%ecx
shr    %cl,%rsi
or     %edx,%eax
and    $0x8,%esi
or     %eax,%esi
lea    0x24(%r14),%ebx
mov    %rdi,%rax
mov    %ebx,%ecx
mov    %ebx,0x20(%rsp)
shr    %cl,%rax
and    $0x10,%eax
or     %esi,%eax
mov    0x30(%rsp),%r13
mov    %r13,%rdx
mov    %r14d,%ecx
shr    %cl,%rdx
and    $0x1,%edx
mov    %r13,%rsi
mov    %r9d,%ecx
shr    %cl,%rsi
and    $0x2,%esi
mov    %r13,%rdi
mov    %r8d,%ecx
shr    %cl,%rdi
or     %edx,%esi
mov    %r13,%rdx
mov    %ebp,%ecx
shr    %cl,%rdx
and    $0x4,%edi
or     %esi,%edi
and    $0x8,%edx
or     %edi,%edx
mov    %r13,%rsi
mov    %ebx,%ecx
shr    %cl,%rsi
and    $0x10,%esi
or     %edx,%esi
shl    $0x5,%esi
or     %eax,%esi
movzwl %si,%edi
mov    %r15d,%esi
mov    $0xa,%edx
call   1070 <gen_web_stream@plt>
movzwl %ax,%r12d
mov    %r12d,%edi
mov    $0xa,%esi
call   1060 <count_contig_bits@plt>
mov    %eax,0x2c(%rsp)
mov    %r12d,%edx
and    $0x1,%edx
mov    %r14d,%ecx
shl    %cl,%rdx
mov    %r12d,%eax
and    $0x2,%eax
mov    0x28(%rsp),%ebx
mov    %ebx,%ecx
shl    %cl,%rax
mov    %r12d,%esi
and    $0x4,%esi
mov    0x24(%rsp),%r8d
mov    %r8d,%ecx
shl    %cl,%rsi
mov    %r12d,%edi
and    $0x8,%edi
mov    %ebp,%r10d
mov    %r10d,%ecx
shl    %cl,%rdi
mov    %r12d,%ebp
and    $0x10,%ebp
mov    0x20(%rsp),%r9d
mov    %r9d,%ecx
shl    %cl,%rbp
or     %rdx,%rsi
or     %rsi,%rdi
mov    0x8(%rsp),%rcx
or     (%rcx),%rax
or     %rdi,%rbp
or     %rbp,%rax
mov    %rax,(%rcx)
shr    $0x5,%r12
mov    %r12d,%eax
and    $0x1,%eax
mov    %r14d,%ecx
shl    %cl,%rax
mov    %r12d,%edx
and    $0x2,%edx
mov    %ebx,%ecx
shl    %cl,%rdx
mov    %r12d,%esi
and    $0x4,%esi
mov    %r8d,%ecx
shl    %cl,%rsi
mov    %r12d,%edi
and    $0x8,%edi
mov    %r10d,%ecx
shl    %cl,%rdi
or     %rax,%rdx
or     %rsi,%rdi
or     %rdx,%rdi
and    $0x10,%r12d
mov    %r9d,%ecx
shl    %cl,%r12
or     %rdi,%r12
mov    0x18(%rsp),%rax
or     %r12,(%rax)
cmp    %r15d,%r14d
mov    %r14d,%r12d
cmovg  %r15d,%r12d
imul   $0xfffffff5,%r12d,%ebp
add    0x38(%rsp),%ebp
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1080 <get_forward_diag@plt>
mov    %ebp,%ecx
cmp    $0xa,%ebp
jl     1467 <gen_web_board_count+0x307>
mov    %ebp,%edx
mov    $0xcccccccd,%ecx
imul   %rdx,%rcx
shr    $0x23,%rcx
mov    $0xa,%ebx
sub    %ecx,%ebx
movzwl %ax,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1070 <gen_web_stream@plt>
movzwl %ax,%r13d
mov    %r13d,%edi
mov    %ebx,%esi
call   1060 <count_contig_bits@plt>
mov    %eax,%r12d
mov    0x8(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %r13d,%edx
mov    %ebp,%ecx
call   1030 <put_forward_diag@plt>
mov    $0xa,%eax
sub    %r14d,%eax
mov    $0x9,%ebp
sub    %r14d,%ebp
cmp    %eax,%r15d
cmovl  %r15d,%ebp
lea    0x0(%rbp,%rbp,8),%eax
mov    0x38(%rsp),%rbx
sub    %eax,%ebx
mov    0x10(%rsp),%rdi
mov    0x30(%rsp),%rsi
mov    %ebx,%edx
call   1040 <get_back_diag@plt>
cmp    $0x9,%ebx
jg     14de <gen_web_board_count+0x37e>
lea    0x1(%rbx),%r14d
jmp    14f6 <gen_web_board_count+0x396>
mov    %ebx,%ecx
mov    $0xcccccccd,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
mov    $0xa,%r14d
sub    %edx,%r14d
movzwl %ax,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1070 <gen_web_stream@plt>
movzwl %ax,%ebp
mov    %ebp,%edi
mov    %r14d,%esi
call   1060 <count_contig_bits@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1050 <put_back_diag@plt>
mov    0x40(%rsp),%rax
add    0x2c(%rsp),%eax
add    %r12d,%eax
add    %r14d,%eax
add    $0xfffffffc,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gen_web_board_count(i64* %0, i64* %1, i64 %2, i64 %3, i32 %4) {
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i16
%15 = alloca i16
%16 = alloca i16
%17 = alloca i16
%18 = alloca i16
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i64* %0, i64** %6
store i64* %1, i64** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i32 %4, i32* %10
%24 = load i32, i32* %10
%25 = icmp sgt i32 %24, 49
br i1 %25, label %26, label %36
26: ; preds = %5
%27 = load i64, i64* %9
%28 = load i32, i32* %10
%29 = sdiv i32 %28, 10
%30 = srem i32 %29, 5
%31 = mul nsw i32 %30, 10
%32 = zext i32 %31 to i64
%33 = lshr i64 %27, %32
%34 = and i64 %33, 1023
%35 = trunc i64 %34 to i16
store i16 %35, i16* %11
br label %46
36: ; preds = %5
%37 = load i64, i64* %8
%38 = load i32, i32* %10
%39 = sdiv i32 %38, 10
%40 = srem i32 %39, 5
%41 = mul nsw i32 %40, 10
%42 = zext i32 %41 to i64
%43 = lshr i64 %37, %42
%44 = and i64 %43, 1023
%45 = trunc i64 %44 to i16
store i16 %45, i16* %11
br label %46
46: ; preds = %36, %26
%47 = load i16, i16* %11
%48 = load i32, i32* %10
%49 = srem i32 %48, 10
%50 = call zeroext i16 @gen_web_stream(i16 zeroext %47, i32 %49, i32 10)
store i16 %50, i16* %15
%51 = load i16, i16* %15
%52 = call i32 @count_contig_bits(i16 zeroext %51, i32 10)
store i32 %52, i32* %20
%53 = load i32, i32* %10
%54 = icmp sgt i32 %53, 49
br i1 %54, label %55, label %67
55: ; preds = %46
%56 = load i16, i16* %15
%57 = zext i16 %56 to i64
%58 = load i32, i32* %10
%59 = sdiv i32 %58, 10
%60 = srem i32 %59, 5
%61 = mul nsw i32 %60, 10
%62 = zext i32 %61 to i64
%63 = shl i64 %57, %62
%64 = load i64*, i64** %7
%65 = load i64, i64* %64
%66 = or i64 %65, %63
store i64 %66, i64* %64
br label %79
67: ; preds = %46
%68 = load i16, i16* %15
%69 = zext i16 %68 to i64
%70 = load i32, i32* %10
%71 = sdiv i32 %70, 10
%72 = srem i32 %71, 5
%73 = mul nsw i32 %72, 10
%74 = zext i32 %73 to i64
%75 = shl i64 %69, %74
%76 = load i64*, i64** %6
%77 = load i64, i64* %76
%78 = or i64 %77, %75
store i64 %78, i64* %76
br label %79
79: ; preds = %67, %55
%80 = load i64, i64* %8
%81 = load i32, i32* %10
%82 = srem i32 %81, 10
%83 = zext i32 %82 to i64
%84 = lshr i64 %80, %83
%85 = and i64 %84, 1
%86 = load i64, i64* %8
%87 = load i32, i32* %10
%88 = srem i32 %87, 10
%89 = add nsw i32 %88, 9
%90 = zext i32 %89 to i64
%91 = lshr i64 %86, %90
%92 = and i64 %91, 2
%93 = or i64 %85, %92
%94 = load i64, i64* %8
%95 = load i32, i32* %10
%96 = srem i32 %95, 10
%97 = add nsw i32 %96, 18
%98 = zext i32 %97 to i64
%99 = lshr i64 %94, %98
%100 = and i64 %99, 4
%101 = or i64 %93, %100
%102 = load i64, i64* %8
%103 = load i32, i32* %10
%104 = srem i32 %103, 10
%105 = add nsw i32 %104, 27
%106 = zext i32 %105 to i64
%107 = lshr i64 %102, %106
%108 = and i64 %107, 8
%109 = or i64 %101, %108
%110 = load i64, i64* %8
%111 = load i32, i32* %10
%112 = srem i32 %111, 10
%113 = add nsw i32 %112, 36
%114 = zext i32 %113 to i64
%115 = lshr i64 %110, %114
%116 = and i64 %115, 16
%117 = or i64 %109, %116
%118 = load i64, i64* %9
%119 = load i32, i32* %10
%120 = srem i32 %119, 10
%121 = zext i32 %120 to i64
%122 = lshr i64 %118, %121
%123 = and i64 %122, 1
%124 = load i64, i64* %9
%125 = load i32, i32* %10
%126 = srem i32 %125, 10
%127 = add nsw i32 %126, 9
%128 = zext i32 %127 to i64
%129 = lshr i64 %124, %128
%130 = and i64 %129, 2
%131 = or i64 %123, %130
%132 = load i64, i64* %9
%133 = load i32, i32* %10
%134 = srem i32 %133, 10
%135 = add nsw i32 %134, 18
%136 = zext i32 %135 to i64
%137 = lshr i64 %132, %136
%138 = and i64 %137, 4
%139 = or i64 %131, %138
%140 = load i64, i64* %9
%141 = load i32, i32* %10
%142 = srem i32 %141, 10
%143 = add nsw i32 %142, 27
%144 = zext i32 %143 to i64
%145 = lshr i64 %140, %144
%146 = and i64 %145, 8
%147 = or i64 %139, %146
%148 = load i64, i64* %9
%149 = load i32, i32* %10
%150 = srem i32 %149, 10
%151 = add nsw i32 %150, 36
%152 = zext i32 %151 to i64
%153 = lshr i64 %148, %152
%154 = and i64 %153, 16
%155 = or i64 %147, %154
%156 = shl i64 %155, 5
%157 = or i64 %117, %156
%158 = trunc i64 %157 to i16
store i16 %158, i16* %12
%159 = load i16, i16* %12
%160 = load i32, i32* %10
%161 = sdiv i32 %160, 10
%162 = call zeroext i16 @gen_web_stream(i16 zeroext %159, i32 %161, i32 10)
store i16 %162, i16* %16
%163 = load i16, i16* %16
%164 = call i32 @count_contig_bits(i16 zeroext %163, i32 10)
store i32 %164, i32* %21
%165 = load i16, i16* %16
%166 = zext i16 %165 to i64
%167 = and i64 %166, 1
%168 = load i32, i32* %10
%169 = srem i32 %168, 10
%170 = zext i32 %169 to i64
%171 = shl i64 %167, %170
%172 = load i16, i16* %16
%173 = zext i16 %172 to i64
%174 = and i64 %173, 2
%175 = load i32, i32* %10
%176 = srem i32 %175, 10
%177 = add nsw i32 %176, 9
%178 = zext i32 %177 to i64
%179 = shl i64 %174, %178
%180 = or i64 %171, %179
%181 = load i16, i16* %16
%182 = zext i16 %181 to i64
%183 = and i64 %182, 4
%184 = load i32, i32* %10
%185 = srem i32 %184, 10
%186 = add nsw i32 %185, 18
%187 = zext i32 %186 to i64
%188 = shl i64 %183, %187
%189 = or i64 %180, %188
%190 = load i16, i16* %16
%191 = zext i16 %190 to i64
%192 = and i64 %191, 8
%193 = load i32, i32* %10
%194 = srem i32 %193, 10
%195 = add nsw i32 %194, 27
%196 = zext i32 %195 to i64
%197 = shl i64 %192, %196
%198 = or i64 %189, %197
%199 = load i16, i16* %16
%200 = zext i16 %199 to i64
%201 = and i64 %200, 16
%202 = load i32, i32* %10
%203 = srem i32 %202, 10
%204 = add nsw i32 %203, 36
%205 = zext i32 %204 to i64
%206 = shl i64 %201, %205
%207 = or i64 %198, %206
%208 = load i64*, i64** %6
%209 = load i64, i64* %208
%210 = or i64 %209, %207
store i64 %210, i64* %208
%211 = load i16, i16* %16
%212 = zext i16 %211 to i64
%213 = lshr i64 %212, 5
%214 = and i64 %213, 1
%215 = load i32, i32* %10
%216 = srem i32 %215, 10
%217 = zext i32 %216 to i64
%218 = shl i64 %214, %217
%219 = load i16, i16* %16
%220 = zext i16 %219 to i64
%221 = lshr i64 %220, 5
%222 = and i64 %221, 2
%223 = load i32, i32* %10
%224 = srem i32 %223, 10
%225 = add nsw i32 %224, 9
%226 = zext i32 %225 to i64
%227 = shl i64 %222, %226
%228 = or i64 %218, %227
%229 = load i16, i16* %16
%230 = zext i16 %229 to i64
%231 = lshr i64 %230, 5
%232 = and i64 %231, 4
%233 = load i32, i32* %10
%234 = srem i32 %233, 10
%235 = add nsw i32 %234, 18
%236 = zext i32 %235 to i64
%237 = shl i64 %232, %236
%238 = or i64 %228, %237
%239 = load i16, i16* %16
%240 = zext i16 %239 to i64
%241 = lshr i64 %240, 5
%242 = and i64 %241, 8
%243 = load i32, i32* %10
%244 = srem i32 %243, 10
%245 = add nsw i32 %244, 27
%246 = zext i32 %245 to i64
%247 = shl i64 %242, %246
%248 = or i64 %238, %247
%249 = load i16, i16* %16
%250 = zext i16 %249 to i64
%251 = lshr i64 %250, 5
%252 = and i64 %251, 16
%253 = load i32, i32* %10
%254 = srem i32 %253, 10
%255 = add nsw i32 %254, 36
%256 = zext i32 %255 to i64
%257 = shl i64 %252, %256
%258 = or i64 %248, %257
%259 = load i64*, i64** %7
%260 = load i64, i64* %259
%261 = or i64 %260, %258
store i64 %261, i64* %259
%262 = load i32, i32* %10
%263 = srem i32 %262, 10
%264 = load i32, i32* %10
%265 = sdiv i32 %264, 10
%266 = icmp sgt i32 %263, %265
br i1 %266, label %267, label %273
267: ; preds = %79
%268 = load i32, i32* %10
%269 = load i32, i32* %10
%270 = sdiv i32 %269, 10
%271 = mul nsw i32 %270, 11
%272 = sub nsw i32 %268, %271
br label %279
273: ; preds = %79
%274 = load i32, i32* %10
%275 = load i32, i32* %10
%276 = srem i32 %275, 10
%277 = mul nsw i32 %276, 11
%278 = sub nsw i32 %274, %277
br label %279
279: ; preds = %273, %267
%280 = phi i32 [ %272, %267 ], [ %278, %273 ]
store i32 %280, i32* %19
%281 = load i64, i64* %8
%282 = load i64, i64* %9
%283 = load i32, i32* %19
%284 = call zeroext i16 @get_forward_diag(i64 %281, i64 %282, i32 %283)
store i16 %284, i16* %13
%285 = load i16, i16* %13
%286 = load i32, i32* %10
%287 = srem i32 %286, 10
%288 = load i32, i32* %10
%289 = sdiv i32 %288, 10
%290 = icmp sgt i32 %287, %289
br i1 %290, label %291, label %294
291: ; preds = %279
%292 = load i32, i32* %10
%293 = sdiv i32 %292, 10
br label %297
294: ; preds = %279
%295 = load i32, i32* %10
%296 = srem i32 %295, 10
br label %297
297: ; preds = %294, %291
%298 = phi i32 [ %293, %291 ], [ %296, %294 ]
%299 = load i32, i32* %19
%300 = icmp slt i32 %299, 10
br i1 %300, label %301, label %304
301: ; preds = %297
%302 = load i32, i32* %19
%303 = sub nsw i32 10, %302
br label %308
304: ; preds = %297
%305 = load i32, i32* %19
%306 = sdiv i32 %305, 10
%307 = sub nsw i32 10, %306
br label %308
308: ; preds = %304, %301
%309 = phi i32 [ %303, %301 ], [ %307, %304 ]
%310 = call zeroext i16 @gen_web_stream(i16 zeroext %285, i32 %298, i32 %309)
store i16 %310, i16* %17
%311 = load i16, i16* %17
%312 = load i32, i32* %19
%313 = icmp slt i32 %312, 10
br i1 %313, label %314, label %317
314: ; preds = %308
%315 = load i32, i32* %19
%316 = sub nsw i32 10, %315
br label %321
317: ; preds = %308
%318 = load i32, i32* %19
%319 = sdiv i32 %318, 10
%320 = sub nsw i32 10, %319
br label %321
321: ; preds = %317, %314
%322 = phi i32 [ %316, %314 ], [ %320, %317 ]
%323 = call i32 @count_contig_bits(i16 zeroext %311, i32 %322)
store i32 %323, i32* %22
%324 = load i64*, i64** %6
%325 = load i64*, i64** %7
%326 = load i16, i16* %17
%327 = load i32, i32* %19
%328 = call i32 @put_forward_diag(i64* %324, i64* %325, i16 zeroext %326, i32 %327)
%329 = load i32, i32* %10
%330 = sdiv i32 %329, 10
%331 = load i32, i32* %10
%332 = srem i32 %331, 10
%333 = sub nsw i32 10, %332
%334 = icmp slt i32 %330, %333
br i1 %334, label %335, label %341
335: ; preds = %321
%336 = load i32, i32* %10
%337 = load i32, i32* %10
%338 = sdiv i32 %337, 10
%339 = mul nsw i32 %338, 9
%340 = sub nsw i32 %336, %339
br label %348
341: ; preds = %321
%342 = load i32, i32* %10
%343 = load i32, i32* %10
%344 = srem i32 %343, 10
%345 = sub nsw i32 9, %344
%346 = mul nsw i32 %345, 9
%347 = sub nsw i32 %342, %346
br label %348
348: ; preds = %341, %335
%349 = phi i32 [ %340, %335 ], [ %347, %341 ]
store i32 %349, i32* %19
%350 = load i64, i64* %8
%351 = load i64, i64* %9
%352 = load i32, i32* %19
%353 = call zeroext i16 @get_back_diag(i64 %350, i64 %351, i32 %352)
store i16 %353, i16* %14
%354 = load i16, i16* %14
%355 = load i32, i32* %10
%356 = sdiv i32 %355, 10
%357 = load i32, i32* %10
%358 = srem i32 %357, 10
%359 = sub nsw i32 10, %358
%360 = icmp slt i32 %356, %359
br i1 %360, label %361, label %364
361: ; preds = %348
%362 = load i32, i32* %10
%363 = sdiv i32 %362, 10
br label %368
364: ; preds = %348
%365 = load i32, i32* %10
%366 = srem i32 %365, 10
%367 = sub nsw i32 9, %366
br label %368
368: ; preds = %364, %361
%369 = phi i32 [ %363, %361 ], [ %367, %364 ]
%370 = load i32, i32* %19
%371 = icmp slt i32 %370, 10
br i1 %371, label %372, label %375
372: ; preds = %368
%373 = load i32, i32* %19
%374 = add nsw i32 %373, 1
br label %379
375: ; preds = %368
%376 = load i32, i32* %19
%377 = sdiv i32 %376, 10
%378 = sub nsw i32 10, %377
br label %379
379: ; preds = %375, %372
%380 = phi i32 [ %374, %372 ], [ %378, %375 ]
%381 = call zeroext i16 @gen_web_stream(i16 zeroext %354, i32 %369, i32 %380)
store i16 %381, i16* %18
%382 = load i16, i16* %18
%383 = load i32, i32* %19
%384 = icmp slt i32 %383, 10
br i1 %384, label %385, label %388
385: ; preds = %379
%386 = load i32, i32* %19
%387 = add nsw i32 %386, 1
br label %392
388: ; preds = %379
%389 = load i32, i32* %19
%390 = sdiv i32 %389, 10
%391 = sub nsw i32 10, %390
br label %392
392: ; preds = %388, %385
%393 = phi i32 [ %387, %385 ], [ %391, %388 ]
%394 = call i32 @count_contig_bits(i16 zeroext %382, i32 %393)
store i32 %394, i32* %23
%395 = load i64*, i64** %6
%396 = load i64*, i64** %7
%397 = load i16, i16* %18
%398 = load i32, i32* %19
%399 = call i32 @put_back_diag(i64* %395, i64* %396, i16 zeroext %397, i32 %398)
%400 = load i32, i32* %20
%401 = load i32, i32* %21
%402 = add nsw i32 %400, %401
%403 = load i32, i32* %22
%404 = add nsw i32 %402, %403
%405 = load i32, i32* %23
%406 = add nsw i32 %404, %405
%407 = sub nsw i32 %406, 4
ret i32 %407
}

LLVM IR (-O2):
define i32 @gen_web_board_count(i64* %0, i64* %1, i64 %2, i64 %3, i32 %4) {
%6 = icmp sgt i32 %4, 49
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = udiv i32 %4, 10
%9 = urem i32 %8, 5
br label %13
10: ; preds = %5
%11 = sdiv i32 %4, 10
%12 = srem i32 %11, 5
br label %13
13: ; preds = %10, %7
%14 = phi i32 [ %12, %10 ], [ %9, %7 ]
%15 = phi i64 [ %2, %10 ], [ %3, %7 ]
%16 = mul nsw i32 %14, 10
%17 = zext i32 %16 to i64
%18 = lshr i64 %15, %17
%19 = trunc i64 %18 to i16
%20 = and i16 %19, 1023
%21 = srem i32 %4, 10
%22 = sdiv i32 %4, 10
%23 = tail call zeroext i16 @gen_web_stream(i16 zeroext %20, i32 %21, i32 10)
%24 = tail call i32 @count_contig_bits(i16 zeroext %23, i32 10)
%25 = zext i16 %23 to i64
br i1 %6, label %26, label %35
26: ; preds = %13
%27 = udiv i32 %4, 10
%28 = urem i32 %27, 5
%29 = mul nuw nsw i32 %28, 10
%30 = zext i32 %29 to i64
%31 = shl nuw nsw i64 %25, %30
%32 = load i64, i64* %1
%33 = or i64 %32, %31
store i64 %33, i64* %1
%34 = udiv i32 %4, 10
br label %42
35: ; preds = %13
%36 = srem i32 %22, 5
%37 = mul nsw i32 %36, 10
%38 = zext i32 %37 to i64
%39 = shl i64 %25, %38
%40 = load i64, i64* %0
%41 = or i64 %40, %39
store i64 %41, i64* %0
br label %42
42: ; preds = %35, %26
%43 = phi i32 [ %22, %35 ], [ %34, %26 ]
%44 = zext i32 %21 to i64
%45 = lshr i64 %2, %44
%46 = and i64 %45, 1
%47 = add nsw i32 %21, 9
%48 = zext i32 %47 to i64
%49 = lshr i64 %2, %48
%50 = and i64 %49, 2
%51 = add nsw i32 %21, 18
%52 = zext i32 %51 to i64
%53 = lshr i64 %2, %52
%54 = and i64 %53, 4
%55 = add nsw i32 %21, 27
%56 = zext i32 %55 to i64
%57 = lshr i64 %2, %56
%58 = and i64 %57, 8
%59 = add nsw i32 %21, 36
%60 = zext i32 %59 to i64
%61 = lshr i64 %2, %60
%62 = and i64 %61, 16
%63 = lshr i64 %3, %44
%64 = and i64 %63, 1
%65 = lshr i64 %3, %48
%66 = and i64 %65, 2
%67 = lshr i64 %3, %52
%68 = and i64 %67, 4
%69 = lshr i64 %3, %56
%70 = and i64 %69, 8
%71 = lshr i64 %3, %60
%72 = and i64 %71, 16
%73 = or i64 %66, %64
%74 = or i64 %73, %68
%75 = or i64 %74, %70
%76 = or i64 %75, %72
%77 = shl nuw nsw i64 %76, 5
%78 = or i64 %50, %46
%79 = or i64 %78, %54
%80 = or i64 %79, %58
%81 = or i64 %80, %62
%82 = or i64 %81, %77
%83 = trunc i64 %82 to i16
%84 = tail call zeroext i16 @gen_web_stream(i16 zeroext %83, i32 %43, i32 10)
%85 = tail call i32 @count_contig_bits(i16 zeroext %84, i32 10)
%86 = zext i16 %84 to i64
%87 = and i64 %86, 1
%88 = shl nuw i64 %87, %44
%89 = and i64 %86, 2
%90 = shl nuw nsw i64 %89, %48
%91 = and i64 %86, 4
%92 = shl nuw nsw i64 %91, %52
%93 = and i64 %86, 8
%94 = shl nuw nsw i64 %93, %56
%95 = and i64 %86, 16
%96 = shl nuw nsw i64 %95, %60
%97 = load i64, i64* %0
%98 = or i64 %90, %97
%99 = or i64 %98, %88
%100 = or i64 %99, %92
%101 = or i64 %100, %94
%102 = or i64 %101, %96
store i64 %102, i64* %0
%103 = lshr i64 %86, 5
%104 = and i64 %103, 1
%105 = shl nuw i64 %104, %44
%106 = and i64 %103, 2
%107 = shl nuw nsw i64 %106, %48
%108 = or i64 %105, %107
%109 = and i64 %103, 4
%110 = shl nuw nsw i64 %109, %52
%111 = or i64 %108, %110
%112 = and i64 %103, 8
%113 = shl nuw nsw i64 %112, %56
%114 = or i64 %111, %113
%115 = and i64 %103, 16
%116 = shl nuw nsw i64 %115, %60
%117 = or i64 %114, %116
%118 = load i64, i64* %1
%119 = or i64 %117, %118
store i64 %119, i64* %1
%120 = icmp sgt i32 %21, %43
%121 = select i1 %120, i32 %43, i32 %21
%122 = mul i32 %121, -11
%123 = add i32 %122, %4
%124 = tail call zeroext i16 @get_forward_diag(i64 %2, i64 %3, i32 %123)
%125 = icmp slt i32 %123, 10
%126 = udiv i32 %123, 10
%127 = select i1 %125, i32 %123, i32 %126
%128 = sub nsw i32 10, %127
%129 = tail call zeroext i16 @gen_web_stream(i16 zeroext %124, i32 %121, i32 %128)
%130 = tail call i32 @count_contig_bits(i16 zeroext %129, i32 %128)
%131 = tail call i32 @put_forward_diag(i64* %0, i64* %1, i16 zeroext %129, i32 %123)
%132 = sub nsw i32 10, %21
%133 = icmp slt i32 %43, %132
%134 = sub nsw i32 9, %21
%135 = select i1 %133, i32 %43, i32 %134
%136 = mul nsw i32 %135, -9
%137 = add i32 %136, %4
%138 = tail call zeroext i16 @get_back_diag(i64 %2, i64 %3, i32 %137)
%139 = icmp slt i32 %137, 10
br i1 %139, label %140, label %142
140: ; preds = %42
%141 = add nsw i32 %137, 1
br label %145
142: ; preds = %42
%143 = udiv i32 %137, 10
%144 = sub nsw i32 10, %143
br label %145
145: ; preds = %142, %140
%146 = phi i32 [ %144, %142 ], [ %141, %140 ]
%147 = tail call zeroext i16 @gen_web_stream(i16 zeroext %138, i32 %135, i32 %146)
%148 = tail call i32 @count_contig_bits(i16 zeroext %147, i32 %146)
%149 = tail call i32 @put_back_diag(i64* %0, i64* %1, i16 zeroext %147, i32 %137)
%150 = add i32 %24, -4
%151 = add i32 %150, %85
%152 = add i32 %151, %130
%153 = add i32 %152, %148
ret i32 %153
}