// File: /workspace/github_c_makefile_star2_O1/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:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %r8d, %r8d
jle 0x15e4
testl %ecx, %ecx
jle 0x15e4
cmpl $0xf4240, %r8d          # imm = 0xF4240
jg 0x15e4
cmpl $0xf4240, %ecx          # imm = 0xF4240
jg 0x15e4
movl %edx, %r11d
testl %edx, %edx
jle 0x15e4
testl %esi, %esi
jle 0x15e4
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r15
testq %rdi, %rdi
je 0x15d6
cmpl $0xf4240, %esi          # imm = 0xF4240
jg 0x15d6
cmpl $0xf4240, %r11d         # imm = 0xF4240
jg 0x15d6
movl %r9d, %r10d
movss 0x5ec4(%rip), %xmm0     # 0x72c0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1429
jp 0x1429
movl %r11d, %ebx
movq %rsi, %r14
movl %r8d, %ebp
movq %rcx, %r12
movl %r10d, %r13d
callq 0x122c
movl %r13d, %r10d
movq %r12, %rcx
movl %ebp, %r8d
movq %r14, %rsi
movl %ebx, %r11d
movl $0x4, %r9d
movl $0x4, %r13d
cmpl %ecx, %r8d
jg 0x1450
leal (,%rcx,4), %eax
xorl %edx, %edx
divl %r8d
movl %eax, %r13d
andl $0x7ffffffe, %r13d      # imm = 0x7FFFFFFE
movl $0x4, %eax
cmpl %esi, %r11d
jg 0x146e
leal (,%rsi,4), %eax
cltd
idivl %r11d
andl $-0x2, %eax
movl $0x1, %r9d
cmpl %r8d, %ecx
movl %r8d, %edi
cmovgl %ecx, %edi
movl %r8d, %ebp
cmovll %ecx, %ebp
shll $0x4, %edi
shll $0x2, %ebp
cmpl %r11d, %esi
movl %r11d, %r12d
cmovgl %esi, %r12d
movl %r11d, %r14d
cmovll %esi, %r14d
shll $0x4, %r12d
shll $0x2, %r14d
movzbl %r10b, %ebx
imull %r8d, %ebx
cmpl %eax, %r13d
cmovgl %r13d, %eax
shll $0x2, %eax
movl %eax, 0x14(%rsp)
movl %ebx, %edx
shll $0x4, %edx
xorl %r13d, %r13d
cmpl %esi, %r11d
cmovlel %edx, %r13d
imull %r9d, %ebx
shll $0x2, %ebx
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movq $0x0, 0x50(%r15)
movq %rsi, 0x20(%rsp)
movl %esi, (%r15)
movl %r11d, 0x10(%rsp)
movl %r11d, 0x4(%r15)
movq %rcx, 0x18(%rsp)
movl %ecx, 0x8(%r15)
movl %r8d, 0xc(%rsp)
movl %r8d, 0xc(%r15)
movl %r10d, 0x10(%r15)
movslq %edi, %rsi
movl $0x1, %edi
callq 0x10d0
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%r15)
movslq %ebp, %rsi
movl %r13d, %ebp
movl $0x1, %edi
callq 0x10d0
movq %rax, %r13
movq %rax, 0x30(%r15)
movslq %r12d, %rsi
movl $0x1, %edi
callq 0x10d0
movq %rax, %r12
movq %rax, 0x20(%r15)
movslq %r14d, %rsi
movl $0x1, %edi
callq 0x10d0
movq %rax, %r14
movq %rax, 0x38(%r15)
movslq %ebx, %rsi
movl $0x1, %edi
callq 0x10d0
movq %rax, %rbx
movq %rax, 0x48(%r15)
movslq %ebp, %rsi
movl $0x1, %edi
callq 0x10d0
movq %rax, 0x28(%rsp)
movq %rax, 0x40(%r15)
movslq 0x14(%rsp), %rdi
callq 0x1100
movq 0x30(%rsp), %rdx
movq %rax, 0x50(%r15)
testq %rdx, %rdx
sete %cl
testq %r13, %r13
sete %dil
orb %cl, %dil
testq %r12, %r12
sete %cl
testq %r14, %r14
sete %sil
orb %cl, %sil
orb %dil, %sil
je 0x15e5
movq %r15, %rdi
callq 0x1635
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x15c9
testq %rax, %rax
je 0x15c9
testl %ebp, %ebp
sete %cl
cmpq $0x0, 0x28(%rsp)
setne %sil
orb %cl, %sil
je 0x15c9
movq 0x18(%rsp), %rdi
movl 0xc(%rsp), %esi
movq %r13, %rcx
movq %rax, %r8
callq 0x16a7
movq 0x20(%r15), %rdx
movq 0x38(%r15), %rcx
movq 0x50(%r15), %r8
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x16a7
xorl %eax, %eax
jmp 0x15d6