#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ build_downsample_pixelprop_table(int *, float *, int const);
int /*<<< orphan*/ downsample_component_line(unsigned char *, unsigned char *,
                                             int, int const, int const, int,
                                             int *, float *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, unsigned char, int const);
int return_downscaled_array_len(int, int const, int const);
void downsample_component(unsigned char *carray, int width, int height,
                          const int xpos, const int ypos, const int xstep,
                          const int ystep, int *out_width, int *out_height) {
  int x_pixel_len = (xstep * 2) - 1;
  int x_pixel_coord[x_pixel_len];
  float x_pixel_percent[x_pixel_len];
  unsigned char x_out_buff[width];
  unsigned char x_in_buff[width + (xstep - 1) * 2];
  int y_pixel_len = (ystep * 2) - 1;
  int y_pixel_coord[y_pixel_len];
  float y_pixel_percent[y_pixel_len];
  unsigned char y_out_buff[height];
  unsigned char y_in_buff[height + (ystep - 1) * 2];
  int linecount;
  unsigned char *datastart;
  int i;
  *out_width = width;
  *out_height = height;
  build_downsample_pixelprop_table(x_pixel_coord, x_pixel_percent, xstep);
  build_downsample_pixelprop_table(y_pixel_coord, y_pixel_percent, ystep);
  *out_height = return_downscaled_array_len(height, ypos, ystep);
  if ((ystep != 1) || (ypos != 0)) {
    for (linecount = 0; linecount < width; linecount++) {
      datastart = carray + linecount;
      memset(y_in_buff, *datastart, ystep - 1);
      memset((y_in_buff + ystep - 1 + height),
             *(datastart + ((height - 1) * width)), ystep - 1);
      for (i = 0; i < height; i++)
        *(y_in_buff + (ystep - 1) + i) = *(datastart + (width * i));
      downsample_component_line(y_in_buff + (ystep - 1), y_out_buff, height,
                                ypos, ystep, y_pixel_len, y_pixel_coord,
                                y_pixel_percent);
      for (i = 0; i < *out_height; i++)
        *(datastart + (width * i)) = *(y_out_buff + i);
    }
  }
  *out_width = return_downscaled_array_len(width, xpos, xstep);
  if ((xstep != 1) || (xpos != 0)) {
    for (linecount = 0; linecount < *out_height; linecount++) {
      datastart = carray + (linecount * width);
      memset(x_in_buff, *datastart, xstep - 1);
      memset((x_in_buff + xstep - 1 + width), *(datastart + (width - 1)),
             xstep - 1);
      memcpy(x_in_buff + (xstep - 1), datastart, width);
      downsample_component_line(x_in_buff + (xstep - 1), x_out_buff, width,
                                xpos, xstep, x_pixel_len, x_pixel_coord,
                                x_pixel_percent);
      memcpy(datastart, x_out_buff, *out_width);
    }
  }
}


x86 assembly (clang, -O0):
<downsample_component>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    %ecx,%eax
lea    -0x1(%rax,%rax,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xc8(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0xc0(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    -0x2(%rax,%rcx,2),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    0x10(%rbp),%ecx
mov    %ecx,%eax
lea    -0x1(%rax,%rax,1),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    -0x4c(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%edx
mov    0x10(%rbp),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    -0x2(%rax,%rcx,2),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
mov    -0xc(%rbp),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%edx
call   1070 <build_downsample_pixelprop_table@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    0x10(%rbp),%edx
call   1070 <build_downsample_pixelprop_table@plt>
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    0x10(%rbp),%edx
call   1030 <return_downscaled_array_len@plt>
mov    %eax,%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,0x10(%rbp)
jne    131e <downsample_component+0x1ce>
cmpl   $0x0,-0x18(%rbp)
je     14ad <downsample_component+0x35d>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    14a8 <downsample_component+0x358>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    (%rax),%al
mov    0x10(%rbp),%edx
sub    $0x1,%edx
movzbl %al,%esi
call   1040 <memset@plt>
mov    -0xa0(%rbp),%rdi
movslq 0x10(%rbp),%rax
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0x80(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    0x10(%rbp),%edx
sub    $0x1,%edx
movzbl %al,%esi
call   1040 <memset@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    13f4 <downsample_component+0x2a4>
mov    -0xa0(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    -0xc(%rbp),%edx
imul   -0x84(%rbp),%edx
movslq %edx,%rdx
mov    (%rcx,%rdx,1),%dl
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x84(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    13a0 <downsample_component+0x250>
mov    -0x90(%rbp),%rax
mov    -0x98(%rbp),%r10
mov    -0xa8(%rbp),%rsi
mov    -0xa0(%rbp),%rdi
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rdi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
sub    $0x10,%rsp
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <downsample_component_line@plt>
add    $0x10,%rsp
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    1495 <downsample_component+0x345>
mov    -0xa8(%rbp),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x80(%rbp),%rax
mov    -0xc(%rbp),%ecx
imul   -0x84(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    144a <downsample_component+0x2fa>
jmp    149a <downsample_component+0x34a>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1325 <downsample_component+0x1d5>
jmp    14ad <downsample_component+0x35d>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <return_downscaled_array_len@plt>
mov    %eax,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x1c(%rbp)
jne    14d7 <downsample_component+0x387>
cmpl   $0x0,-0x14(%rbp)
je     15e7 <downsample_component+0x497>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    15e2 <downsample_component+0x492>
mov    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x74(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    (%rax),%al
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
movzbl %al,%esi
call   1040 <memset@plt>
mov    -0xb0(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x80(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
movzbl %al,%esi
call   1040 <memset@plt>
mov    -0xb0(%rbp),%rdi
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x80(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xc8(%rbp),%r10
mov    -0xb8(%rbp),%rsi
mov    -0xc0(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rdi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
sub    $0x10,%rsp
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <downsample_component_line@plt>
mov    -0xb8(%rbp),%rsi
add    $0x10,%rsp
mov    -0x80(%rbp),%rdi
mov    0x18(%rbp),%rax
mov    (%rax),%edx
call   1050 <memcpy@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    14de <downsample_component+0x38e>
jmp    15e7 <downsample_component+0x497>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<downsample_component>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %r8d,-0x48(%rbp)
mov    %ecx,-0x44(%rbp)
mov    %rdi,%rbx
movslq 0x10(%rbp),%r15
mov    0x20(%rbp),%r10
mov    0x18(%rbp),%r8
lea    (%r9,%r9,1),%eax
add    $0xffffffff,%eax
mov    %rax,-0xc8(%rbp)
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rdi
sub    %rax,%rdi
mov    %rdi,%rsp
mov    %rsp,%r11
sub    %rax,%r11
mov    %r11,%rsp
mov    %esi,%r14d
mov    %rsp,%rcx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
lea    (%rsi,%r9,2),%eax
add    $0xfffffffe,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %r15,%rcx
mov    %r15,-0x58(%rbp)
lea    (%r15,%r15,1),%eax
add    $0xffffffff,%eax
mov    %rax,-0xf8(%rbp)
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %edx,%eax
mov    %rsp,%r15
mov    %rax,-0x50(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x88(%rbp)
lea    (%rdx,%rax,2),%eax
mov    %rdx,-0x38(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rsi,-0x40(%rbp)
mov    %esi,(%r8)
mov    %edx,(%r10)
mov    %rdi,-0xc0(%rbp)
mov    %r11,-0xb8(%rbp)
mov    %r11,%rsi
mov    %r9,-0x78(%rbp)
mov    %r9d,%edx
call   1070 <build_downsample_pixelprop_table@plt>
mov    %r12,-0xf0(%rbp)
mov    %r12,%rdi
mov    %r13,-0xe8(%rbp)
mov    %r13,%rsi
mov    -0x58(%rbp),%r13
mov    %r13d,%edx
call   1070 <build_downsample_pixelprop_table@plt>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%r12d
mov    %r12d,%esi
mov    %r13d,%edx
call   1030 <return_downscaled_array_len@plt>
mov    0x20(%rbp),%rcx
mov    %eax,(%rcx)
mov    %r13d,%eax
xor    $0x1,%eax
or     %r12d,%eax
je     14cb <downsample_component+0x37b>
cmpl   $0x0,-0x40(%rbp)
jle    14cb <downsample_component+0x37b>
movslq -0x58(%rbp),%rax
mov    -0x80(%rbp),%rsi
add    %rsi,%rax
mov    -0x38(%rbp),%rdx
movslq %edx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0xd8(%rbp)
lea    -0x1(%rdx),%eax
imul   -0x40(%rbp),%eax
cltq
mov    %rax,-0xd0(%rbp)
mov    -0x88(%rbp),%rcx
lea    (%rsi,%rcx,1),%rax
mov    %rax,-0x90(%rbp)
mov    -0x50(%rbp),%rax
lea    -0x1(%rax),%rdx
mov    %rdx,-0xb0(%rbp)
mov    %eax,%r12d
and    $0x3,%r12d
and    $0xfffffffc,%eax
mov    %rax,-0x50(%rbp)
lea    0x0(,%r14,4),%rax
mov    %rax,-0xa8(%rbp)
lea    (%rsi,%rcx,1),%r13
add    $0x3,%r13
lea    (%r14,%r14,2),%rax
mov    %rax,-0xa0(%rbp)
xor    %eax,%eax
mov    %rbx,-0x30(%rbp)
mov    %rbx,-0xe0(%rbp)
jmp    137d <downsample_component+0x22d>
nopw   0x0(%rax,%rax,1)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
addq   $0x1,-0x30(%rbp)
cmp    %r14,%rax
mov    -0xe0(%rbp),%rbx
je     14cb <downsample_component+0x37b>
lea    (%rbx,%rax,1),%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,-0x68(%rbp)
movzbl (%rbx,%rax,1),%esi
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rbx
mov    %ebx,%edx
call   1040 <memset@plt>
mov    -0xd0(%rbp),%rax
mov    -0x60(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
mov    -0xd8(%rbp),%rdi
mov    %ebx,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x38(%rbp)
jle    1462 <downsample_component+0x312>
cmpq   $0x3,-0xb0(%rbp)
03
jae    13e0 <downsample_component+0x290>
xor    %eax,%eax
jmp    1431 <downsample_component+0x2e1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    -0x50(%rbp),%rsi
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rcx),%edx
mov    %dl,-0x3(%r13,%rax,1)
movzbl (%rcx,%r14,1),%edx
mov    %dl,-0x2(%r13,%rax,1)
movzbl (%rcx,%r14,2),%edx
mov    %dl,-0x1(%r13,%rax,1)
movzbl (%rcx,%rbx,1),%edx
mov    %dl,0x0(%r13,%rax,1)
add    $0x4,%rax
add    %rdi,%rcx
cmp    %rax,%rsi
jne    1400 <downsample_component+0x2b0>
test   %r12,%r12
je     1462 <downsample_component+0x312>
mov    -0x90(%rbp),%rcx
add    %rax,%rcx
imul   %r14,%rax
add    -0x30(%rbp),%rax
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movzbl (%rax),%ebx
mov    %bl,(%rcx,%rdx,1)
add    $0x1,%rdx
add    %r14,%rax
cmp    %rdx,%r12
jne    1450 <downsample_component+0x300>
mov    -0x90(%rbp),%rdi
mov    %r15,%rsi
mov    -0x38(%rbp),%rdx
mov    -0x48(%rbp),%ecx
mov    -0x58(%rbp),%r8
mov    -0xf8(%rbp),%r9
push   -0xe8(%rbp)
push   -0xf0(%rbp)
call   1060 <downsample_component_line@plt>
add    $0x10,%rsp
mov    0x20(%rbp),%rsi
cmpl   $0x0,(%rsi)
jle    1360 <downsample_component+0x210>
mov    -0x30(%rbp),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r15,%rcx,1),%edx
mov    %dl,(%rax)
add    $0x1,%rcx
movslq (%rsi),%rdx
add    %r14,%rax
cmp    %rdx,%rcx
jl     14b0 <downsample_component+0x360>
jmp    1360 <downsample_component+0x210>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%r14d
mov    %r14d,%esi
mov    -0x78(%rbp),%r13
mov    %r13d,%edx
call   1030 <return_downscaled_array_len@plt>
mov    0x18(%rbp),%rcx
mov    %eax,(%rcx)
test   %r14d,%r14d
mov    0x20(%rbp),%rax
mov    -0x98(%rbp),%r12
mov    -0x70(%rbp),%rcx
jne    1506 <downsample_component+0x3b6>
cmp    $0x1,%r13d
je     15d2 <downsample_component+0x482>
cmpl   $0x0,(%rax)
jle    15d2 <downsample_component+0x482>
lea    -0x1(%r13),%edx
movslq %r13d,%rax
add    %rcx,%rax
movslq -0x40(%rbp),%rsi
mov    %rsi,-0x30(%rbp)
add    %rsi,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x68(%rbp)
mov    %edx,-0x38(%rbp)
movslq %edx,%rax
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
xor    %r15d,%r15d
mov    -0x40(%rbp),%r14
movzbl (%rbx),%esi
mov    -0x70(%rbp),%rdi
mov    -0x38(%rbp),%r13d
mov    %r13d,%edx
call   1040 <memset@plt>
mov    -0x30(%rbp),%rax
movzbl -0x1(%rbx,%rax,1),%esi
mov    -0x68(%rbp),%rdi
mov    %r13d,%edx
call   1040 <memset@plt>
mov    -0x60(%rbp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <memcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
mov    -0x44(%rbp),%ecx
mov    -0x78(%rbp),%r13
mov    %r13d,%r8d
mov    -0xc8(%rbp),%r9
push   -0xb8(%rbp)
push   -0xc0(%rbp)
call   1060 <downsample_component_line@plt>
add    $0x10,%rsp
mov    0x18(%rbp),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <memcpy@plt>
mov    0x20(%rbp),%rax
add    $0x1,%r15
movslq (%rax),%rax
add    -0x30(%rbp),%rbx
cmp    %rax,%r15
jl     1540 <downsample_component+0x3f0>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @downsample_component(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i32* %8) {
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i64
%23 = alloca i64
%24 = alloca i64
%25 = alloca i32
%26 = alloca i64
%27 = alloca i64
%28 = alloca i64
%29 = alloca i64
%30 = alloca i32
%31 = alloca i8*
%32 = alloca i32
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32* %7, i32** %17
store i32* %8, i32** %18
%33 = load i32, i32* %15
%34 = mul nsw i32 %33, 2
%35 = sub nsw i32 %34, 1
store i32 %35, i32* %19
%36 = load i32, i32* %19
%37 = zext i32 %36 to i64
%38 = call i8* @llvm.stacksave()
store i8* %38, i8** %20
%39 = alloca i32, i64 %37
store i64 %37, i64* %21
%40 = load i32, i32* %19
%41 = zext i32 %40 to i64
%42 = alloca float, i64 %41
store i64 %41, i64* %22
%43 = load i32, i32* %11
%44 = zext i32 %43 to i64
%45 = alloca i8, i64 %44
store i64 %44, i64* %23
%46 = load i32, i32* %11
%47 = load i32, i32* %15
%48 = sub nsw i32 %47, 1
%49 = mul nsw i32 %48, 2
%50 = add nsw i32 %46, %49
%51 = zext i32 %50 to i64
%52 = alloca i8, i64 %51
store i64 %51, i64* %24
%53 = load i32, i32* %16
%54 = mul nsw i32 %53, 2
%55 = sub nsw i32 %54, 1
store i32 %55, i32* %25
%56 = load i32, i32* %25
%57 = zext i32 %56 to i64
%58 = alloca i32, i64 %57
store i64 %57, i64* %26
%59 = load i32, i32* %25
%60 = zext i32 %59 to i64
%61 = alloca float, i64 %60
store i64 %60, i64* %27
%62 = load i32, i32* %12
%63 = zext i32 %62 to i64
%64 = alloca i8, i64 %63
store i64 %63, i64* %28
%65 = load i32, i32* %12
%66 = load i32, i32* %16
%67 = sub nsw i32 %66, 1
%68 = mul nsw i32 %67, 2
%69 = add nsw i32 %65, %68
%70 = zext i32 %69 to i64
%71 = alloca i8, i64 %70
store i64 %70, i64* %29
%72 = load i32, i32* %11
%73 = load i32*, i32** %17
store i32 %72, i32* %73
%74 = load i32, i32* %12
%75 = load i32*, i32** %18
store i32 %74, i32* %75
%76 = load i32, i32* %15
%77 = call i32 @build_downsample_pixelprop_table(i32* %39, float* %42, i32 %76)
%78 = load i32, i32* %16
%79 = call i32 @build_downsample_pixelprop_table(i32* %58, float* %61, i32 %78)
%80 = load i32, i32* %12
%81 = load i32, i32* %14
%82 = load i32, i32* %16
%83 = call i32 @return_downscaled_array_len(i32 %80, i32 %81, i32 %82)
%84 = load i32*, i32** %18
store i32 %83, i32* %84
%85 = load i32, i32* %16
%86 = icmp ne i32 %85, 1
br i1 %86, label %90, label %87
87: ; preds = %9
%88 = load i32, i32* %14
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %179
90: ; preds = %87, %9
store i32 0, i32* %30
br label %91
91: ; preds = %175, %90
%92 = load i32, i32* %30
%93 = load i32, i32* %11
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %178
95: ; preds = %91
%96 = load i8*, i8** %10
%97 = load i32, i32* %30
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
store i8* %99, i8** %31
%100 = load i8*, i8** %31
%101 = load i8, i8* %100
%102 = load i32, i32* %16
%103 = sub nsw i32 %102, 1
%104 = call i32 @memset(i8* %71, i8 zeroext %101, i32 %103)
%105 = load i32, i32* %16
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %71, i64 %106
%108 = getelementptr inbounds i8, i8* %107, i64 -1
%109 = load i32, i32* %12
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %108, i64 %110
%112 = load i8*, i8** %31
%113 = load i32, i32* %12
%114 = sub nsw i32 %113, 1
%115 = load i32, i32* %11
%116 = mul nsw i32 %114, %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %112, i64 %117
%119 = load i8, i8* %118
%120 = load i32, i32* %16
%121 = sub nsw i32 %120, 1
%122 = call i32 @memset(i8* %111, i8 zeroext %119, i32 %121)
store i32 0, i32* %32
br label %123
123: ; preds = %142, %95
%124 = load i32, i32* %32
%125 = load i32, i32* %12
%126 = icmp slt i32 %124, %125
br i1 %126, label %127, label %145
127: ; preds = %123
%128 = load i8*, i8** %31
%129 = load i32, i32* %11
%130 = load i32, i32* %32
%131 = mul nsw i32 %129, %130
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %128, i64 %132
%134 = load i8, i8* %133
%135 = load i32, i32* %16
%136 = sub nsw i32 %135, 1
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %71, i64 %137
%139 = load i32, i32* %32
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %138, i64 %140
store i8 %134, i8* %141
br label %142
142: ; preds = %127
%143 = load i32, i32* %32
%144 = add nsw i32 %143, 1
store i32 %144, i32* %32
br label %123
145: ; preds = %123
%146 = load i32, i32* %16
%147 = sub nsw i32 %146, 1
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %71, i64 %148
%150 = load i32, i32* %12
%151 = load i32, i32* %14
%152 = load i32, i32* %16
%153 = load i32, i32* %25
%154 = call i32 @downsample_component_line(i8* %149, i8* %64, i32 %150, i32 %151, i32 %152, i32 %153, i32* %58, float* %61)
store i32 0, i32* %32
br label %155
155: ; preds = %171, %145
%156 = load i32, i32* %32
%157 = load i32*, i32** %18
%158 = load i32, i32* %157
%159 = icmp slt i32 %156, %158
br i1 %159, label %160, label %174
160: ; preds = %155
%161 = load i32, i32* %32
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %64, i64 %162
%164 = load i8, i8* %163
%165 = load i8*, i8** %31
%166 = load i32, i32* %11
%167 = load i32, i32* %32
%168 = mul nsw i32 %166, %167
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i8, i8* %165, i64 %169
store i8 %164, i8* %170
br label %171
171: ; preds = %160
%172 = load i32, i32* %32
%173 = add nsw i32 %172, 1
store i32 %173, i32* %32
br label %155
174: ; preds = %155
br label %175
175: ; preds = %174
%176 = load i32, i32* %30
%177 = add nsw i32 %176, 1
store i32 %177, i32* %30
br label %91
178: ; preds = %91
br label %179
179: ; preds = %178, %87
%180 = load i32, i32* %11
%181 = load i32, i32* %13
%182 = load i32, i32* %15
%183 = call i32 @return_downscaled_array_len(i32 %180, i32 %181, i32 %182)
%184 = load i32*, i32** %17
store i32 %183, i32* %184
%185 = load i32, i32* %15
%186 = icmp ne i32 %185, 1
br i1 %186, label %190, label %187
187: ; preds = %179
%188 = load i32, i32* %13
%189 = icmp ne i32 %188, 0
br i1 %189, label %190, label %248
190: ; preds = %187, %179
store i32 0, i32* %30
br label %191
191: ; preds = %244, %190
%192 = load i32, i32* %30
%193 = load i32*, i32** %18
%194 = load i32, i32* %193
%195 = icmp slt i32 %192, %194
br i1 %195, label %196, label %247
196: ; preds = %191
%197 = load i8*, i8** %10
%198 = load i32, i32* %30
%199 = load i32, i32* %11
%200 = mul nsw i32 %198, %199
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds i8, i8* %197, i64 %201
store i8* %202, i8** %31
%203 = load i8*, i8** %31
%204 = load i8, i8* %203
%205 = load i32, i32* %15
%206 = sub nsw i32 %205, 1
%207 = call i32 @memset(i8* %52, i8 zeroext %204, i32 %206)
%208 = load i32, i32* %15
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds i8, i8* %52, i64 %209
%211 = getelementptr inbounds i8, i8* %210, i64 -1
%212 = load i32, i32* %11
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds i8, i8* %211, i64 %213
%215 = load i8*, i8** %31
%216 = load i32, i32* %11
%217 = sub nsw i32 %216, 1
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i8, i8* %215, i64 %218
%220 = load i8, i8* %219
%221 = load i32, i32* %15
%222 = sub nsw i32 %221, 1
%223 = call i32 @memset(i8* %214, i8 zeroext %220, i32 %222)
%224 = load i32, i32* %15
%225 = sub nsw i32 %224, 1
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds i8, i8* %52, i64 %226
%228 = load i8*, i8** %31
%229 = load i32, i32* %11
%230 = call i32 @memcpy(i8* %227, i8* %228, i32 %229)
%231 = load i32, i32* %15
%232 = sub nsw i32 %231, 1
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds i8, i8* %52, i64 %233
%235 = load i32, i32* %11
%236 = load i32, i32* %13
%237 = load i32, i32* %15
%238 = load i32, i32* %19
%239 = call i32 @downsample_component_line(i8* %234, i8* %45, i32 %235, i32 %236, i32 %237, i32 %238, i32* %39, float* %42)
%240 = load i8*, i8** %31
%241 = load i32*, i32** %17
%242 = load i32, i32* %241
%243 = call i32 @memcpy(i8* %240, i8* %45, i32 %242)
br label %244
244: ; preds = %196
%245 = load i32, i32* %30
%246 = add nsw i32 %245, 1
store i32 %246, i32* %30
br label %191
247: ; preds = %191
br label %248
248: ; preds = %247, %187
%249 = load i8*, i8** %20
ret void
}

LLVM IR (-O2):
define void @downsample_component(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* nocapture %7, i32* nocapture %8) {
%10 = shl nsw i32 %5, 1
%11 = add nsw i32 %10, -1
%12 = zext i32 %11 to i64
%13 = alloca i32, i64 %12
%14 = alloca float, i64 %12
%15 = zext i32 %1 to i64
%16 = alloca i8, i64 %15
%17 = add nsw i32 %5, -1
%18 = shl nsw i32 %17, 1
%19 = add nsw i32 %18, %1
%20 = zext i32 %19 to i64
%21 = alloca i8, i64 %20
%22 = shl nsw i32 %6, 1
%23 = add nsw i32 %22, -1
%24 = zext i32 %23 to i64
%25 = alloca i32, i64 %24
%26 = alloca float, i64 %24
%27 = zext i32 %2 to i64
%28 = alloca i8, i64 %27
%29 = add nsw i32 %6, -1
%30 = shl nsw i32 %29, 1
%31 = add nsw i32 %30, %2
%32 = zext i32 %31 to i64
%33 = alloca i8, i64 %32
store i32 %1, i32* %7
store i32 %2, i32* %8
%34 = call i32 @build_downsample_pixelprop_table(i32* %13, float* %14, i32 %5)
%35 = call i32 @build_downsample_pixelprop_table(i32* %25, float* %26, i32 %6)
%36 = call i32 @return_downscaled_array_len(i32 %2, i32 %4, i32 %6)
store i32 %36, i32* %8
%37 = icmp ne i32 %6, 1
%38 = icmp ne i32 %4, 0
%39 = or i1 %38, %37
%40 = icmp sgt i32 %1, 0
%41 = and i1 %39, %40
br i1 %41, label %42, label %123
42: ; preds = %9
%43 = sext i32 %6 to i64
%44 = getelementptr inbounds i8, i8* %33, i64 %43
%45 = getelementptr inbounds i8, i8* %44, i64 -1
%46 = sext i32 %2 to i64
%47 = getelementptr inbounds i8, i8* %45, i64 %46
%48 = add nsw i32 %2, -1
%49 = mul nsw i32 %48, %1
%50 = sext i32 %49 to i64
%51 = icmp sgt i32 %2, 0
%52 = sext i32 %29 to i64
%53 = getelementptr inbounds i8, i8* %33, i64 %52
%54 = zext i32 %1 to i64
%55 = add nsw i64 %27, -1
%56 = and i64 %27, 3
%57 = icmp ult i64 %55, 3
%58 = and i64 %27, 4294967292
%59 = icmp eq i64 %56, 0
br label %60
60: ; preds = %42, %120
%61 = phi i64 [ 0, %42 ], [ %121, %120 ]
%62 = getelementptr inbounds i8, i8* %0, i64 %61
%63 = load i8, i8* %62
%64 = call i32 @memset(i8* %33, i8 zeroext %63, i32 %29)
%65 = getelementptr inbounds i8, i8* %62, i64 %50
%66 = load i8, i8* %65
%67 = call i32 @memset(i8* %47, i8 zeroext %66, i32 %29)
br i1 %51, label %68, label %106
68: ; preds = %60
br i1 %57, label %94, label %69
69: ; preds = %68, %69
%70 = phi i64 [ %91, %69 ], [ 0, %68 ]
%71 = phi i64 [ %92, %69 ], [ 0, %68 ]
%72 = mul nsw i64 %70, %54
%73 = getelementptr inbounds i8, i8* %62, i64 %72
%74 = load i8, i8* %73
%75 = getelementptr inbounds i8, i8* %53, i64 %70
store i8 %74, i8* %75
%76 = or i64 %70, 1
%77 = mul nsw i64 %76, %54
%78 = getelementptr inbounds i8, i8* %62, i64 %77
%79 = load i8, i8* %78
%80 = getelementptr inbounds i8, i8* %53, i64 %76
store i8 %79, i8* %80
%81 = or i64 %70, 2
%82 = mul nsw i64 %81, %54
%83 = getelementptr inbounds i8, i8* %62, i64 %82
%84 = load i8, i8* %83
%85 = getelementptr inbounds i8, i8* %53, i64 %81
store i8 %84, i8* %85
%86 = or i64 %70, 3
%87 = mul nsw i64 %86, %54
%88 = getelementptr inbounds i8, i8* %62, i64 %87
%89 = load i8, i8* %88
%90 = getelementptr inbounds i8, i8* %53, i64 %86
store i8 %89, i8* %90
%91 = add nuw nsw i64 %70, 4
%92 = add i64 %71, 4
%93 = icmp eq i64 %92, %58
br i1 %93, label %94, label %69
94: ; preds = %69, %68
%95 = phi i64 [ 0, %68 ], [ %91, %69 ]
br i1 %59, label %106, label %96
96: ; preds = %94, %96
%97 = phi i64 [ %103, %96 ], [ %95, %94 ]
%98 = phi i64 [ %104, %96 ], [ 0, %94 ]
%99 = mul nsw i64 %97, %54
%100 = getelementptr inbounds i8, i8* %62, i64 %99
%101 = load i8, i8* %100
%102 = getelementptr inbounds i8, i8* %53, i64 %97
store i8 %101, i8* %102
%103 = add nuw nsw i64 %97, 1
%104 = add i64 %98, 1
%105 = icmp eq i64 %104, %56
br i1 %105, label %106, label %96
106: ; preds = %94, %96, %60
%107 = call i32 @downsample_component_line(i8* %53, i8* %28, i32 %2, i32 %4, i32 %6, i32 %23, i32* %25, float* %26)
%108 = load i32, i32* %8
%109 = icmp sgt i32 %108, 0
br i1 %109, label %110, label %120
110: ; preds = %106, %110
%111 = phi i64 [ %116, %110 ], [ 0, %106 ]
%112 = getelementptr inbounds i8, i8* %28, i64 %111
%113 = load i8, i8* %112
%114 = mul nsw i64 %111, %54
%115 = getelementptr inbounds i8, i8* %62, i64 %114
store i8 %113, i8* %115
%116 = add nuw nsw i64 %111, 1
%117 = load i32, i32* %8
%118 = sext i32 %117 to i64
%119 = icmp slt i64 %116, %118
br i1 %119, label %110, label %120
120: ; preds = %110, %106
%121 = add nuw nsw i64 %61, 1
%122 = icmp eq i64 %121, %15
br i1 %122, label %123, label %60
123: ; preds = %120, %9
%124 = call i32 @return_downscaled_array_len(i32 %1, i32 %3, i32 %5)
store i32 %124, i32* %7
%125 = icmp ne i32 %5, 1
%126 = icmp ne i32 %3, 0
%127 = or i1 %126, %125
br i1 %127, label %128, label %158
128: ; preds = %123
%129 = load i32, i32* %8
%130 = icmp sgt i32 %129, 0
br i1 %130, label %131, label %158
131: ; preds = %128
%132 = sext i32 %5 to i64
%133 = getelementptr inbounds i8, i8* %21, i64 %132
%134 = getelementptr inbounds i8, i8* %133, i64 -1
%135 = sext i32 %1 to i64
%136 = getelementptr inbounds i8, i8* %134, i64 %135
%137 = add nsw i32 %1, -1
%138 = sext i32 %137 to i64
%139 = sext i32 %17 to i64
%140 = getelementptr inbounds i8, i8* %21, i64 %139
br label %141
141: ; preds = %131, %141
%142 = phi i64 [ 0, %131 ], [ %154, %141 ]
%143 = mul nsw i64 %142, %135
%144 = getelementptr inbounds i8, i8* %0, i64 %143
%145 = load i8, i8* %144
%146 = call i32 @memset(i8* %21, i8 zeroext %145, i32 %17)
%147 = getelementptr inbounds i8, i8* %144, i64 %138
%148 = load i8, i8* %147
%149 = call i32 @memset(i8* %136, i8 zeroext %148, i32 %17)
%150 = call i32 @memcpy(i8* %140, i8* %144, i32 %1)
%151 = call i32 @downsample_component_line(i8* %140, i8* %16, i32 %1, i32 %3, i32 %5, i32 %11, i32* %13, float* %14)
%152 = load i32, i32* %7
%153 = call i32 @memcpy(i8* %144, i8* %16, i32 %152)
%154 = add nuw nsw i64 %142, 1
%155 = load i32, i32* %8
%156 = sext i32 %155 to i64
%157 = icmp slt i64 %154, %156
br i1 %157, label %141, label %158
158: ; preds = %141, %128, %123
ret void
}