// File: eggnot[P]pixel_camera/matrix/lib/framebuffer.cc
// Function: rgb_matrix::internal::Framebuffer::Fill(unsigned char, unsigned char, unsigned char)
void Framebuffer::Fill(uint8_t r, uint8_t g, uint8_t b) {
  const uint16_t red   = MapColor(r);
  const uint16_t green = MapColor(PANEL_SWAP_G_B_ ? b : g);
  const uint16_t blue  = MapColor(PANEL_SWAP_G_B_ ? g : b);

  for (int b = kBitPlanes - pwm_bits_; b < kBitPlanes; ++b) {
    uint16_t mask = 1 << b;
    IoBits plane_bits;
    plane_bits.raw = 0;
    plane_bits.bits.p0_r1 = plane_bits.bits.p0_r2 = (red & mask) == mask;
    plane_bits.bits.p0_g1 = plane_bits.bits.p0_g2 = (green & mask) == mask;
    plane_bits.bits.p0_b1 = plane_bits.bits.p0_b2 = (blue & mask) == mask;

#ifndef ONLY_SINGLE_CHAIN
    plane_bits.bits.p1_r1 = plane_bits.bits.p1_r2 =
      plane_bits.bits.p2_r1 = plane_bits.bits.p2_r2 = (red & mask) == mask;
    plane_bits.bits.p1_g1 = plane_bits.bits.p1_g2 =
      plane_bits.bits.p2_g1 = plane_bits.bits.p2_g2 = (green & mask) == mask;
    plane_bits.bits.p1_b1 = plane_bits.bits.p1_b2 =
      plane_bits.bits.p2_b1 = plane_bits.bits.p2_b2 = (blue & mask) == mask;
#endif
    for (int row = 0; row < double_rows_; ++row) {
      IoBits *row_data = ValueAt(row, 0, b);
      for (int col = 0; col < columns_; ++col) {
        (row_data++)->raw = plane_bits.raw;
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movb %dl, %cl
movb %sil, %dl
movq %rdi, -0x8(%rbp)
movb %dl, -0x9(%rbp)
movb %cl, -0xa(%rbp)
movb %al, -0xb(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movzbl -0x9(%rbp), %esi
callq 0x8110
movq -0x40(%rbp), %rdi
movw %ax, -0xe(%rbp)
movzbl -0xa(%rbp), %esi
callq 0x8110
movq -0x40(%rbp), %rdi
movw %ax, -0x10(%rbp)
movzbl -0xb(%rbp), %esi
callq 0x8110
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, -0x12(%rbp)
movzbl 0x10(%rax), %ecx
movl $0xb, %eax
subl %ecx, %eax
movl %eax, -0x18(%rbp)
cmpl $0xb, -0x18(%rbp)
jge 0x75dd
movl -0x18(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movw %ax, -0x1a(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x80f0
movl $0x0, -0x20(%rbp)
movzwl -0xe(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x8, %edx
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
shll $0xb, %ecx
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
orl %ecx, %eax
movl %eax, -0x20(%rbp)
movzwl -0x10(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x9, %edx
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
shll $0x1b, %ecx
andl $0xf7ffffff, %eax       # imm = 0xF7FFFFFF
orl %ecx, %eax
movl %eax, -0x20(%rbp)
movzwl -0x12(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0xa, %edx
andl $0xfffffbff, %eax       # imm = 0xFFFFFBFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
shll $0x7, %ecx
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
orl %ecx, %eax
movl %eax, -0x20(%rbp)
movzwl -0xe(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x1a, %edx
andl $0xfbffffff, %eax       # imm = 0xFBFFFFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0xe, %edx
andl $0xffffbfff, %eax       # imm = 0xFFFFBFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x13, %edx
andl $0xfff7ffff, %eax       # imm = 0xFFF7FFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
shll $0xc, %ecx
andl $0xffffefff, %eax       # imm = 0xFFFFEFFF
orl %ecx, %eax
movl %eax, -0x20(%rbp)
movzwl -0x10(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x10, %edx
andl $0xfffeffff, %eax       # imm = 0xFFFEFFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x2, %edx
andl $-0x5, %eax
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0xd, %edx
andl $0xffffdfff, %eax       # imm = 0xFFFFDFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
shll $0x5, %ecx
andl $-0x21, %eax
orl %ecx, %eax
movl %eax, -0x20(%rbp)
movzwl -0x12(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x15, %edx
andl $0xffdfffff, %eax       # imm = 0xFFDFFFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x3, %edx
andl $-0x9, %eax
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
movl %ecx, %edx
shll $0x14, %edx
andl $0xffefffff, %eax       # imm = 0xFFEFFFFF
orl %edx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %ecx
shll $0x6, %ecx
andl $-0x41, %eax
orl %ecx, %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x40(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x14(%rcx), %eax
jge 0x75cd
movq -0x40(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x18(%rbp), %ecx
xorl %edx, %edx
callq 0x81f0
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x40(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0x75c0
movl -0x20(%rbp), %ecx
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x30(%rbp)
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7595
jmp 0x75c2
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x756d
jmp 0x75cf
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x7348
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)