// File: /workspace/github_cpp_makefile_star2_O3/drummyfish[P]flowchart/src/program.cpp
// Function: std::vector<block_directive, std::allocator<block_directive>> program::get_directive_function_blocks<block_directive>(image*)
vector<T> program::get_directive_function_blocks(image *img)
  {
    unsigned int i,j,x,y;
    vector<T> result;
    coord_2d c1, c2;

    bool directive = switch_value<T>::value == 0;  // whether directive or function blocks are being looked for

    for (j = 0; j < img->get_height(); j++)
      for (i = 0; i < img->get_width(); i++)
        {
          if (   // block corner
            !img->pixel_is_black(i - 1,j)     &&
            !img->pixel_is_black(i - 1,j - 1) &&
            !img->pixel_is_black(i,j - 1) &&
            img->pixel_is_black(i,j)     &&
            img->pixel_is_black(i + 1,j) &&
            img->pixel_is_black(i + 2,j) &&
            img->pixel_is_black(i,j + 1)     &&
            directive != img->pixel_is_black(i + 1,j + 1) &&
            directive != img->pixel_is_black(i + 2,j + 1) &&
            img->pixel_is_black(i,j + 2)     &&
            directive != img->pixel_is_black(i + 1,j + 2) &&
            img->pixel_is_black(i + 2,j + 2))
            {
              // try to follow the block border now:

              c1.x = i;
              c1.y = j;

              x = i + 2;
              y = j;

              while (   // upper horizontal border
                img->pixel_is_black(x + 1,y)     &&
                directive != img->pixel_is_black(x + 1,y + 1) &&    // the middle pixel differs for function and directive block
                img->pixel_is_black(x + 1,y + 2))
                {
                  x++;
                }

              i = x + 1;   // i can skip here now
              y += 2;

              if (directive)    // with directive blocks we have to checks corners
                {
                  if (!(
                    !img->pixel_is_black(x + 1,y - 1) &&
                    img->pixel_is_black(x + 2,y - 1) &&
                    img->pixel_is_black(x + 2,y - 2) &&
                    img->pixel_is_black(x + 1,y - 2)))
                    continue;    // corner not valid

                  x += 2;
                }

              if (x - c1.x < FONT_WIDTH + 6)       // the block must be at least one character wide + borders
                continue;

              while (   // right verticel border
                img->pixel_is_black(x,y + 1)     &&
                directive != img->pixel_is_black(x - 1,y + 1) &&
                img->pixel_is_black(x - 2,y + 1))
                {
                  y++;
                }

              if (c2.y - c1.y < FONT_HEIGHT + 6)   // the block must be at least one character high
                continue;

              if (directive)
                {
                  if (!(
                    img->pixel_is_black(x,y + 1) &&
                    img->pixel_is_black(x,y + 2) &&
                    !img->pixel_is_black(x - 1,y + 1) &&
                    img->pixel_is_black(x - 1,y + 2)))
                    continue;    // corner not valid
                  x -= 2;
                  y += 2;
                }

              c2.x = x;
              c2.y = y;

              if (directive)
                c2.x += 2;

              while (   // lower horizontal border
                img->pixel_is_black(x - 1,y)     &&
                directive != img->pixel_is_black(x - 1,y - 1) &&
                img->pixel_is_black(x - 1,y - 2))
                {
                  x--;
                }

              if (directive)
                {
                  if (!(
                    img->pixel_is_black(x - 1,y) &&
                    img->pixel_is_black(x - 2,y) &&
                    !img->pixel_is_black(x - 1,y - 1) &&
                    img->pixel_is_black(x - 2,y - 1)))
                    continue;    // corner not valid

                  x -= 2;
                }

              y -= 2;

              while (   // left vertical border
                img->pixel_is_black(x,y - 1)     &&
                directive != img->pixel_is_black(x + 1,y - 1) &&
                img->pixel_is_black(x + 2,y - 1))
                {
                  y--;
                }

              if (directive)
                y -= 2;

              if (x == c1.x && y == c1.y)          // block detected
                {
                  string block_string;
                  bool error;

                  block_string = this->string_from_image_area(img,make_coord(c1.x + 3,c1.y + 3),make_coord(c2.x - 3,c2.y - 3),error);

                  T b(block_string,c1,c2);

                  result.push_back(b);
                }
            }
        }

    return result;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %r14
movq %rsi, 0xc8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, 0x48(%rsp)
movq $0x0, 0x10(%rdi)
xorl %r12d, %r12d
movq %r14, %rdi
callq 0xe554
movl %eax, %eax
cmpq %rax, %r12
jae 0x104c2
leal -0x1(%r12), %eax
movl %eax, 0x34(%rsp)
leaq 0x1(%r12), %rax
movq %rax, 0x28(%rsp)
leal 0x2(%r12), %eax
movl %eax, 0x8(%rsp)
leal 0x3(%r12), %eax
movl %eax, 0x54(%rsp)
movq %r12, %rax
shlq $0x20, %rax
movq %rax, 0xd0(%rsp)
xorl %ebx, %ebx
movq %r14, %rdi
callq 0xe544
cmpl %eax, %ebx
jae 0x104b8
leal -0x1(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0xe5fc
testb %al, %al
jne 0x1049f
movq %r14, %rdi
movl %ebp, %esi
movl 0x34(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x1049f
movq %r14, %rdi
movl %ebx, %esi
movl 0x34(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x1049f
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0xe5fc
testb %al, %al
je 0x1049f
leal 0x1(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0xe5fc
testb %al, %al
je 0x1049f
leal 0x2(%rbx), %esi
movq %r14, %rdi
movl %esi, 0x4(%rsp)
movl %r12d, %edx
callq 0xe5fc
testb %al, %al
je 0x1049f
movq %r14, %rdi
movl %ebx, %esi
movq 0x28(%rsp), %rdx
callq 0xe5fc
testb %al, %al
je 0x1049f
movq %r14, %rdi
movl %ebp, %esi
movq 0x28(%rsp), %rdx
callq 0xe5fc
testb %al, %al
jne 0x1049f
movq %r14, %rdi
movl 0x4(%rsp), %esi
movq 0x28(%rsp), %rdx
callq 0xe5fc
testb %al, %al
jne 0x1049f
movq %r14, %rdi
movl %ebx, %esi
movl 0x8(%rsp), %edx
callq 0xe5fc
testb %al, %al
je 0x1049f
movq %r14, %rdi
movl %ebp, %esi
movl 0x8(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x1049f
movq %r14, %rdi
movl 0x4(%rsp), %esi
movl 0x8(%rsp), %edx
callq 0xe5fc
testb %al, %al
je 0x1049f
movl $0x4, %ecx
xorl %edx, %edx
movl $0x1, %esi
movl 0x4(%rsp), %ebp
movl %ebp, %r15d
movl %ecx, %eax
movq %rax, 0x10(%rsp)
movl %edx, %eax
movq %rax, 0x18(%rsp)
movl %esi, %eax
movq %rax, 0x20(%rsp)
leal 0x1(%r15), %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0xe5fc
testb %al, %al
je 0x100da
movq %r14, %rdi
movl %ebp, %esi
movq 0x28(%rsp), %rdx
callq 0xe5fc
testb %al, %al
jne 0x100da
movq %r14, %rdi
movl %ebp, %esi
movl 0x8(%rsp), %edx
callq 0xe5fc
movq 0x10(%rsp), %rcx
incl %ecx
movq 0x18(%rsp), %rdx
decl %edx
movq 0x20(%rsp), %rsi
incl %esi
testb %al, %al
jne 0x10073
movq %r15, 0x40(%rsp)
incl %r15d
movq %r14, %rdi
movl %r15d, %esi
movq 0x28(%rsp), %rdx
callq 0xe5fc
testb %al, %al
jne 0x104b3
movq 0x40(%rsp), %rax
leal 0x2(%rax), %esi
movq %r14, %rdi
movl %esi, (%rsp)
movq 0x28(%rsp), %rdx
callq 0xe5fc
testb %al, %al
je 0x104b3
movq %r14, %rdi
movl (%rsp), %esi
movl %r12d, %edx
callq 0xe5fc
testb %al, %al
je 0x104b3
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0xe5fc
cmpl $0xd, 0x10(%rsp)
setae %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x104b3
movl %r12d, %ecx
movl 0x8(%rsp), %ebp
movl %ebp, %eax
movq %rcx, 0x10(%rsp)
movq %rax, 0x38(%rsp)
leal 0x1(%rax), %ebp
movq %r14, %rdi
movl (%rsp), %esi
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
je 0x101a2
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
jne 0x101a2
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movl %ebp, %edx
callq 0xe5fc
movq 0x10(%rsp), %rcx
incl %ecx
testb %al, %al
jne 0x10157
movl %r13d, %eax
subl %r12d, %eax
cmpl $0xe, %eax
jb 0x104b3
movq 0x38(%rsp), %rax
leal 0x1(%rax), %edx
movq %r14, %rdi
movl (%rsp), %esi
movl %edx, 0xc(%rsp)
callq 0xe5fc
testb %al, %al
je 0x104b3
movq 0x38(%rsp), %rax
leal 0x2(%rax), %ebp
movq %r14, %rdi
movl (%rsp), %esi
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
je 0x104b3
movq %r14, %rdi
movl %r15d, %esi
movl 0xc(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x104b3
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
je 0x104b3
movq 0x18(%rsp), %rdx
movq %rdx, 0x18(%rsp)
movq 0x20(%rsp), %rax
leal (%rbx,%rax), %esi
movq %r14, %rdi
movl %esi, %r13d
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
je 0x10277
movq %r14, %rdi
movl %r13d, %esi
movl 0xc(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x10277
movq %r14, %rdi
movl %r13d, %esi
movq 0x38(%rsp), %rdx
callq 0xe5fc
movq 0x18(%rsp), %rcx
leal 0x1(%rcx), %edx
movq 0x20(%rsp), %rcx
decl %ecx
movq %rcx, 0x20(%rsp)
testb %al, %al
jne 0x1021e
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
je 0x104a5
movl %ebx, %esi
subl 0x18(%rsp), %esi
movq %r14, %rdi
movl %esi, 0x30(%rsp)
movl %ebp, %edx
callq 0xe5fc
testb %al, %al
je 0x104a5
movq %r14, %rdi
movl %r13d, %esi
movl 0xc(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x104a5
movq %r14, %rdi
movl 0x30(%rsp), %esi
movl 0xc(%rsp), %edx
callq 0xe5fc
testb %al, %al
je 0x104a5
movq 0x18(%rsp), %rax
subl %eax, 0x4(%rsp)
movq 0x10(%rsp), %rcx
movq %rcx, 0x20(%rsp)
leal 0x1(%rcx), %edx
movq %r14, %rdi
movl 0x30(%rsp), %esi
movl %edx, 0x10(%rsp)
callq 0xe5fc
testb %al, %al
je 0x1032f
movq %r14, %rdi
movl %r13d, %esi
movl 0x10(%rsp), %edx
callq 0xe5fc
testb %al, %al
jne 0x1032f
movq %r14, %rdi
movl 0x4(%rsp), %esi
movl 0x10(%rsp), %edx
callq 0xe5fc
movq 0x20(%rsp), %rcx
decl %ecx
testb %al, %al
jne 0x102e5
cmpl $0x0, 0x18(%rsp)
sete %al
movl 0x20(%rsp), %ecx
cmpq %rcx, %r12
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x104a5
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movb $0x0, 0x68(%rsp)
leal 0x3(%rbx), %edi
movl 0x54(%rsp), %esi
callq 0x1133c
movq %rax, %r13
movq 0x40(%rsp), %rdi
decl %edi
movq 0x38(%rsp), %rsi
decl %esi
callq 0x1133c
leaq 0x98(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0xf728
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x2230
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x103db
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xec7c
movl %ebx, %edx
orq 0xd0(%rsp), %rdx
movq %rbp, %rax
shlq $0x20, %rax
movl (%rsp), %ecx
orq %rax, %rcx
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x11896
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1044a
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x48(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x10da4
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x10481
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x104a5
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x104a5
movl %r13d, %ebp
movl %ebx, %r15d
incl %r15d
movl %ebp, %r13d
movl %r15d, %ebx
jmp 0xff3d
movl %r13d, %ebp
jmp 0x104a5
movq 0x28(%rsp), %r12
jmp 0xfef4
movq 0x48(%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x10527
movq 0xa8(%rsp), %rsi
jmp 0x10518
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x10527
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x10527
jmp 0x10524
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x10552
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x10552
jmp 0x1054f
jmp 0x1054f
jmp 0x1054f
jmp 0x1054f
jmp 0x1054f
movq %rax, %rbx
movq 0x48(%rsp), %rdi
callq 0xfdb0
movq %rbx, %rdi
callq 0x2340