// File: /workspace/github_c_makefile_star2_O0/ender672[P]liboil/imgscale.c
// Function: jpeg
static void jpeg(FILE *input, FILE *output, int width_out, int height_out)
{
	struct jpeg_decompress_struct dinfo;
	struct jpeg_compress_struct cinfo;
	struct jpeg_error_mgr jerr;
	unsigned char *outbuf;
	int i, ret;
	struct oil_libjpeg ol;
	jpeg_saved_marker_ptr marker;

	prepare_jpeg_decompress(input, &dinfo, &jerr);

	/* Use the image dimensions read from the header to calculate our final
	 * output dimensions.
	 */
	oil_fix_ratio(dinfo.output_width, dinfo.output_height, &width_out, &height_out);

	/* set up scaler */
	ret = oil_libjpeg_init(&ol, &dinfo, width_out, height_out);
	if (ret!=0) {
		fprintf(stderr, "Unable to initialize scaler.");
		jpeg_destroy_decompress(&dinfo);
		fclose(input);
		fclose(output);
		exit(1);
	}

	/* Allocate linear converter output buffer */
	outbuf = malloc(width_out * OIL_CMP(ol.os.cs) * sizeof(unsigned char));
	if (!outbuf) {
		fprintf(stderr, "Unable to allocate buffers.");
		exit(1);
	}

	/* Jpeg compressor. */
	cinfo.err = &jerr;
	jpeg_create_compress(&cinfo);
	jpeg_stdio_dest(&cinfo, output);
	cinfo.image_width = width_out;
	cinfo.image_height = height_out;
	cinfo.input_components = OIL_CMP(ol.os.cs);
	cinfo.in_color_space = oil_cs_to_jpeg(ol.os.cs);
	jpeg_set_defaults(&cinfo);
	jpeg_set_quality(&cinfo, 94, FALSE);
	jpeg_start_compress(&cinfo, TRUE);

	/* Copy custom headers from source jpeg to dest jpeg. */
	for (marker=dinfo.marker_list; marker; marker=marker->next) {
		jpeg_write_marker(&cinfo, marker->marker, marker->data,
			marker->data_length);
	}

	/* Read scanlines, process image, and write scanlines to the jpeg
	 * encoder.
	 */
	for(i=height_out; i>0; i--) {
		oil_libjpeg_read_scanline(&ol, outbuf);
		jpeg_write_scanlines(&cinfo, (JSAMPARRAY)&outbuf, 1);
	}

	jpeg_finish_compress(&cinfo);
	jpeg_destroy_compress(&cinfo);

	jpeg_finish_decompress(&dinfo);
	jpeg_destroy_decompress(&dinfo);
	free(outbuf);
	oil_libjpeg_free(&ol);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x620, %rsp            # imm = 0x620
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0x598(%rbp), %rdx
callq 0x6190
movl -0x220(%rbp), %edi
movl -0x21c(%rbp), %esi
leaq -0x14(%rbp), %rdx
leaq -0x18(%rbp), %rcx
callq 0x33c0
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq -0x610(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x5360
movl %eax, -0x5a8(%rbp)
cmpl $0x0, -0x5a8(%rbp)
je 0x5fa1
movq 0x4080(%rip), %rax      # 0x9fe8
movq (%rax), %rdi
leaq 0x124f(%rip), %rsi      # 0x71c1
movb $0x0, %al
callq 0x2360
leaq -0x2a8(%rbp), %rdi
callq 0x2110
movq -0x8(%rbp), %rdi
callq 0x22e0
movq -0x10(%rbp), %rdi
callq 0x22e0
movl $0x1, %edi
callq 0x20c0
movl -0x14(%rbp), %eax
movl -0x600(%rbp), %ecx
andl $0xff, %ecx
imull %ecx, %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x20d0
movq %rax, -0x5a0(%rbp)
cmpq $0x0, -0x5a0(%rbp)
jne 0x5ff3
movq 0x4010(%rip), %rax      # 0x9fe8
movq (%rax), %rdi
leaq 0x11fc(%rip), %rsi      # 0x71de
movb $0x0, %al
callq 0x2360
movl $0x1, %edi
callq 0x20c0
leaq -0x598(%rbp), %rax
movq %rax, -0x4f0(%rbp)
leaq -0x4f0(%rbp), %rdi
movl $0x50, %esi
movl $0x248, %edx            # imm = 0x248
callq 0x2170
movq -0x10(%rbp), %rsi
leaq -0x4f0(%rbp), %rdi
callq 0x20b0
movl -0x14(%rbp), %eax
movl %eax, -0x4c0(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x4bc(%rbp)
movl -0x600(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x4b8(%rbp)
movl -0x600(%rbp), %edi
callq 0x5540
movl %eax, -0x4b4(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x2160
leaq -0x4f0(%rbp), %rdi
movl $0x5e, %esi
xorl %edx, %edx
callq 0x2330
leaq -0x4f0(%rbp), %rdi
movl $0x1, %esi
callq 0x2040
movq -0x118(%rbp), %rax
movq %rax, -0x618(%rbp)
cmpq $0x0, -0x618(%rbp)
je 0x60e2
movq -0x618(%rbp), %rax
movzbl 0x8(%rax), %esi
movq -0x618(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x618(%rbp), %rax
movl 0x10(%rax), %ecx
leaq -0x4f0(%rbp), %rdi
callq 0x2290
movq -0x618(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x618(%rbp)
jmp 0x6099
movl -0x18(%rbp), %eax
movl %eax, -0x5a4(%rbp)
cmpl $0x0, -0x5a4(%rbp)
jle 0x6130
movq -0x5a0(%rbp), %rsi
leaq -0x610(%rbp), %rdi
callq 0x54e0
leaq -0x4f0(%rbp), %rdi
leaq -0x5a0(%rbp), %rsi
movl $0x1, %edx
callq 0x2200
movl -0x5a4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5a4(%rbp)
jmp 0x60eb
leaq -0x4f0(%rbp), %rdi
callq 0x2100
leaq -0x4f0(%rbp), %rdi
callq 0x23b0
leaq -0x2a8(%rbp), %rdi
callq 0x23a0
leaq -0x2a8(%rbp), %rdi
callq 0x2110
movq -0x5a0(%rbp), %rdi
callq 0x21a0
leaq -0x610(%rbp), %rdi
callq 0x54a0
addq $0x620, %rsp            # imm = 0x620
popq %rbp
retq
nopw %cs:(%rax,%rax)