// File: eggnot[P]pixel_camera/matrix/lib/framebuffer.cc
// Function: rgb_matrix::internal::Framebuffer::InitGPIO(rgb_matrix::GPIO*, int)
void Framebuffer::InitGPIO(GPIO *io, int parallel) {
  if (sOutputEnablePulser != NULL)
    return;  // already initialized.

  // Tell GPIO about all bits we intend to use.
  IoBits b;
  b.raw = 0;

#ifdef PI_REV1_RGB_PINOUT_
  b.bits.output_enable_rev1 = b.bits.output_enable_rev2 = 1;
  b.bits.clock_rev1 = b.bits.clock_rev2 = 1;
#endif

  b.bits.output_enable = 1;
  b.bits.clock = 1;
  b.bits.strobe = 1;

  b.bits.p0_r1 = b.bits.p0_g1 = b.bits.p0_b1 = 1;
  b.bits.p0_r2 = b.bits.p0_g2 = b.bits.p0_b2 = 1;

#ifndef ONLY_SINGLE_CHAIN
  if (parallel >= 2) {
    b.bits.p1_r1 = b.bits.p1_g1 = b.bits.p1_b1 = 1;
    b.bits.p1_r2 = b.bits.p1_g2 = b.bits.p1_b2 = 1;
  }

  if (parallel >= 3) {
    b.bits.p2_r1 = b.bits.p2_g1 = b.bits.p2_b1 = 1;
    b.bits.p2_r2 = b.bits.p2_g2 = b.bits.p2_b2 = 1;
  }
#endif

  b.bits.a = b.bits.b = b.bits.c = b.bits.d = 1;

  // Initialize outputs, make sure that all of these are supported bits.
  const uint32_t result = io->InitOutputs(b.raw);
  assert(result == b.raw);

  // Now, set up the PinPulser for output enable.
  IoBits output_enable_bits;
#ifdef PI_REV1_RGB_PINOUT_
  output_enable_bits.bits.output_enable_rev1
    = output_enable_bits.bits.output_enable_rev2 = 1;
#endif
  output_enable_bits.bits.output_enable = 1;

  std::vector<int> bitplane_timings;
  for (int b = 0; b < kBitPlanes; ++b) {
    bitplane_timings.push_back(kBaseTimeNanos << b);
  }
  sOutputEnablePulser = PinPulser::Create(io, output_enable_bits.raw,
                                          bitplane_timings);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpq $0x0, 0x71c1(%rip)      # 0xe1c8
je 0x700e
jmp 0x7278
leaq -0x10(%rbp), %rdi
callq 0x80f0
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffbffff, %eax       # imm = 0xFFFBFFFF
orl $0x40000, %eax          # imm = 0x40000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffdffff, %eax       # imm = 0xFFFDFFFF
orl $0x20000, %eax          # imm = 0x20000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $-0x11, %eax
orl $0x10, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
orl $0x80, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xf7ffffff, %eax       # imm = 0xF7FFFFFF
orl $0x8000000, %eax        # imm = 0x8000000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
orl $0x800, %eax            # imm = 0x800
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffffbff, %eax       # imm = 0xFFFFFBFF
orl $0x400, %eax            # imm = 0x400
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
orl $0x200, %eax            # imm = 0x200
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x10(%rbp)
cmpl $0x2, -0xc(%rbp)
jl 0x7108
movl -0x10(%rbp), %eax
andl $-0x41, %eax
orl $0x40, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $-0x21, %eax
orl $0x20, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffffefff, %eax       # imm = 0xFFFFEFFF
orl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffefffff, %eax       # imm = 0xFFEFFFFF
orl $0x100000, %eax         # imm = 0x100000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffffdfff, %eax       # imm = 0xFFFFDFFF
orl $0x2000, %eax           # imm = 0x2000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfff7ffff, %eax       # imm = 0xFFF7FFFF
orl $0x80000, %eax          # imm = 0x80000
movl %eax, -0x10(%rbp)
cmpl $0x3, -0xc(%rbp)
jl 0x7166
movl -0x10(%rbp), %eax
andl $-0x9, %eax
orl $0x8, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $-0x5, %eax
orl $0x4, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffffbfff, %eax       # imm = 0xFFFFBFFF
orl $0x4000, %eax           # imm = 0x4000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffdfffff, %eax       # imm = 0xFFDFFFFF
orl $0x200000, %eax         # imm = 0x200000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfffeffff, %eax       # imm = 0xFFFEFFFF
orl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfbffffff, %eax       # imm = 0xFBFFFFFF
orl $0x4000000, %eax        # imm = 0x4000000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfdffffff, %eax       # imm = 0xFDFFFFFF
orl $0x2000000, %eax        # imm = 0x2000000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xfeffffff, %eax       # imm = 0xFEFFFFFF
orl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xff7fffff, %eax       # imm = 0xFF7FFFFF
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0xffbfffff, %eax       # imm = 0xFFBFFFFF
orl $0x400000, %eax         # imm = 0x400000
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x2660
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x71bf
jmp 0x71de
leaq 0x21f2(%rip), %rdi      # 0x93b8
leaq 0x217f(%rip), %rsi      # 0x934c
movl $0x78, %edx
leaq 0x21ef(%rip), %rcx      # 0x93c8
callq 0x2110
leaq -0x18(%rbp), %rdi
callq 0x80f0
movl -0x18(%rbp), %eax
andl $0xfffbffff, %eax       # imm = 0xFFFBFFFF
orl $0x40000, %eax          # imm = 0x40000
movl %eax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x34d0
movl $0x0, -0x34(%rbp)
cmpl $0xb, -0x34(%rbp)
jge 0x724e
movb -0x34(%rbp), %cl
movl $0x82, %eax
shlq %cl, %rax
movl %eax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3510
jmp 0x722a
jmp 0x722c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3590
jmp 0x727e
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq -0x30(%rbp), %rdx
callq 0x29d0
movq %rax, -0x50(%rbp)
jmp 0x7264
movq -0x50(%rbp), %rax
movq %rax, 0x6f59(%rip)      # 0xe1c8
leaq -0x30(%rbp), %rdi
callq 0x3590
addq $0x50, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x22b0
nopw (%rax,%rax)