// File: phillip-h[P]fractal-gen/lodepng.cpp
// Function: Adam7_getpassvalues(unsigned int*, unsigned int*, unsigned long*, unsigned long*, unsigned long*, unsigned int, unsigned int, unsigned int)
static void Adam7_getpassvalues(unsigned passw[7], unsigned passh[7], size_t filter_passstart[8],
                                size_t padded_passstart[8], size_t passstart[8], unsigned w, unsigned h, unsigned bpp)
{
  /*the passstart values have 8 values: the 8th one indicates the byte after the end of the 7th (= last) pass*/
  unsigned i;

  /*calculate width and height in pixels of each pass*/
  for(i = 0; i != 7; ++i)
  {
    passw[i] = (w + ADAM7_DX[i] - ADAM7_IX[i] - 1) / ADAM7_DX[i];
    passh[i] = (h + ADAM7_DY[i] - ADAM7_IY[i] - 1) / ADAM7_DY[i];
    if(passw[i] == 0) passh[i] = 0;
    if(passh[i] == 0) passw[i] = 0;
  }

  filter_passstart[0] = padded_passstart[0] = passstart[0] = 0;
  for(i = 0; i != 7; ++i)
  {
    /*if passw[i] is 0, it's 0 bytes, not 1 (no filtertype-byte)*/
    filter_passstart[i + 1] = filter_passstart[i]
                            + ((passw[i] && passh[i]) ? passh[i] * (1 + (passw[i] * bpp + 7) / 8) : 0);
    /*bits padded if needed to fill full byte at end of each scanline*/
    padded_passstart[i + 1] = padded_passstart[i] + passh[i] * ((passw[i] * bpp + 7) / 8);
    /*only padded at end of reduced image*/
    passstart[i + 1] = passstart[i] + (passh[i] * passw[i] * bpp + 7) / 8;
  }
}

// Assembly:
movl 0x10(%rsp), %eax
movl 0x8(%rsp), %eax
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movq %rcx, -0x20(%rsp)
movq %r8, -0x28(%rsp)
movl %r9d, -0x2c(%rsp)
movl $0x0, -0x30(%rsp)
cmpl $0x7, -0x30(%rsp)
je 0x177d7
movl -0x2c(%rsp), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x50c6(%rip), %rcx      # 0x1c7d0
addl (%rcx,%rdx,4), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x50d6(%rip), %rcx      # 0x1c7f0
subl (%rcx,%rdx,4), %eax
subl $0x1, %eax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
leaq 0x50a3(%rip), %rcx      # 0x1c7d0
xorl %edx, %edx
divl (%rcx,%rsi,4)
movl %eax, %edx
movq -0x8(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x8(%rsp), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x50bf(%rip), %rcx      # 0x1c810
addl (%rcx,%rdx,4), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x50cf(%rip), %rcx      # 0x1c830
subl (%rcx,%rdx,4), %eax
subl $0x1, %eax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
leaq 0x509c(%rip), %rcx      # 0x1c810
xorl %edx, %edx
divl (%rcx,%rsi,4)
movl %eax, %edx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rsp), %rax
movl -0x30(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jne 0x177a6
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jne 0x177c5
movq -0x8(%rsp), %rax
movl -0x30(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
jmp 0x177c7
movl -0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rsp)
jmp 0x176ee
movq -0x28(%rsp), %rax
movq $0x0, (%rax)
movq -0x20(%rsp), %rax
movq $0x0, (%rax)
movq -0x18(%rsp), %rax
movq $0x0, (%rax)
movl $0x0, -0x30(%rsp)
cmpl $0x7, -0x30(%rsp)
je 0x17937
movq -0x18(%rsp), %rax
movl -0x30(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rsp)
movq -0x8(%rsp), %rax
movl -0x30(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x1786d
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x1786d
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x8(%rsp), %rcx
movl -0x30(%rsp), %edx
movl (%rcx,%rdx,4), %ecx
imull 0x10(%rsp), %ecx
addl $0x7, %ecx
shrl $0x3, %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl %eax, -0x3c(%rsp)
jmp 0x17875
xorl %eax, %eax
movl %eax, -0x3c(%rsp)
jmp 0x17875
movq -0x38(%rsp), %rdx
movl -0x3c(%rsp), %eax
movl %eax, %eax
addq %rax, %rdx
movq -0x18(%rsp), %rax
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rsp), %rax
movl -0x30(%rsp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x8(%rsp), %rcx
movl -0x30(%rsp), %esi
movl (%rcx,%rsi,4), %ecx
imull 0x10(%rsp), %ecx
addl $0x7, %ecx
shrl $0x3, %ecx
imull %ecx, %eax
movl %eax, %eax
addq %rax, %rdx
movq -0x20(%rsp), %rax
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rsp), %rax
movl -0x30(%rsp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x8(%rsp), %rcx
movl -0x30(%rsp), %esi
imull (%rcx,%rsi,4), %eax
imull 0x10(%rsp), %eax
addl $0x7, %eax
shrl $0x3, %eax
movl %eax, %eax
addq %rax, %rdx
movq -0x28(%rsp), %rax
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rsp)
jmp 0x17803
retq
nopl (%rax,%rax)