// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dsp/rescaler.c
// Function: WebPRescalerImportRowShrink_C
void WebPRescalerImportRowShrink_C(WebPRescaler* const wrk,
                                   const uint8_t* src) {
  const int x_stride = wrk->num_channels;
  const int x_out_max = wrk->dst_width * wrk->num_channels;
  int channel;
  assert(!WebPRescalerInputDone(wrk));
  assert(!wrk->x_expand);
  for (channel = 0; channel < x_stride; ++channel) {
    int x_in = channel;
    int x_out = channel;
    uint32_t sum = 0;
    int accum = 0;
    while (x_out < x_out_max) {
      uint32_t base = 0;
      accum += wrk->x_add;
      while (accum > 0) {
        accum -= wrk->x_sub;
        assert(x_in < wrk->src_width * x_stride);
        base = src[x_in];
        sum += base;
        x_in += x_stride;
      }
      {        // Emit next horizontal pixel.
        const rescaler_t frac = base * (-accum);
        wrk->frow[x_out] = sum * wrk->x_sub - frac;
        // fresh fractional start for next pixel
        sum = (int)MULT_FIX(frac, wrk->fx_scale);
      }
      x_out += x_stride;
    }
    assert(accum == 0);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movq -0x8(%rbp), %rcx
imull 0x8(%rcx), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x150a80
cmpl $0x0, %eax
jne 0x150adc
jmp 0x150afb
leaq 0x6f359(%rip), %rdi     # 0x1bfe3c
leaq 0x6f36e(%rip), %rsi     # 0x1bfe58
movl $0x43, %edx
leaq 0x6f3fd(%rip), %rcx     # 0x1bfef3
callq 0x598a0
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x150b06
jmp 0x150b25
leaq 0x6f42f(%rip), %rdi     # 0x1bff3c
leaq 0x6f344(%rip), %rsi     # 0x1bfe58
movl $0x44, %edx
leaq 0x6f3d3(%rip), %rcx     # 0x1bfef3
callq 0x598a0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x150c6f
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x150c38
movl $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0x150bdd
movq -0x8(%rbp), %rax
movl 0x28(%rax), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x2c(%rcx), %ecx
imull -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x150b9b
jmp 0x150bba
leaq 0x6f312(%rip), %rdi     # 0x1bfeb4
leaq 0x6f2af(%rip), %rsi     # 0x1bfe58
movl $0x4f, %edx
leaq 0x6f33e(%rip), %rcx     # 0x1bfef3
callq 0x598a0
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x150b72
movl -0x30(%rbp), %eax
xorl %ecx, %ecx
subl -0x2c(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x28(%rbp), %edx
movq -0x8(%rbp), %rax
imull 0x28(%rax), %edx
subl -0x34(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq %rcx, %rax
movabsq $0x80000000, %rcx       # imm = 0x80000000
addq %rcx, %rax
shrq $0x20, %rax
movl %eax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x150b52
cmpl $0x0, -0x2c(%rbp)
jne 0x150c40
jmp 0x150c5f
leaq 0x6f2a1(%rip), %rdi     # 0x1bfee8
leaq 0x6f20a(%rip), %rsi     # 0x1bfe58
movl $0x5c, %edx
leaq 0x6f299(%rip), %rcx     # 0x1bfef3
callq 0x598a0
jmp 0x150c61
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x150b2c
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)