// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rsi, 0xb0(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, 0x28(%rsp)
movq $0x0, 0x10(%rdi)
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movl $0x1, %r14d
xorl %r15d, %r15d
movq %rdx, 0x30(%rsp)
movq %r13, %rdi
callq 0xe84a
movl %eax, %eax
cmpq %rax, %r15
jae 0xf98a
leaq 0x1(%r15), %r12
movq %r15, %rax
shlq $0x20, %rax
movq %rax, 0xb8(%rsp)
xorl %ebx, %ebx
movq %r15, 0x20(%rsp)
movq %r12, 0x18(%rsp)
movq %r13, %rdi
callq 0xe83a
cmpl %eax, %ebx
jae 0xf97d
movq %r13, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0xe8f6
testb %al, %al
je 0xf721
leal 0x1(%rbx), %esi
movq %r13, %rdi
movl %esi, 0x14(%rsp)
movl %r15d, %edx
callq 0xe8f6
testb %al, %al
je 0xf721
movq %r13, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
je 0xf721
movq %r13, %rdi
movl 0x14(%rsp), %esi
movl %r12d, %edx
callq 0xe8f6
testb %al, %al
je 0xf725
incl %ebx
jmp 0xf6c6
xorl %ecx, %ecx
movq %rbx, 0xc0(%rsp)
movl %ebx, %r15d
movl %ecx, %r12d
leal 0x2(%r15), %esi
movq %r13, %rdi
movq 0x20(%rsp), %rdx
callq 0xe8f6
leal 0x1(%r15), %ebx
leal 0x1(%r12), %ecx
testb %al, %al
jne 0xf72f
cmpl $0x9, %ecx
jb 0xf79d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r14d, 0x10(%rsp)
movl %r14d, %ecx
movl %ebp, 0xc(%rsp)
movl %ecx, %r14d
leal 0x3(%rbp), %edx
movq 0x30(%rsp), %rdi
movl %ebx, %esi
callq 0xe8f6
incl %ebp
incl %r13d
leal 0x1(%r14), %ecx
testb %al, %al
jne 0xf76a
cmpl $0xa, %r13d
jae 0xf7ac
movq 0x30(%rsp), %r13
movl 0xc(%rsp), %ebp
movl 0x10(%rsp), %r14d
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r12
jmp 0xf721
leal 0x1(%rbp), %eax
movq %rax, 0x58(%rsp)
notl %r12d
movq 0x30(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
movq 0x58(%rsp), %rdx
callq 0xe8f6
incl %r12d
decl %r15d
testb %al, %al
jne 0xf7bc
movl 0x14(%rsp), %r15d
subl %r12d, %r15d
leal -0x2(%r14), %edx
movq %r13, %rdi
movl %r15d, %esi
callq 0xe8f6
decl %r14d
testb %al, %al
jne 0xf7de
cmpl $0x1, %r12d
jne 0xf794
movl %r14d, %eax
movq 0x20(%rsp), %r15
cmpq %rax, %r15
leaq 0x60(%rsp), %r12
jne 0xf96f
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movb $0x0, 0x48(%rsp)
movl 0x14(%rsp), %edi
movq 0x18(%rsp), %rsi
callq 0x116c8
movl 0x10(%rsp), %r14d
movq %rax, %r15
leal -0x1(%rbx), %edi
movl %ebp, %esi
callq 0x116c8
leaq 0x80(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0xfa26
leaq 0x38(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2230
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xf89d
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xef74
movl 0xc(%rsp), %ebp
movq 0x20(%rsp), %r15
movl 0xc0(%rsp), %edx
orq 0xb8(%rsp), %rdx
movq 0x58(%rsp), %rax
shlq $0x20, %rax
movl %ebx, %ecx
orq %rax, %rcx
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x11c94
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
movq 0x18(%rsp), %r12
je 0xf913
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1016e
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xf94a
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xf721
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xf721
movl 0xc(%rsp), %ebp
movl 0x10(%rsp), %r14d
jmp 0xf7a2
incl %ebp
incl %r14d
movq %r12, %r15
jmp 0xf694
movq 0x28(%rsp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xf9e9
movq 0x90(%rsp), %rsi
jmp 0xf9da
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xf9e9
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xf9e9
jmp 0xf9e6
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xfa14
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xfa14
jmp 0xfa11
jmp 0xfa11
jmp 0xfa11
jmp 0xfa11
jmp 0xfa11
movq %rax, %rbx
movq 0x28(%rsp), %rdi
callq 0x1005a
movq %rbx, %rdi
callq 0x2340