// File: /workspace/github_c_makefile_star2_O2/ender672[P]liboil/oil_resample.c
// Function: oil_scale_init
int oil_scale_init(struct oil_scale *os, int in_height, int out_height,
	int in_width, int out_width, enum oil_colorspace cs)
{
	int taps_x, taps_y, coeffs_x_len, coeffs_y_len, borders_x_len,
		borders_y_len, rb_len, sums_len, tmp_len;

	if (!os || in_height > MAX_DIMENSION || out_height > MAX_DIMENSION ||
		in_height < 1 || out_height < 1 ||
		in_width > MAX_DIMENSION || out_width > MAX_DIMENSION ||
		in_width < 1 || out_width < 1) {
		return -1;
	}

	// Lazy perform global init, in case oil_global_ini() hasn't been
	// called yet.
	if (!s2l_map[128]) {
		oil_global_init();
	}

	taps_x = calc_taps(in_width, out_width);
	taps_y = calc_taps(in_height, out_height);

	coeffs_x_len = calc_coeffs_len(in_width, out_width);
	borders_x_len = calc_borders_len(in_width, out_width);
	coeffs_y_len = calc_coeffs_len(in_height, out_height);
	borders_y_len = calc_borders_len(in_height, out_height);
	rb_len = out_width * OIL_CMP(cs) * taps_y * sizeof(float);
	tmp_len = max(taps_x, taps_y) * sizeof(float);
	sums_len = 0;
	if (out_height <= in_height) {
		sums_len = out_width * OIL_CMP(cs) * 4 * sizeof(float);
		rb_len = out_width * OIL_CMP(cs) * sizeof(float);
	}

	memset(os, 0, sizeof(struct oil_scale));
	os->in_height = in_height;
	os->out_height = out_height;
	os->in_width = in_width;
	os->out_width = out_width;
	os->cs = cs;
	os->coeffs_x = calloc(1, coeffs_x_len);
	os->borders_x = calloc(1, borders_x_len);
	os->coeffs_y = calloc(1, coeffs_y_len);
	os->borders_y = calloc(1, borders_y_len);
	os->rb = calloc(1, rb_len);
	os->sums_y = calloc(1, sums_len);
	os->tmp_coeffs = malloc(tmp_len);

	if (!os->coeffs_x || !os->borders_x || !os->coeffs_y ||
		!os->borders_y || !os->rb || !os->tmp_coeffs ||
		(sums_len && !os->sums_y)) {
		oil_scale_free(os);
		return -2;
	}

	set_coeffs(in_width, out_width, os->coeffs_x, os->borders_x, os->tmp_coeffs);
	set_coeffs(in_height, out_height, os->coeffs_y, os->borders_y, os->tmp_coeffs);

	return 0;
}

// Assembly:
pushq $-0x1
popq %rax
testl %r8d, %r8d
jle 0x15b9
testl %ecx, %ecx
jle 0x15b9
cmpl $0xf4240, %r8d          # imm = 0xF4240
jg 0x15b9
cmpl $0xf4240, %ecx          # imm = 0xF4240
jg 0x15b9
movl %edx, %r10d
testl %edx, %edx
jle 0x15b9
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %r14d
testl %esi, %esi
jle 0x15ab
movq %rdi, %r15
testq %rdi, %rdi
je 0x15ab
cmpl $0xf4240, %r14d         # imm = 0xF4240
jg 0x15ab
cmpl $0xf4240, %r10d         # imm = 0xF4240
jg 0x15ab
movss 0x5ec5(%rip), %xmm0     # 0x72b0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1412
jp 0x1412
movl %r10d, %ebx
movl %r9d, %r13d
movl %r8d, %ebp
movq %rcx, %r12
callq 0x121c
movq %r12, %rcx
movl %ebp, %r8d
movl %r13d, %r9d
movl %ebx, %r10d
pushq $0x4
popq %rdi
movl %edi, %r11d
cmpl %ecx, %r8d
ja 0x1433
leal (,%rcx,4), %eax
xorl %edx, %edx
divl %r8d
movl %eax, %r11d
andl $0x7ffffffe, %r11d      # imm = 0x7FFFFFFE
movl %edi, %eax
cmpl %r14d, %r10d
jg 0x144c
leal (,%r14,4), %eax
cltd
idivl %r10d
andl $-0x2, %eax
pushq $0x1
popq %rdi
cmpl %r8d, %ecx
movl %r8d, %esi
cmoval %ecx, %esi
movl %r8d, %r12d
cmovbl %ecx, %r12d
shll $0x4, %esi
shll $0x2, %r12d
cmpl %r10d, %r14d
movl %r10d, %ebx
cmovgl %r14d, %ebx
movl %r10d, %r13d
cmovll %r14d, %r13d
shll $0x4, %ebx
shll $0x2, %r13d
movzbl %r9b, %ebp
imull %r8d, %ebp
cmpl %eax, %r11d
cmovgl %r11d, %eax
shll $0x2, %eax
movl %eax, 0x14(%rsp)
movl %ebp, %eax
shll $0x4, %eax
xorl %edx, %edx
cmpl %r14d, %r10d
cmovlel %eax, %edx
movl %edx, 0x10(%rsp)
imull %edi, %ebp
shll $0x2, %ebp
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movq %r14, 0x20(%rsp)
movl %r14d, (%r15)
movl %r10d, 0xc(%rsp)
movl %r10d, 0x4(%r15)
movq %rcx, 0x18(%rsp)
movl %ecx, 0x8(%r15)
movl %r8d, 0x8(%rsp)
movl %r8d, 0xc(%r15)
movl %r9d, 0x10(%r15)
pushq $0x1
popq %r14
movq %r14, %rdi
callq 0x10c0
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%r15)
movq %r14, %rdi
movq %r12, %rsi
callq 0x10c0
movq %rax, %r12
movq %rax, 0x30(%r15)
movslq %ebx, %rsi
movq %r14, %rdi
callq 0x10c0
movq %rax, %rbx
movq %rax, 0x20(%r15)
movslq %r13d, %rsi
movq %r14, %rdi
movq %r14, %r13
callq 0x10c0
movq %rax, %r14
movq %rax, 0x38(%r15)
movslq %ebp, %rsi
movl 0x10(%rsp), %ebp
movq %r13, %rdi
callq 0x10c0
movq %rax, 0x28(%rsp)
movq %rax, 0x48(%r15)
movslq %ebp, %rsi
movq %r13, %rdi
callq 0x10c0
movq %rax, %r13
movq %rax, 0x40(%r15)
movslq 0x14(%rsp), %rdi
callq 0x10f0
movq 0x30(%rsp), %rdx
movq %rax, 0x50(%r15)
movq %rdx, %xmm0
movq %r14, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r12, %xmm1
movq %rbx, %xmm2
punpcklqdq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0]
pxor %xmm2, %xmm2
pcmpeqd %xmm2, %xmm1
pcmpeqd %xmm2, %xmm0
movdqa %xmm1, %xmm2
shufps $0xdd, %xmm0, %xmm2     # xmm2 = xmm2[1,3],xmm0[1,3]
shufps $0x88, %xmm0, %xmm1     # xmm1 = xmm1[0,2],xmm0[0,2]
andps %xmm2, %xmm1
movmskps %xmm1, %esi
testl %esi, %esi
je 0x15ba
movq %r15, %rdi
callq 0x160b
pushq $-0x2
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x28(%rsp)
je 0x15a0
testq %rax, %rax
je 0x15a0
testl %ebp, %ebp
sete %dil
testq %r13, %r13
setne %sil
orb %dil, %sil
je 0x15a0
movq 0x18(%rsp), %rdi
movl 0x8(%rsp), %esi
movq %r12, %rcx
movq %rax, %r8
callq 0x1678
movq 0x20(%r15), %rdx
movq 0x38(%r15), %rcx
movq 0x50(%r15), %r8
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x1678
xorl %eax, %eax
jmp 0x15ab