// File: Lut99[P]RayTracer/src/lib/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] * (1u + (passw[i] * bpp + 7u) / 8u) : 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 + 7u) / 8u);
    /*only padded at end of reduced image*/
    passstart[i + 1] = passstart[i] + (passh[i] * passw[i] * bpp + 7u) / 8u;
  }
}

// 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 0x150767
movl -0x2c(%rsp), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x25fa6(%rip), %rcx     # 0x176640
addl (%rcx,%rdx,4), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x25fb6(%rip), %rcx     # 0x176660
subl (%rcx,%rdx,4), %eax
subl $0x1, %eax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
leaq 0x25f83(%rip), %rcx     # 0x176640
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 0x25f9f(%rip), %rcx     # 0x176680
addl (%rcx,%rdx,4), %eax
movl -0x30(%rsp), %ecx
movl %ecx, %edx
leaq 0x25faf(%rip), %rcx     # 0x1766a0
subl (%rcx,%rdx,4), %eax
subl $0x1, %eax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
leaq 0x25f7c(%rip), %rcx     # 0x176680
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 0x150736
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 0x150755
movq -0x8(%rsp), %rax
movl -0x30(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
jmp 0x150757
movl -0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rsp)
jmp 0x15067e
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 0x1508c7
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 0x1507fd
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x1507fd
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 0x150805
xorl %eax, %eax
movl %eax, -0x3c(%rsp)
jmp 0x150805
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 0x150793
retq
nopl (%rax,%rax)