// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/bmp.c
// Function: do_image_64bit
static void do_image_64bit(deark *c, lctx *d, dbuf *bits, i64 bits_offset)
{
	de_bitmap *imghi = NULL;
	de_bitmap *imglo = NULL;
	i64 i, j;
	size_t k;
	u8 range_flag = 0;
	u8 sm_hi[4];
	u8 sm_lo[4];
	int sm16[4];

	if(d->want_returned_img) return; // Not supported for this image type
	imghi = bmp_bitmap_create(c, d, 4);
	imglo = bmp_bitmap_create(c, d, 4);
	for(j=0; j<d->height; j++) {
		i64 pos;

		pos = bits_offset + j*d->rowspan;
		for(i=0; i<d->pdwidth; i++) {
			sm16[2] = (int)dbuf_geti16le_p(bits, &pos);
			sm16[1] = (int)dbuf_geti16le_p(bits, &pos);
			sm16[0] = (int)dbuf_geti16le_p(bits, &pos);
			sm16[3] = (int)dbuf_geti16le_p(bits, &pos);

			// This is a signed "fixed point" format.
			// Full sample range is -32768 to 32767 (= -4.0 to +3.999);
			//  0 is the normal min brightness ("black" or transparent), and
			//  8192 is the normal max brightness ("white" or opaque).
			// Colorspace is, apparently, linear.
			for(k=0; k<4; k++) {
				if(sm16[k]<0 || sm16[k]>8192) {
					range_flag = 1;
				}
				de_scale_n_to_16bit(8192, sm16[k], &sm_hi[k], &sm_lo[k]);
			}
			de_bitmap_setpixel_rgba(imghi, i, j, DE_MAKE_RGBA(sm_hi[0], sm_hi[1], sm_hi[2], sm_hi[3]));
			de_bitmap_setpixel_rgba(imglo, i, j, DE_MAKE_RGBA(sm_lo[0], sm_lo[1], sm_lo[2], sm_lo[3]));
		}
	}

	if(range_flag) {
		de_warn(c, "Image has samples outside the normal range");
	}
	d->fi->linear_colorpace = 1;
	d->createflags |= DE_CREATEFLAG_OPT_IMAGE;
	de_bitmap16_write_to_file_finfo(imghi, imglo, d->fi, d->createflags);
	de_bitmap_destroy(imghi);
	de_bitmap_destroy(imglo);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movb $0x0, -0x49(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x45b3e
jmp 0x45d38
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x4, %edx
callq 0x45f20
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x4, %edx
callq 0x45f20
movq %rax, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jge 0x45cd9
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rdx
imulq 0xf8(%rdx), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jge 0x45cc6
movq -0x18(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1653f0
movl %eax, -0x68(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1653f0
movl %eax, -0x6c(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1653f0
movl %eax, -0x70(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1653f0
movl %eax, -0x64(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x4, -0x48(%rbp)
jae 0x45c55
movq -0x48(%rbp), %rax
cmpl $0x0, -0x70(%rbp,%rax,4)
jl 0x45c21
movq -0x48(%rbp), %rax
cmpl $0x2000, -0x70(%rbp,%rax,4) # imm = 0x2000
jle 0x45c25
movb $0x1, -0x49(%rbp)
movq -0x48(%rbp), %rax
movl -0x70(%rbp,%rax,4), %esi
leaq -0x4d(%rbp), %rdx
addq -0x48(%rbp), %rdx
leaq -0x51(%rbp), %rcx
addq -0x48(%rbp), %rcx
movl $0x2000, %edi           # imm = 0x2000
callq 0x161810
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45c01
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movzbl -0x4a(%rbp), %ecx
shll $0x18, %ecx
movzbl -0x4d(%rbp), %eax
shll $0x10, %eax
orl %eax, %ecx
movzbl -0x4c(%rbp), %eax
shll $0x8, %eax
orl %eax, %ecx
movzbl -0x4b(%rbp), %eax
orl %eax, %ecx
callq 0x16b350
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movzbl -0x4e(%rbp), %ecx
shll $0x18, %ecx
movzbl -0x51(%rbp), %eax
shll $0x10, %eax
orl %eax, %ecx
movzbl -0x50(%rbp), %eax
shll $0x8, %eax
orl %eax, %ecx
movzbl -0x4f(%rbp), %eax
orl %eax, %ecx
callq 0x16b350
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x45ba7
jmp 0x45cc8
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x45b72
cmpb $0x0, -0x49(%rbp)
je 0x45cf1
movq -0x8(%rbp), %rdi
leaq 0x15dd50(%rip), %rsi    # 0x1a3a3a
movb $0x0, %al
callq 0x15bc10
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x1, 0xf(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
callq 0x16aac0
movq -0x28(%rbp), %rdi
callq 0x16af60
movq -0x30(%rbp), %rdi
callq 0x16af60
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)