// File: /workspace/github_cpp_makefile_star2_O2/drummyfish[P]flowchart/src/program.cpp
// Function: program::get_command_blocks(image*)
vector<block_command> program::get_command_blocks(image *img)
  {
    unsigned int i, j, x, y;
    coord_2d c1, c2;
    vector<block_command> result;

    for (j = 0; j < img->get_height(); j++)
      for (i = 0; i < img->get_width(); i++)
        {
          if (   // block corner
            img->pixel_is_black(i,j)     &&
            img->pixel_is_black(i + 1,j) &&
            img->pixel_is_black(i,j + 1) &&
            !img->pixel_is_black(i + 1,j + 1))
            {
              c1.x = i;
              c1.y = j;

              x = i + 1;
              y = j;

              // trace the block border:

              while (img->pixel_is_black(x + 1,y))
                x++;

              i = x;    // i can skip here

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

              while (img->pixel_is_black(x,y + 1))
                y++;

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

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

              while (img->pixel_is_black(x - 1,y))
                x--;

              while (img->pixel_is_black(x,y - 1))
                y--;

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

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

                  block_command 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 $0xc8, %rsp
movq %rdx, %r15
movq %rsi, 0x48(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, 0x28(%rsp)
andq $0x0, 0x10(%rdi)
pushq $-0x2
popq %rax
movl %eax, 0x10(%rsp)
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
xorl %ebx, %ebx
movq %rdx, 0x40(%rsp)
movq %r15, %rdi
callq 0xb47e
movl %eax, %eax
cmpq %rax, %rbx
jae 0xc23e
leaq 0x1(%rbx), %rax
movq %rax, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
shlq $0x20, %rbx
movq %rbx, 0x50(%rsp)
xorl %edx, %edx
movl %edx, %ebx
movq %r15, %rdi
callq 0xb46e
cmpl %eax, %ebx
jae 0xc22c
movq %r15, %rdi
movl %ebx, %esi
movq 0x20(%rsp), %rdx
callq 0xb4ce
movq %rbx, 0x30(%rsp)
incl %ebx
movl %ebx, %edx
testb %al, %al
je 0xc014
movq %r15, %rdi
movl %ebx, %esi
movq 0x20(%rsp), %rdx
callq 0xb4ce
movl %ebx, %edx
testb %al, %al
je 0xc014
movq %r15, %rdi
movq 0x30(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0xb4ce
movl %ebx, %edx
testb %al, %al
je 0xc014
movq %r15, %rdi
movl %ebx, %esi
movq 0x18(%rsp), %rdx
callq 0xb4ce
movl %ebx, %edx
testb %al, %al
jne 0xc014
movl %ebx, 0x14(%rsp)
xorl %ecx, %ecx
movq 0x30(%rsp), %r12
movq 0x20(%rsp), %rbx
movl %r12d, %r13d
movl %ecx, %ebp
leal 0x2(%r13), %esi
movq %r15, %rdi
movl %ebx, %edx
callq 0xb4ce
leal 0x1(%r13), %r12d
leal 0x1(%rbp), %ecx
testb %al, %al
jne 0xc094
leal 0x1(%r12), %edx
cmpl $0x9, %ecx
jb 0xc014
movl %edx, 0x8(%rsp)
movl 0xc(%rsp), %ecx
pushq $-0x1
popq %r15
movl 0x10(%rsp), %eax
movl %eax, %ebx
movl %ecx, %r14d
leal 0x3(%rbx), %edx
movq 0x40(%rsp), %rdi
movl %r12d, %esi
callq 0xb4ce
incl %ebx
incl %r15d
leal 0x1(%r14), %ecx
testb %al, %al
jne 0xc0d2
cmpl $0xa, %r15d
movq 0x40(%rsp), %r15
movl 0x8(%rsp), %edx
jb 0xc014
leal 0x1(%rbx), %eax
movq %rax, 0x38(%rsp)
notl %ebp
movq %r15, %rdi
movl %r13d, %esi
movq 0x38(%rsp), %rdx
callq 0xb4ce
incl %ebp
decl %r13d
testb %al, %al
jne 0xc10f
movl 0x14(%rsp), %r13d
subl %ebp, %r13d
leal -0x2(%r14), %edx
movq %r15, %rdi
movl %r13d, %esi
callq 0xb4ce
decl %r14d
testb %al, %al
jne 0xc130
cmpl $0x1, %ebp
movl 0x8(%rsp), %edx
movl 0x14(%rsp), %edi
jne 0xc014
movl %r14d, %eax
cmpq %rax, 0x20(%rsp)
jne 0xc014
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
movb $0x0, 0x68(%rsp)
movq 0x18(%rsp), %rsi
callq 0xdac4
leaq 0x98(%rsp), %r14
movq %rax, %r13
leal -0x1(%r12), %edi
movl %ebx, %esi
callq 0xdac4
movq %r14, %rdi
movq 0x48(%rsp), %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0xc2a2
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x20d0
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2280
movl 0x30(%rsp), %edx
orq 0x50(%rsp), %rdx
movq 0x38(%rsp), %rax
shlq $0x20, %rax
movl %r12d, %ecx
orq %rax, %rcx
movq %r14, %rdi
movq %r13, %rsi
callq 0xdf74
movq %r13, %rdi
callq 0x20d0
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xc81c
movq %r14, %rdi
callq 0x20d0
leaq 0x58(%rsp), %rdi
callq 0x20d0
movl 0x8(%rsp), %edx
jmp 0xc014
incl 0x10(%rsp)
incl 0xc(%rsp)
movq 0x18(%rsp), %rbx
jmp 0xbfe8
movq 0x28(%rsp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0xc26a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x20d0
jmp 0xc276
jmp 0xc273
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x20d0
jmp 0xc28f
jmp 0xc28c
jmp 0xc28c
jmp 0xc28c
jmp 0xc28c
jmp 0xc28c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
callq 0xc7b6
movq %rbx, %rdi
callq 0x2330
nop