// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/iccprofile.c
// Function: do_read_header
static void do_read_header(deark *c, lctx *d, i64 pos)
{
	u32 profile_ver_raw;
	i64 x;
	u64 xu;
	struct de_fourcc tmp4cc;
	UI tmpflags;
	const char *name;
	struct XYZ_type xyz;

	de_dbg(c, "header at %"I64_FMT, pos);
	de_dbg_indent(c, 1);

	d->profile_size = de_getu32be(pos+0);
	de_dbg(c, "profile size: %"I64_FMT, d->profile_size);

	dbuf_read_fourcc(c->infile, pos+4, &tmp4cc, 4, 0x0);
	de_dbg(c, "preferred CMM type: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x3));

	profile_ver_raw = (u32)de_getu32be(pos+8);
	d->profile_ver_major = 10*((profile_ver_raw&0xf0000000U)>>28) +
		((profile_ver_raw&0x0f000000U)>>24);
	d->profile_ver_minor = (profile_ver_raw&0x00f00000U)>>20;
	d->profile_ver_bugfix = (profile_ver_raw&0x000f0000U)>>16;
	de_dbg(c, "profile version: %u.%u.%u", d->profile_ver_major,
		d->profile_ver_minor, d->profile_ver_bugfix);

	dbuf_read_fourcc(c->infile, pos+12, &tmp4cc, 4, 0x0);
	de_dbg(c, "profile/device class: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x1));

	dbuf_read_fourcc(c->infile, pos+16, &tmp4cc, 4, 0x0);
	tmpflags = 0x1;
	if(d->profile_ver_major>=5) tmpflags |= 0x2;
	de_dbg(c, "colour space: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), tmpflags));

	dbuf_read_fourcc(c->infile, pos+20, &tmp4cc, 4, 0x0);
	tmpflags = 0x1;
	if(d->profile_ver_major>=5) tmpflags |= 0x2;
	de_dbg(c, "PCS: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), tmpflags));

	dbg_timestamp(c, pos+24, "creation time");

	dbuf_read_fourcc(c->infile, pos+36, &tmp4cc, 4, 0x0);
	de_dbg(c, "file signature: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x1));

	dbuf_read_fourcc(c->infile, pos+40, &tmp4cc, 4, 0x0);
	de_dbg(c, "primary platform: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x3));

	// TODO: Decode profile flags
	x = de_getu32be(pos+44);
	de_dbg(c, "profile flags: 0x%08x", (UI)x);

	dbuf_read_fourcc(c->infile, pos+48, &tmp4cc, 4, 0x0);
	de_dbg(c, "device manufacturer: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x3));

	dbuf_read_fourcc(c->infile, pos+52, &tmp4cc, 4, 0x0);
	de_dbg(c, "device model: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x3));

	// TODO: Decode device attributes
	xu = dbuf_getu64be(c->infile, pos+56);
	de_dbg(c, "device attribs: 0x%016"U64_FMTx, xu);

	x = de_getu32be(pos+64);
	switch(x) {
	case 0: name="perceptual"; break;
	case 1: name="relative colorimetric"; break;
	case 2: name="saturation"; break;
	case 3: name="absolute colorimetric"; break;
	default: name="?"; break;
	}
	de_dbg(c, "rendering intent: %d (%s)", (int)x, name);

	read_XYZ(c, pos+68, &xyz);
	de_dbg(c, "illuminant: %.5f, %.5f, %.5f", xyz.v[0], xyz.v[1], xyz.v[2]);

	dbuf_read_fourcc(c->infile, pos+80, &tmp4cc, 4, 0x0);
	de_dbg(c, "profile creator: %s",
		format_4cc_dbgstr(&tmp4cc, d->tmpbuf1, sizeof(d->tmpbuf1), 0x3));

	// TODO: pos=84-99 Profile ID

	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x109c2d(%rip), %rsi    # 0x1aed63
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x0, %rsi
callq 0x165470
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0xfe739(%rip), %rsi     # 0x1a38b7
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
leaq -0x60(%rbp), %rdi
movl $0x50, %edx
movl $0x3, %ecx
callq 0xa5930
movq -0x98(%rbp), %rdi
movq %rax, %rdx
leaq 0x10ce0e(%rip), %rsi    # 0x1b1feb
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
callq 0x165470
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0xf0000000, %eax       # imm = 0xF0000000
shrl $0x1c, %eax
imull $0xa, %eax, %ecx
movl -0x1c(%rbp), %eax
andl $0xf000000, %eax        # imm = 0xF000000
shrl $0x18, %eax
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x1c(%rbp), %ecx
andl $0xf00000, %ecx         # imm = 0xF00000
shrl $0x14, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x1c(%rbp), %ecx
andl $0xf0000, %ecx          # imm = 0xF0000
shrl $0x10, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %r8d
leaq 0x10cd9f(%rip), %rsi    # 0x1b2002
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
leaq -0x60(%rbp), %rdi
movl $0x50, %edx
movl $0x1, %ecx
callq 0xa5930
movq -0x90(%rbp), %rdi
movq %rax, %rdx
leaq 0x10cd5a(%rip), %rsi    # 0x1b201c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movl $0x1, -0x64(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x5, (%rax)
jb 0xa5303
movl -0x64(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movl -0x64(%rbp), %ecx
leaq -0x60(%rbp), %rdi
movl $0x50, %edx
callq 0xa5930
movq -0xa0(%rbp), %rdi
movq %rax, %rdx
leaq 0x10ccfd(%rip), %rsi    # 0x1b2035
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x14, %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movl $0x1, -0x64(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x5, (%rax)
jb 0xa5379
movl -0x64(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movl -0x64(%rbp), %ecx
leaq -0x60(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movl $0x50, %edx
movq %rdx, -0xc8(%rbp)
callq 0xa5930
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
leaq 0x10cc8a(%rip), %rsi    # 0x1b2046
xorl %eax, %eax
movl %eax, -0xd4(%rbp)
movb %al, -0xa9(%rbp)
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
leaq 0x11477b(%rip), %rdx    # 0x1b9b5d
callq 0xa59e0
movl -0xd4(%rbp), %r8d
movq -0xd0(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x24, %rsi
movl $0x4, %ecx
movl %ecx, -0xd8(%rbp)
callq 0x169860
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movl $0x1, %ecx
callq 0xa5930
movq -0xf0(%rbp), %rdi
movq %rax, %rdx
movb -0xa9(%rbp), %al
leaq 0x10cbf7(%rip), %rsi    # 0x1b204e
callq 0x15b0d0
movl -0xd8(%rbp), %ecx
movl -0xd4(%rbp), %r8d
movq -0xd0(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x28, %rsi
callq 0x169860
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movl $0x3, %ecx
movl %ecx, -0xbc(%rbp)
callq 0xa5930
movq -0xe8(%rbp), %rdi
movq %rax, %rdx
movb -0xa9(%rbp), %al
leaq 0x10cb94(%rip), %rsi    # 0x1b2061
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x2c, %rsi
callq 0x165470
movq %rax, %rcx
movb -0xa9(%rbp), %al
movq %rcx, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %edx
leaq 0x10cb74(%rip), %rsi    # 0x1b2076
callq 0x15b0d0
movl -0xd8(%rbp), %ecx
movl -0xd4(%rbp), %r8d
movq -0xd0(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
callq 0x169860
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movl -0xbc(%rbp), %ecx
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
callq 0xa5930
movq -0xe0(%rbp), %rdi
movq %rax, %rdx
movb -0xa9(%rbp), %al
leaq 0x10cb19(%rip), %rsi    # 0x1b208c
callq 0x15b0d0
movl -0xd8(%rbp), %ecx
movl -0xd4(%rbp), %r8d
movq -0xd0(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x34, %rsi
callq 0x169860
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movl -0xbc(%rbp), %ecx
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
callq 0xa5930
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
movb -0xa9(%rbp), %al
leaq 0x10cac0(%rip), %rsi    # 0x1b20a4
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x38, %rsi
callq 0x1659b0
movq %rax, %rcx
movb -0xa9(%rbp), %al
movq %rcx, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x10ca9b(%rip), %rsi    # 0x1b20b5
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x40, %rsi
callq 0x165470
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
subq $0x3, %rax
ja 0xa5694
movq -0xa8(%rbp), %rax
leaq 0x10c96d(%rip), %rcx    # 0x1b1fc4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10ca67(%rip), %rax    # 0x1b20ce
movq %rax, -0x70(%rbp)
jmp 0xa569f
leaq 0x10ca65(%rip), %rax    # 0x1b20d9
movq %rax, -0x70(%rbp)
jmp 0xa569f
leaq 0x10ca6e(%rip), %rax    # 0x1b20ef
movq %rax, -0x70(%rbp)
jmp 0xa569f
leaq 0x10ca6c(%rip), %rax    # 0x1b20fa
movq %rax, -0x70(%rbp)
jmp 0xa569f
leaq 0x112592(%rip), %rax    # 0x1b7c2d
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x70(%rbp), %rcx
leaq 0x10ca5c(%rip), %rsi    # 0x1b2110
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x44, %rsi
leaq -0x88(%rbp), %rdx
callq 0xa5ad0
movq -0x8(%rbp), %rdi
movsd -0x88(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm2
leaq 0x10ca3a(%rip), %rsi    # 0x1b212a
movb $0x3, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
leaq -0x60(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x169860
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
leaq -0x60(%rbp), %rdi
movl $0x50, %edx
movl $0x3, %ecx
callq 0xa5930
movq -0x100(%rbp), %rdi
movq %rax, %rdx
leaq 0x10c9f8(%rip), %rsi    # 0x1b2147
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)