// File: /workspace/github_cpp_makefile_star2_O1/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 0xe84a
movl %eax, %eax
cmpq %rax, %r12
jae 0x107c4
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 0xe83a
cmpl %eax, %ebx
jae 0x107ba
leal -0x1(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
jne 0x107a1
movq %r14, %rdi
movl %ebp, %esi
movl 0x34(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x107a1
movq %r14, %rdi
movl %ebx, %esi
movl 0x34(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x107a1
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
je 0x107a1
leal 0x1(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
je 0x107a1
leal 0x2(%rbx), %esi
movq %r14, %rdi
movl %esi, 0x4(%rsp)
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
je 0x107a1
movq %r14, %rdi
movl %ebx, %esi
movq 0x28(%rsp), %rdx
callq 0xe8f6
testb %al, %al
je 0x107a1
movq %r14, %rdi
movl %ebp, %esi
movq 0x28(%rsp), %rdx
callq 0xe8f6
testb %al, %al
jne 0x107a1
movq %r14, %rdi
movl 0x4(%rsp), %esi
movq 0x28(%rsp), %rdx
callq 0xe8f6
testb %al, %al
jne 0x107a1
movq %r14, %rdi
movl %ebx, %esi
movl 0x8(%rsp), %edx
callq 0xe8f6
testb %al, %al
je 0x107a1
movq %r14, %rdi
movl %ebp, %esi
movl 0x8(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x107a1
movq %r14, %rdi
movl 0x4(%rsp), %esi
movl 0x8(%rsp), %edx
callq 0xe8f6
testb %al, %al
je 0x107a1
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 0xe8f6
testb %al, %al
je 0x103dc
movq %r14, %rdi
movl %ebp, %esi
movq 0x28(%rsp), %rdx
callq 0xe8f6
testb %al, %al
jne 0x103dc
movq %r14, %rdi
movl %ebp, %esi
movl 0x8(%rsp), %edx
callq 0xe8f6
movq 0x10(%rsp), %rcx
incl %ecx
movq 0x18(%rsp), %rdx
decl %edx
movq 0x20(%rsp), %rsi
incl %esi
testb %al, %al
jne 0x10375
movq %r15, 0x40(%rsp)
incl %r15d
movq %r14, %rdi
movl %r15d, %esi
movq 0x28(%rsp), %rdx
callq 0xe8f6
testb %al, %al
jne 0x107b5
movq 0x40(%rsp), %rax
leal 0x2(%rax), %esi
movq %r14, %rdi
movl %esi, (%rsp)
movq 0x28(%rsp), %rdx
callq 0xe8f6
testb %al, %al
je 0x107b5
movq %r14, %rdi
movl (%rsp), %esi
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
je 0x107b5
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0xe8f6
cmpl $0xd, 0x10(%rsp)
setae %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x107b5
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 0xe8f6
testb %al, %al
je 0x104a4
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0xe8f6
testb %al, %al
jne 0x104a4
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movl %ebp, %edx
callq 0xe8f6
movq 0x10(%rsp), %rcx
incl %ecx
testb %al, %al
jne 0x10459
movl %r13d, %eax
subl %r12d, %eax
cmpl $0xe, %eax
jb 0x107b5
movq 0x38(%rsp), %rax
leal 0x1(%rax), %edx
movq %r14, %rdi
movl (%rsp), %esi
movl %edx, 0xc(%rsp)
callq 0xe8f6
testb %al, %al
je 0x107b5
movq 0x38(%rsp), %rax
leal 0x2(%rax), %ebp
movq %r14, %rdi
movl (%rsp), %esi
movl %ebp, %edx
callq 0xe8f6
testb %al, %al
je 0x107b5
movq %r14, %rdi
movl %r15d, %esi
movl 0xc(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x107b5
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0xe8f6
testb %al, %al
je 0x107b5
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 0xe8f6
testb %al, %al
je 0x10579
movq %r14, %rdi
movl %r13d, %esi
movl 0xc(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x10579
movq %r14, %rdi
movl %r13d, %esi
movq 0x38(%rsp), %rdx
callq 0xe8f6
movq 0x18(%rsp), %rcx
leal 0x1(%rcx), %edx
movq 0x20(%rsp), %rcx
decl %ecx
movq %rcx, 0x20(%rsp)
testb %al, %al
jne 0x10520
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0xe8f6
testb %al, %al
je 0x107a7
movl %ebx, %esi
subl 0x18(%rsp), %esi
movq %r14, %rdi
movl %esi, 0x30(%rsp)
movl %ebp, %edx
callq 0xe8f6
testb %al, %al
je 0x107a7
movq %r14, %rdi
movl %r13d, %esi
movl 0xc(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x107a7
movq %r14, %rdi
movl 0x30(%rsp), %esi
movl 0xc(%rsp), %edx
callq 0xe8f6
testb %al, %al
je 0x107a7
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 0xe8f6
testb %al, %al
je 0x10631
movq %r14, %rdi
movl %r13d, %esi
movl 0x10(%rsp), %edx
callq 0xe8f6
testb %al, %al
jne 0x10631
movq %r14, %rdi
movl 0x4(%rsp), %esi
movl 0x10(%rsp), %edx
callq 0xe8f6
movq 0x20(%rsp), %rcx
decl %ecx
testb %al, %al
jne 0x105e7
cmpl $0x0, 0x18(%rsp)
sete %al
movl 0x20(%rsp), %ecx
cmpq %rcx, %r12
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x107a7
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 0x116c8
movq %rax, %r13
movq 0x40(%rsp), %rdi
decl %edi
movq 0x38(%rsp), %rsi
decl %esi
callq 0x116c8
leaq 0x98(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0xfa26
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x2230
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x106dd
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 0xef74
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 0x11c06
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1074c
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x48(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x110d4
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x10783
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x107a7
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x107a7
movl %r13d, %ebp
movl %ebx, %r15d
incl %r15d
movl %ebp, %r13d
movl %r15d, %ebx
jmp 0x1023f
movl %r13d, %ebp
jmp 0x107a7
movq 0x28(%rsp), %r12
jmp 0x101f6
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 0x10829
movq 0xa8(%rsp), %rsi
jmp 0x1081a
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x10829
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x10829
jmp 0x10826
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x10854
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x10854
jmp 0x10851
jmp 0x10851
jmp 0x10851
jmp 0x10851
jmp 0x10851
movq %rax, %rbx
movq 0x48(%rsp), %rdi
callq 0x100b6
movq %rbx, %rdi
callq 0x2340