// File: /workspace/github_c_makefile_star2_O0/albinoloverats[P]hide/src/jpeg-save.c
// Function: fdct_and_quantization
static void fdct_and_quantization(int8_t *data, double *fdtbl, int16_t *outdata)
{
	double tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
	double tmp10, tmp11, tmp12, tmp13;
	double z1, z2, z3, z4, z5, z11, z13;
	double *dataptr;
	double datafloat[64];

	for (int i = 0; i < 64; i++)
		datafloat[i] = data[i];

	// Pass 1: process rows.
	dataptr = datafloat;
	for (int i = 7; i >= 0; i--)
	{
		tmp0 = dataptr[0] + dataptr[7];
		tmp7 = dataptr[0] - dataptr[7];
		tmp1 = dataptr[1] + dataptr[6];
		tmp6 = dataptr[1] - dataptr[6];
		tmp2 = dataptr[2] + dataptr[5];
		tmp5 = dataptr[2] - dataptr[5];
		tmp3 = dataptr[3] + dataptr[4];
		tmp4 = dataptr[3] - dataptr[4];

		// Even part

		tmp10 = tmp0 + tmp3;                // phase 2
		tmp13 = tmp0 - tmp3;
		tmp11 = tmp1 + tmp2;
		tmp12 = tmp1 - tmp2;

		dataptr[0] = tmp10 + tmp11;         // phase 3
		dataptr[4] = tmp10 - tmp11;

		z1 = 0.707106781 * (tmp12 + tmp13); // c4
		dataptr[2] = tmp13 + z1;            // phase 5
		dataptr[6] = tmp13 - z1;

		// Odd part

		tmp10 = tmp4 + tmp5;                // phase 2
		tmp11 = tmp5 + tmp6;
		tmp12 = tmp6 + tmp7;

		// The rotator is modified from fig 4-8 to avoid extra negations
		z5 = 0.382683433 * (tmp10 - tmp12); // c6
		z2 = 0.541196100 * tmp10 + z5;      // c2-c6
		z4 = 1.306562965 * tmp12 + z5;      // c2+c6
		z3 = 0.707106781 * tmp11;           // c4

		z11 = tmp7 + z3;                    // phase 5
		z13 = tmp7 - z3;

		dataptr[5] = z13 + z2;              // phase 6
		dataptr[3] = z13 - z2;
		dataptr[1] = z11 + z4;
		dataptr[7] = z11 - z4;

		dataptr += 8;                       // advance pointer to next row
	}

	// Pass 2: process columns

	dataptr = datafloat;
	for (int i = 7; i >= 0; i--)
	{
		tmp0 = dataptr[0] + dataptr[56];
		tmp7 = dataptr[0] - dataptr[56];
		tmp1 = dataptr[8] + dataptr[48];
		tmp6 = dataptr[8] - dataptr[48];
		tmp2 = dataptr[16] + dataptr[40];
		tmp5 = dataptr[16] - dataptr[40];
		tmp3 = dataptr[24] + dataptr[32];
		tmp4 = dataptr[24] - dataptr[32];

		// Even part

		tmp10 = tmp0 + tmp3;                // phase 2
		tmp13 = tmp0 - tmp3;
		tmp11 = tmp1 + tmp2;
		tmp12 = tmp1 - tmp2;

		dataptr[0] = tmp10 + tmp11;         // phase 3
		dataptr[32] = tmp10 - tmp11;

		z1 = 0.707106781 * (tmp12 + tmp13); // c4
		dataptr[16] = tmp13 + z1;           // phase 5
		dataptr[48] = tmp13 - z1;

		// Odd part

		tmp10 = tmp4 + tmp5;                // phase 2
		tmp11 = tmp5 + tmp6;
		tmp12 = tmp6 + tmp7;

		// The rotator is modified from fig 4-8 to avoid extra negations.
		z5 = 0.382683433 * (tmp10 - tmp12); // c6
		z2 = 0.541196100 * tmp10 + z5;      // c2-c6
		z4 = 1.306562965 * tmp12 + z5;      // c2+c6
		z3 = 0.707106781 * tmp11;           // c4

		z11 = tmp7 + z3;                    // phase 5
		z13 = tmp7 - z3;
		dataptr[40] = z13 + z2;             // phase 6
		dataptr[24] = z13 - z2;
		dataptr[8] = z11 + z4;
		dataptr[56] = z11 - z4;

		dataptr++;                          // advance pointer to next column
	}

	// Quantize/descale the coefficients, and store into output array
	// Apply the quantization and scaling factor
	// Round to nearest integer.
	// Since C does not specify the direction of rounding for negative
	// quotients, we have to force the dividend positive for portability.
	// The maximum coefficient size is +-16K (for 12-bit data), so this
	// code should work for either 16-bit or 32-bit ints.
	for (int i = 0; i < 64; i++)
		outdata[i] = (int16_t)((int16_t)(datafloat[i] * fdtbl[i] + 16384.5) - 16384);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x2c4(%rbp)
cmpl $0x40, -0x2c4(%rbp)
jge 0x5b3e
movq -0x8(%rbp), %rax
movslq -0x2c4(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
movslq -0x2c4(%rbp), %rax
movsd %xmm0, -0x2c0(%rbp,%rax,8)
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x5b01
leaq -0x2c0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl $0x7, -0x2c8(%rbp)
cmpl $0x0, -0x2c8(%rbp)
jl 0x5e61
movq -0xb8(%rbp), %rax
movsd (%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x38(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0xb8(%rbp), %rax
movsd (%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x38(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x30(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x30(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x28(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x28(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x20(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x20(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x20(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x28(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x28(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x60(%rbp), %xmm0
addsd -0x68(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x60(%rbp), %xmm0
subsd -0x68(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movsd -0x70(%rbp), %xmm1
addsd -0x78(%rbp), %xmm1
movsd 0x149e(%rip), %xmm0     # 0x7160
mulsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
addsd -0x80(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movsd -0x78(%rbp), %xmm0
subsd -0x80(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x30(%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x60(%rbp), %xmm1
subsd -0x70(%rbp), %xmm1
movsd 0x1442(%rip), %xmm0     # 0x7178
mulsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x60(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
movsd 0x1419(%rip), %xmm2     # 0x7170
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
movsd 0x13ec(%rip), %xmm2     # 0x7168
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd 0x13cc(%rip), %xmm0     # 0x7160
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x58(%rbp), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x58(%rbp), %xmm0
subsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
addsd -0x88(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movsd -0xb0(%rbp), %xmm0
subsd -0x88(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0xa8(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0xa8(%rbp), %xmm0
subsd -0x98(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movq -0xb8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0xb8(%rbp)
movl -0x2c8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c8(%rbp)
jmp 0x5b56
leaq -0x2c0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl $0x7, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
jl 0x61ba
movq -0xb8(%rbp), %rax
movsd (%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x1c0(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0xb8(%rbp), %rax
movsd (%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x1c0(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x40(%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x180(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x40(%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x180(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x80(%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x140(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0xb8(%rbp), %rax
movsd 0x80(%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x140(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0xb8(%rbp), %rax
movsd 0xc0(%rax), %xmm0
movq -0xb8(%rbp), %rax
addsd 0x100(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0xb8(%rbp), %rax
movsd 0xc0(%rax), %xmm0
movq -0xb8(%rbp), %rax
subsd 0x100(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x20(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x28(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x28(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x60(%rbp), %xmm0
addsd -0x68(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x60(%rbp), %xmm0
subsd -0x68(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x100(%rax)
movsd -0x70(%rbp), %xmm1
addsd -0x78(%rbp), %xmm1
movsd 0x1154(%rip), %xmm0     # 0x7160
mulsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
addsd -0x80(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x80(%rax)
movsd -0x78(%rbp), %xmm0
subsd -0x80(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x180(%rax)
movsd -0x40(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x60(%rbp), %xmm1
subsd -0x70(%rbp), %xmm1
movsd 0x10f2(%rip), %xmm0     # 0x7178
mulsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x60(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
movsd 0x10c9(%rip), %xmm2     # 0x7170
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
movsd 0x109c(%rip), %xmm2     # 0x7168
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd 0x107c(%rip), %xmm0     # 0x7160
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x58(%rbp), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x58(%rbp), %xmm0
subsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
addsd -0x88(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x140(%rax)
movsd -0xb0(%rbp), %xmm0
subsd -0x88(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0xc0(%rax)
movsd -0xa8(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movsd -0xa8(%rbp), %xmm0
subsd -0x98(%rbp), %xmm0
movq -0xb8(%rbp), %rax
movsd %xmm0, 0x1c0(%rax)
movq -0xb8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xb8(%rbp)
movl -0x2cc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2cc(%rbp)
jmp 0x5e79
movl $0x0, -0x2d0(%rbp)
cmpl $0x40, -0x2d0(%rbp)
jge 0x6223
movslq -0x2d0(%rbp), %rcx
movsd -0x2c0(%rbp,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movsd 0xf66(%rip), %xmm1      # 0x7158
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cwtl
subl $0x4000, %eax           # imm = 0x4000
movw %ax, %dx
movq -0x18(%rbp), %rax
movslq -0x2d0(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x2d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2d0(%rbp)
jmp 0x61c4
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq