LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tga.c
// Function: look_for_v2_signature
static int look_for_v2_signature(deark *c, int idmode, i64 *pfooterpos)
{
	i64 x;
	i64 possible_sig_pos;
	static const u8 v2sig[18] = "TRUEVISION-XFILE."; // size 18 includes trailing NUL

	if(c->infile->len<18+26) return 0;
	if(de_getbyte(c->infile->len-1) != 0x00) return 0;
	possible_sig_pos = c->infile->len-18;
	if(!dbuf_memcmp(c->infile, possible_sig_pos, v2sig, 18)) {
		*pfooterpos = possible_sig_pos-8;
		return 1;
	}
	if(idmode) return 0;

	x = find_last_nonNUL_byte_for_sig_search(c);
	if(x<=0) return 0;
	possible_sig_pos = x-16;
	if(!dbuf_memcmp(c->infile, possible_sig_pos, v2sig, 18)) {
		de_warn(c, "v2 signature found at %"I64_FMT"; ignoring %"I64_FMT" extra "
			"bytes at end of file",
			possible_sig_pos, c->infile->len-(possible_sig_pos+18));
		*pfooterpos = possible_sig_pos-8;
		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x820, %rsp            # imm = 0x820
movl %esi, %r15d
movq %rdi, %r14
movq 0x18(%rdi), %rdi
movq 0x18(%rdi), %rsi
xorl %ebp, %ebp
cmpq $0x2c, %rsi
jl 0xcbbf4
movq %rdx, %rbx
decq %rsi
callq 0xef0d5
testb %al, %al
jne 0xcbbf4
movq 0x18(%r14), %rdi
movq 0x18(%rdi), %r12
leaq -0x12(%r12), %rsi
leaq 0x6ff5a(%rip), %rdx     # 0x13baf0
movl $0x12, %ecx
callq 0xf025e
testl %eax, %eax
je 0xcbbe8
testl %r15d, %r15d
jne 0xcbbf4
movq 0x18(%r14), %rdi
movq 0x18(%rdi), %r15
leaq -0x812(%r15), %rdx
movq %rsp, %rsi
movl $0x812, %ecx            # imm = 0x812
callq 0xeeee8
movq $-0x1, %rax
xorl %r12d, %r12d
movzbl 0x812(%rsp,%rax), %ecx
testl %ecx, %ecx
jne 0xcbc06
decq %rax
cmpq $-0x813, %rax           # imm = 0xF7ED
jne 0xcbbcf
jmp 0xcbc11
addq $-0x1a, %r12
movq %r12, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x820, %rsp            # imm = 0x820
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2e, %ecx
jne 0xcbc11
addq %rax, %r15
movq %r15, %r12
xorl %ebp, %ebp
testq %r12, %r12
jle 0xcbbf4
leaq -0x10(%r12), %r15
movq 0x18(%r14), %rdi
leaq 0x6fec8(%rip), %rdx     # 0x13baf0
movl $0x12, %ecx
movq %r15, %rsi
callq 0xf025e
testl %eax, %eax
jne 0xcbbf4
movq 0x18(%r14), %rax
movq 0x18(%rax), %rcx
subq %r12, %rcx
addq $-0x2, %rcx
leaq 0x70043(%rip), %rsi     # 0x13bc92
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9b27
addq $-0x18, %r12
jmp 0xcbbec
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tga.c
// Function: do_read_image_descriptor
static void do_read_image_descriptor(deark *c, lctx *d)
{
	d->image_descriptor = de_getbyte(17);
	de_dbg(c, "descriptor: 0x%02x", (UI)d->image_descriptor);

	de_dbg_indent(c, 1);
	d->num_attribute_bits = (i64)(d->image_descriptor & 0x0f);
	de_dbg(c, "number of %s bits: %d",
		d->file_format==FMT_VST?"alpha channel":"attribute",
		(int)d->num_attribute_bits);

	d->right_to_left = (d->image_descriptor>>4)&0x01;
	d->top_down = (d->image_descriptor>>5)&0x01;
	de_dbg(c, "right-to-left flag: %d", (int)d->right_to_left);
	de_dbg(c, "top-down flag: %d", (int)d->top_down);

	d->interleave_mode = d->image_descriptor >> 6;
	if(d->interleave_mode != 0) {
		de_dbg(c, "interleaving: %d", (int)d->interleave_mode);
	}
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movl $0x11, %esi
callq 0xef0d5
movb %al, 0x78(%r14)
movzbl %al, %edx
leaq 0x56716(%rip), %rsi     # 0x12239e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movzbl 0x78(%r14), %ecx
andl $0xf, %ecx
movq %rcx, 0x80(%r14)
cmpl $0x1, 0xc(%r14)
leaq 0x70041(%rip), %rax     # 0x13bcfb
leaq 0x70048(%rip), %rdx     # 0x13bd09
cmoveq %rax, %rdx
leaq 0x70019(%rip), %rsi     # 0x13bce5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl 0x78(%r14), %eax
movl %eax, %edx
shrl $0x4, %edx
andl $0x1, %edx
movb %dl, 0x8b(%r14)
shrb $0x5, %al
andb $0x1, %al
movb %al, 0x8a(%r14)
leaq 0x70017(%rip), %rsi     # 0x13bd13
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movzbl 0x8a(%r14), %edx
leaq 0x70015(%rip), %rsi     # 0x13bd2a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movzbl 0x78(%r14), %eax
movl %eax, %edx
shrl $0x6, %edx
movb %dl, 0x8c(%r14)
cmpl $0x40, %eax
jb 0xcbd46
leaq 0x70000(%rip), %rsi     # 0x13bd3c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe9585
nop
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: de_module_tiff
void de_module_tiff(deark *c, struct deark_module_info *mi)
{
	mi->id = "tiff";
	mi->desc = "TIFF image";
	mi->run_fn = de_run_tiff;
	mi->identify_fn = de_identify_tiff;
	mi->help_fn = de_help_tiff;
}

// Assembly:
leaq 0x7e17d(%rip), %rax     # 0x149ee0
movq %rax, (%rsi)
leaq 0x70843(%rip), %rax     # 0x13c5b0
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0xcbd93
movq %rax, 0x18(%rsi)
leaq 0x1da2(%rip), %rax      # 0xcdb25
movq %rax, 0x20(%rsi)
leaq 0x1dae(%rip), %rax      # 0xcdb3c
movq %rax, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: de_identify_tiff_internal
static int de_identify_tiff_internal(deark *c, int *is_le)
{
	i64 byte_order_sig;
	i64 magic;
	int fmt = 0;

	byte_order_sig = de_getu16be(0);
	*is_le = (byte_order_sig == 0x4d4d) ? 0 : 1;

	if(*is_le)
		magic = de_getu16le(2);
	else
		magic = de_getu16be(2);

	if(byte_order_sig==0x4550 && magic==0x002a) {
		fmt = DE_TIFFFMT_MDI;
	}
	else if(byte_order_sig==0x4d4d || byte_order_sig==0x4949) {

		switch(magic) {
		case 0x002a: // Standard TIFF
			fmt = DE_TIFFFMT_TIFF;
			break;
		case 0x002b:
			fmt = DE_TIFFFMT_BIGTIFF;
			break;
		case 0x0055:
			fmt = DE_TIFFFMT_PANASONIC;
			break;

		case 0x01bc: // JPEG-XR
			fmt = DE_TIFFFMT_JPEGXR;
			break;

		//case 0x314e: // NIFF

		case 0x4352:
			fmt = DE_TIFFFMT_DCP;
			break;
		case 0x4f52:
		case 0x5352:
			fmt = DE_TIFFFMT_ORF;
			break;
		}
	}

	return fmt;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rdi
xorl %esi, %esi
callq 0xef169
movq %rax, %rbx
xorl %eax, %eax
cmpq $0x4d4d, %rbx           # imm = 0x4D4D
setne %al
movl %eax, (%r14)
movq 0x18(%r15), %rdi
movl $0x2, %esi
je 0xcdbab
callq 0xef1ca
jmp 0xcdbb0
callq 0xef169
movq %rax, %rcx
movq %rbx, %rdx
xorq $0x4550, %rdx           # imm = 0x4550
movq %rax, %rsi
xorq $0x2a, %rsi
movl $0x6, %eax
orq %rdx, %rsi
je 0xcdc56
xorl %eax, %eax
cmpq $0x4d4d, %rbx           # imm = 0x4D4D
je 0xcdbe6
cmpq $0x4949, %rbx           # imm = 0x4949
jne 0xcdc56
cmpq $0x1bb, %rcx            # imm = 0x1BB
jle 0xcdc11
cmpq $0x4f51, %rcx           # imm = 0x4F51
jg 0xcdc2a
cmpq $0x1bc, %rcx            # imm = 0x1BC
je 0xcdc4a
cmpq $0x4352, %rcx           # imm = 0x4352
jne 0xcdc56
movl $0x5, %eax
jmp 0xcdc56
cmpq $0x2a, %rcx
je 0xcdc43
cmpq $0x2b, %rcx
je 0xcdc51
cmpq $0x55, %rcx
jne 0xcdc56
movl $0x3, %eax
jmp 0xcdc56
cmpq $0x4f52, %rcx           # imm = 0x4F52
je 0xcdc3c
cmpq $0x5352, %rcx           # imm = 0x5352
jne 0xcdc56
movl $0x4, %eax
jmp 0xcdc56
movl $0x1, %eax
jmp 0xcdc56
movl $0x7, %eax
jmp 0xcdc56
movl $0x2, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: detiff_warn
static void detiff_warn(deark *c, lctx *d, struct page_ctx *pg, const char *fmt, ...)
{
	va_list ap;
	char buf[256];

	va_start(ap, fmt);
	if(d->errmsgtoken_module[0] && pg) {
		de_vsnprintf(buf, sizeof(buf), fmt, ap);
		de_warn(c, "[%s:%s] %s", d->errmsgtoken_module, pg->errmsgtoken_ifd, buf);
	}
	else if(d->errmsgtoken_module[0]) {
		de_vsnprintf(buf, sizeof(buf), fmt, ap);
		de_warn(c, "[%s] %s", d->errmsgtoken_module, buf);
	}
	else if(pg) {
		de_vsnprintf(buf, sizeof(buf), fmt, ap);
		de_warn(c, "[%s] %s", pg->errmsgtoken_ifd, buf);
	}
	else {
		de_vwarn(c, fmt, ap);
	}
	va_end(ap);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x120(%rsp), %rdx
movq %r8, 0x20(%rdx)
movq %r9, 0x28(%rdx)
testb %al, %al
je 0xcdcc7
movaps %xmm0, 0x150(%rsp)
movaps %xmm1, 0x160(%rsp)
movaps %xmm2, 0x170(%rsp)
movaps %xmm3, 0x180(%rsp)
movaps %xmm4, 0x190(%rsp)
movaps %xmm5, 0x1a0(%rsp)
movaps %xmm6, 0x1b0(%rsp)
movaps %xmm7, 0x1c0(%rsp)
movabsq $0x3000000020, %rax     # imm = 0x3000000020
movq %rax, (%rsp)
leaq 0x200(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movb 0x7c(%rsi), %al
addq $0x7c, %r15
testb %al, %al
sete %dl
testq %r14, %r14
sete %sil
orb %dl, %sil
jne 0xcdd3d
leaq 0x20(%rsp), %r12
movq %rsp, %rax
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x109878
addq $0x4e4, %r14            # imm = 0x4E4
leaq 0x6e9df(%rip), %rsi     # 0x13c707
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0xe9b27
jmp 0xcddac
testb %al, %al
je 0xcdd6e
leaq 0x20(%rsp), %r14
movq %rsp, %rax
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x109878
leaq 0x6e9af(%rip), %rsi     # 0x13c712
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
jmp 0xcdda5
testq %r14, %r14
je 0xcddbb
leaq 0x20(%rsp), %r15
movq %rsp, %rax
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x109878
addq $0x4e4, %r14            # imm = 0x4E4
leaq 0x6e976(%rip), %rsi     # 0x13c712
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe9b27
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsp, %rdx
movq %rbx, %rdi
movq %rcx, %rsi
callq 0xe9e7b
jmp 0xcddac
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: push_ifd
static void push_ifd(deark *c, lctx *d, i64 ifdpos, u8 ifdtype, u8 is_in_main_ifd_list)
{
	if(ifdpos==0) return;

	if(ifdpos < 0 || ifdpos >= c->infile->len) {
		detiff_warn(c, d, NULL, "Invalid IFD offset: %"I64_FMT, ifdpos);
		return;
	}

	// Append to the IFD list (of all IFDs). This is only used for loop detection.
	if(!d->ifds_seen) {
		d->ifds_seen = de_inthashtable_create(c);
	}
	if(d->ifd_count >= MAX_IFDS) {
		detiff_warn(c, d, NULL, "Too many TIFF IFDs");
		return;
	}
	if(!de_inthashtable_add_item(c, d->ifds_seen, ifdpos, NULL)) {
		detiff_err(c, d, NULL, "IFD loop detected");
		return;
	}
	d->ifd_count++;

	// Add to the IFD stack (of unprocessed IFDs).
	if(!d->ifdstack) {
		d->ifdstack_capacity = 200;
		d->ifdstack = de_mallocarray(c, d->ifdstack_capacity, sizeof(struct ifdstack_item));
		d->ifdstack_numused = 0;
	}
	if(d->ifdstack_numused >= d->ifdstack_capacity) {
		detiff_warn(c, d, NULL, "Too many TIFF IFDs");
		return;
	}
	d->ifdstack[d->ifdstack_numused].offset = ifdpos;
	d->ifdstack[d->ifdstack_numused].ifdtype = ifdtype;
	d->ifdstack[d->ifdstack_numused].is_in_main_ifd_list = is_in_main_ifd_list;
	d->ifdstack_numused++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdx, %rdx
je 0xcde8d
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
js 0xcde96
movq 0x18(%r14), %rax
cmpq %r15, 0x18(%rax)
jle 0xcde96
movl %r8d, %ebp
movl %ecx, %r12d
cmpq $0x0, 0x40(%rbx)
jne 0xcde12
movq %r14, %rdi
callq 0xeb85a
movq %rax, 0x40(%rbx)
cmpl $0x3e8, 0x48(%rbx)      # imm = 0x3E8
jge 0xcdeb7
movq 0x40(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xeb96a
testl %eax, %eax
je 0xcded5
incl 0x48(%rbx)
cmpq $0x0, 0x28(%rbx)
jne 0xcde66
movl $0xc8, 0x30(%rbx)
movl $0xc8, %esi
movl $0x10, %edx
movq %r14, %rdi
callq 0xea259
movq %rax, 0x28(%rbx)
movl $0x0, 0x34(%rbx)
movslq 0x34(%rbx), %rax
cmpl 0x30(%rbx), %eax
jge 0xcdeb7
movq 0x28(%rbx), %rcx
movq %rax, %rdx
shlq $0x4, %rdx
movq %r15, (%rcx,%rdx)
movb %r12b, 0x8(%rcx,%rdx)
movb %bpl, 0x9(%rcx,%rdx)
incl %eax
movl %eax, 0x34(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6e8d4(%rip), %rcx     # 0x13c771
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r15, %r8
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xcdc5c
leaq 0x6e8cb(%rip), %rcx     # 0x13c789
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xcdc5c
leaq 0x6e8c0(%rip), %rcx     # 0x13c79c
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xcdf34
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: get_u32_or_u64_count
static i64 get_u32_or_u64_count(deark *c, lctx *d, i64 pos)
{
	if(d->is_bigtiff) {
		i64 n;

		n = dbuf_geti64x(c->infile, pos, d->is_le);
		de_sanitize_count(&n);
		return n;
	}
	return dbuf_getu32x(c->infile, pos, d->is_le);
}

// Assembly:
cmpb $0x0, 0x8(%rsi)
je 0xcdf24
pushq %rbx
subq $0x10, %rsp
movq 0x18(%rdi), %rdi
movl (%rsi), %eax
movq %rdx, %rsi
movl %eax, %edx
callq 0xef661
leaq 0x8(%rsp), %rbx
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0xec0d1
movq (%rbx), %rax
addq $0x10, %rsp
popq %rbx
retq
movq 0x18(%rdi), %rdi
movl (%rsi), %eax
movq %rdx, %rsi
movl %eax, %edx
jmp 0xef614
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: detiff_err
static void detiff_err(deark *c, lctx *d, struct page_ctx *pg, const char *fmt, ...)
{
	va_list ap;
	char buf[256];

	va_start(ap, fmt);
	if(d->errmsgtoken_module[0] && pg) {
		de_vsnprintf(buf, sizeof(buf), fmt, ap);
		de_err(c, "[%s:%s] %s", d->errmsgtoken_module, pg->errmsgtoken_ifd, buf);
	}
	else if(d->errmsgtoken_module[0]) {
		de_vsnprintf(buf, sizeof(buf), fmt, ap);
		de_err(c, "[%s] %s", d->errmsgtoken_module, buf);
	}
	else if(pg) {
		de_vsnprintf(buf, sizeof(buf), fmt, ap);
		de_err(c, "[%s] %s", pg->errmsgtoken_ifd, buf);
	}
	else {
		de_verr(c, fmt, ap);
	}
	va_end(ap);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x120(%rsp), %rdx
movq %r8, 0x20(%rdx)
movq %r9, 0x28(%rdx)
testb %al, %al
je 0xcdf9f
movaps %xmm0, 0x150(%rsp)
movaps %xmm1, 0x160(%rsp)
movaps %xmm2, 0x170(%rsp)
movaps %xmm3, 0x180(%rsp)
movaps %xmm4, 0x190(%rsp)
movaps %xmm5, 0x1a0(%rsp)
movaps %xmm6, 0x1b0(%rsp)
movaps %xmm7, 0x1c0(%rsp)
movabsq $0x3000000020, %rax     # imm = 0x3000000020
movq %rax, (%rsp)
leaq 0x200(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movb 0x7c(%rsi), %al
addq $0x7c, %r15
testb %al, %al
sete %dl
testq %r14, %r14
sete %sil
orb %dl, %sil
jne 0xce015
leaq 0x20(%rsp), %r12
movq %rsp, %rax
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x109878
addq $0x4e4, %r14            # imm = 0x4E4
leaq 0x6e707(%rip), %rsi     # 0x13c707
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0xe9df7
jmp 0xce084
testb %al, %al
je 0xce046
leaq 0x20(%rsp), %r14
movq %rsp, %rax
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x109878
leaq 0x6e6d7(%rip), %rsi     # 0x13c712
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
jmp 0xce07d
testq %r14, %r14
je 0xce093
leaq 0x20(%rsp), %r15
movq %rsp, %rax
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x109878
addq $0x4e4, %r14            # imm = 0x4E4
leaq 0x6e69e(%rip), %rsi     # 0x13c712
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe9df7
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsp, %rdx
movq %rbx, %rdi
movq %rcx, %rsi
callq 0xe9d7b
jmp 0xce084
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_newsubfiletype
static int valdec_newsubfiletype(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	i64 n = vp->n;

	if(n<1) return 0;

	if(n&0x1) {
		ucstring_append_flags_item(vr->s, "reduced-res");
		n -= 0x1;
	}
	if(n&0x2) {
		ucstring_append_flags_item(vr->s, "one-page-of-many");
		n -= 0x2;
	}
	if(n&0x4) {
		ucstring_append_flags_item(vr->s, "mask");
		n -= 0x4;
	}
	if(n&0x10) {
		ucstring_append_flags_item(vr->s, "MRC-related");
		n -= 0x10;
	}
	if(n!=0) {
		ucstring_append_flags_itemf(vr->s, "0x%x", (unsigned int)n);
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x18(%rsi), %rbx
testq %rbx, %rbx
jle 0xce32f
movq %rdx, %r14
testb $0x1, %bl
je 0xce2c8
movq (%r14), %rdi
leaq 0x7079e(%rip), %rsi     # 0x13ea5e
callq 0xf7566
decq %rbx
testb $0x2, %bl
je 0xce2e0
movq (%r14), %rdi
leaq 0x70793(%rip), %rsi     # 0x13ea6a
callq 0xf7566
addq $-0x2, %rbx
testb $0x4, %bl
je 0xce2f8
movq (%r14), %rdi
leaq 0x778a4(%rip), %rsi     # 0x145b93
callq 0xf7566
addq $-0x4, %rbx
testb $0x10, %bl
je 0xce310
movq (%r14), %rdi
leaq 0x70774(%rip), %rsi     # 0x13ea7b
callq 0xf7566
addq $-0x10, %rbx
movl $0x1, %ebp
testq %rbx, %rbx
je 0xce331
movq (%r14), %rdi
leaq 0x5a8c2(%rip), %rsi     # 0x128be6
movl %ebx, %edx
xorl %eax, %eax
callq 0xf7593
jmp 0xce331
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_oldsubfiletype
static int valdec_oldsubfiletype(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "full-res"}, {2, "reduced-res"}, {3, "one-page-of-many"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbde25(%rip), %r8      # 0x18c170
leaq 0x5db17(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xce362
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xce36f
addq $0x10, %rcx
cmpq $0x38, %rcx
jne 0xce352
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_bitspersample
static void handler_bitspersample(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	i64 val;

	tg->pg->valcount_bitspersample = (u8)tg->valcount;
	if(tg->valcount<1) return;

	// FIXME: This is a multi-valued field.
	read_tag_value_as_int64(c, d, tg, 0, &val);
	tg->pg->bits_per_sample = (u32)val;
}

// Assembly:
movq (%rdx), %rax
movq 0x18(%rdx), %rcx
movb %cl, 0x9b(%rax)
testq %rcx, %rcx
jle 0xce3b7
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsp, %r14
xorl %ecx, %ecx
movq %r14, %r8
callq 0xd03d8
movl (%r14), %eax
movq (%rbx), %rcx
movl %eax, 0x28(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_compression
static int valdec_compression(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	const struct cmpr_meth_info *cmi;

	cmi = find_cmpr_meth_info((u32)vp->n);

	if(cmi && cmi->name) {
		ucstring_append_sz(vr->s, cmi->name, DE_ENCODING_UTF8);
	}
	else {
		ucstring_append_sz(vr->s, "?", DE_ENCODING_LATIN1);
	}
	return 1;
}

// Assembly:
movl 0x18(%rsi), %esi
xorl %eax, %eax
leaq 0xbdddc(%rip), %rcx     # 0x18c1a0
xorl %edi, %edi
cmpl %esi, (%rdi,%rcx)
je 0xce3da
addq $0x18, %rdi
cmpq $0x318, %rdi            # imm = 0x318
jne 0xce3c6
jmp 0xce3e0
addq %rdi, %rcx
movq %rcx, %rax
pushq %rax
testq %rax, %rax
je 0xce3f9
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0xce3f9
movq (%rdx), %rdi
movl $0x2, %edx
jmp 0xce408
movq (%rdx), %rdi
leaq 0x5da66(%rip), %rsi     # 0x12be69
movl $0x5, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_threshholding
static int valdec_threshholding(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "not dithered"}, {2, "ordered dither"}, {3, "error diffusion"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbe12d(%rip), %r8      # 0x18c5a0
leaq 0x5d9ef(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xce48a
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xce497
addq $0x10, %rcx
cmpq $0x38, %rcx
jne 0xce47a
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_fillorder
static int valdec_fillorder(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "MSB-first"}, {2, "LSB-first"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbe117(%rip), %r8      # 0x18c5d0
leaq 0x5d9a9(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xce4d0
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xce4dd
addq $0x10, %rcx
cmpq $0x20, %rcx
jne 0xce4c0
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_strileoffsets
static void handler_strileoffsets(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	struct page_ctx *pg = tg->pg;
	i64 i;

	if(tni->tagnum==TAG_TILEOFFSETS) {
		pg->have_tile_tags = 1;
	}
	else {
		pg->have_strip_tags = 1;
	}
	if(!alloc_striledata(c, pg, tg->valcount)) return;

	for(i=0; i<tg->valcount; i++) {
		read_tag_value_as_int64(c, d, tg, i, &pg->strile_data[i].pos);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdx), %r12
cmpl $0x144, (%rcx)          # imm = 0x144
jne 0xce516
movb $0x1, 0x16(%r12)
jmp 0xce51c
movb $0x1, 0x15(%r12)
movq 0x18(%rbx), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0xd0804
testl %eax, %eax
je 0xce564
cmpq $0x0, 0x18(%rbx)
jle 0xce564
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0xb8(%r12), %r8
addq %rbp, %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xd03d8
incq %r13
addq $0x10, %rbp
cmpq 0x18(%rbx), %r13
jl 0xce53b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_strilebytecounts
static void handler_strilebytecounts(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	struct page_ctx *pg = tg->pg;
	i64 i;

	pg->have_strilebytecounts = 1;
	if(tni->tagnum==TAG_TILEBYTECOUNTS) {
		pg->have_tile_tags = 1;
	}
	else {
		pg->have_strip_tags = 1;
	}
	if(!alloc_striledata(c, pg, tg->valcount)) return;

	for(i=0; i<tg->valcount; i++) {
		read_tag_value_as_int64(c, d, tg, i, &pg->strile_data[i].len);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdx), %r12
movb $0x1, 0x17(%r12)
cmpl $0x145, (%rcx)          # imm = 0x145
jne 0xce5c4
movb $0x1, 0x16(%r12)
jmp 0xce5ca
movb $0x1, 0x15(%r12)
movq 0x18(%rbx), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0xd0804
testl %eax, %eax
je 0xce615
cmpq $0x0, 0x18(%rbx)
jle 0xce615
movl $0x8, %ebp
xorl %r13d, %r13d
movq 0xb8(%r12), %r8
addq %rbp, %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xd03d8
incq %r13
addq $0x10, %rbp
cmpq 0x18(%rbx), %r13
jl 0xce5ec
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_resolution
static void handler_resolution(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	struct numeric_value nv;

	if(tg->valcount<1) return;
	read_numeric_value(c, d, tg, 0, &nv, NULL);
	if(!nv.isvalid) return;
	tg->pg->have_density = 1;
	if(tg->tagnum==TAG_XRESOLUTION) {
		tg->pg->density_ImageWidth = nv.val_double;
	}
	else if(tg->tagnum==TAG_YRESOLUTION) {
		tg->pg->density_ImageLength = nv.val_double;
	}
}

// Assembly:
cmpq $0x0, 0x18(%rdx)
jle 0xce683
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsp, %r14
xorl %ecx, %ecx
movq %r14, %r8
xorl %r9d, %r9d
callq 0xd0867
cmpl $0x0, (%r14)
je 0xce67c
movq (%rbx), %rax
movb $0x1, 0x14(%rax)
movl 0x8(%rbx), %ecx
cmpl $0x11a, %ecx            # imm = 0x11A
je 0xce66c
cmpl $0x11b, %ecx            # imm = 0x11B
jne 0xce67c
movl $0x58, %ecx
jmp 0xce671
movl $0x50, %ecx
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%rcx)
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_planarconfiguration
static int valdec_planarconfiguration(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "contiguous"}, {2, "separated"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbdf5c(%rip), %r8      # 0x18c5f0
leaq 0x5d7ce(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xce6ab
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xce6b8
addq $0x10, %rcx
cmpq $0x20, %rcx
jne 0xce69b
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_t4options
static int valdec_t4options(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	if(vp->n<1) return 0;

	if(vp->n&0x1) {
		ucstring_append_flags_item(vr->s, "2-d encoding");
	}
	if(vp->n&0x2) {
		ucstring_append_flags_item(vr->s, "uncompressed mode allowed");
	}
	if(vp->n&0x4) {
		ucstring_append_flags_item(vr->s, "has fill bits");
	}
	if((vp->n & ~0x7)!=0) {
		ucstring_append_flags_item(vr->s, "?");
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x18(%rsi), %rax
testq %rax, %rax
jle 0xce739
movq %rdx, %rbx
movq %rsi, %r14
testb $0x1, %al
je 0xce6f0
movq (%rbx), %rdi
leaq 0x70542(%rip), %rsi     # 0x13ec2d
callq 0xf7566
testb $0x2, 0x18(%r14)
je 0xce706
movq (%rbx), %rdi
leaq 0x70539(%rip), %rsi     # 0x13ec3a
callq 0xf7566
testb $0x4, 0x18(%r14)
je 0xce71c
movq (%rbx), %rdi
leaq 0x7053d(%rip), %rsi     # 0x13ec54
callq 0xf7566
movl $0x1, %ebp
cmpq $0x8, 0x18(%r14)
jb 0xce73b
movq (%rbx), %rdi
leaq 0x5d737(%rip), %rsi     # 0x12be69
callq 0xf7566
jmp 0xce73b
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_t6options
static int valdec_t6options(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	if(vp->n<1) return 0;

	if(vp->n&0x2) {
		ucstring_append_flags_item(vr->s, "uncompressed mode allowed");
	}
	if((vp->n & ~0x2)!=0) {
		ucstring_append_flags_item(vr->s, "?");
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x18(%rsi), %rax
testq %rax, %rax
jle 0xce788
movq %rdx, %rbx
movq %rsi, %r14
testb $0x2, %al
je 0xce768
movq (%rbx), %rdi
leaq 0x704d7(%rip), %rsi     # 0x13ec3a
callq 0xf7566
movl $0x1, %ebp
testq $-0x3, 0x18(%r14)
je 0xce78a
movq (%rbx), %rdi
leaq 0x5d6e8(%rip), %rsi     # 0x12be69
callq 0xf7566
jmp 0xce78a
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_resolutionunit
static int valdec_resolutionunit(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "unspecified"}, {2, "pixels/inch"}, {3, "pixels/cm"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbde6c(%rip), %r8      # 0x18c610
leaq 0x5d6be(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xce7bb
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xce7c8
addq $0x10, %rcx
cmpq $0x38, %rcx
jne 0xce7ab
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_pagenumber
static int valdec_pagenumber(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	if(vp->idx==0) {
		ucstring_printf(vr->s, DE_ENCODING_LATIN1, "page %d", (int)(vp->n+1));
		return 1;
	}
	if(vp->idx==1) {
		if(vp->n==0) {
			ucstring_append_sz(vr->s, "of an unknown number", DE_ENCODING_LATIN1);
		}
		else {
			ucstring_printf(vr->s, DE_ENCODING_LATIN1, "of %d", (int)vp->n);
		}
		return 1;
	}
	return 0;
}

// Assembly:
pushq %rax
movq 0x10(%rsi), %rcx
cmpq $0x1, %rcx
je 0xce802
xorl %eax, %eax
testq %rcx, %rcx
jne 0xce826
movq (%rdx), %rdi
movl 0x18(%rsi), %ecx
incl %ecx
leaq 0x72a02(%rip), %rdx     # 0x1411fd
movl $0x5, %esi
jmp 0xce81a
movq 0x18(%rsi), %rcx
movq (%rdx), %rdi
testq %rcx, %rcx
je 0xce828
leaq 0x466a1(%rip), %rdx     # 0x114eb6
movl $0x5, %esi
xorl %eax, %eax
callq 0xf6ab0
movl $0x1, %eax
popq %rcx
retq
leaq 0x70433(%rip), %rsi     # 0x13ec62
movl $0x5, %edx
callq 0xf6a40
jmp 0xce821
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_datetime
static void parse_tiff_datetime(deark *c, lctx *d, const struct taginfo *tg, struct de_timestamp *ts)
{
	i64 yr, mo, da;
	i64 hr, mi, se;

	if(tg->unit_size!=1) return;
	if(tg->valcount<19) return;
	// Format: "YYYY:MM:DD HH:MM:SS"
	yr = read_fixed_decimal(c->infile, tg->val_offset, 4);
	mo = read_fixed_decimal(c->infile, tg->val_offset+5, 2);
	da = read_fixed_decimal(c->infile, tg->val_offset+8, 2);
	hr = read_fixed_decimal(c->infile, tg->val_offset+11, 2);
	mi = read_fixed_decimal(c->infile, tg->val_offset+14, 2);
	se = read_fixed_decimal(c->infile, tg->val_offset+17, 2);
	de_make_timestamp(ts, yr, mo, da, hr, mi, se);
	if(ts->is_valid) {
		ts->tzcode = DE_TZCODE_UNKNOWN;
		ts->precision = DE_TSPREC_1SEC;
	}
}

// Assembly:
cmpq $0x1, 0x28(%rdx)
jne 0xce9ce
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
cmpq $0x13, 0x18(%rdx)
jl 0xce9c0
movq %rdi, %r15
movq (%r14), %rax
movq %rax, 0x28(%rsp)
addq $0xc0, %rax
movq %rax, 0x40(%rsp)
movq 0x18(%rdi), %rdi
movq 0x20(%r14), %rdx
leaq 0x10(%rsp), %r12
movl $0x4, %ecx
movq %r12, %rsi
callq 0xeeee8
xorl %ebx, %ebx
movb %bl, 0x4(%r12)
movq %r12, %rdi
callq 0xea786
movq %rax, 0x38(%rsp)
movq 0x18(%r15), %rdi
movq 0x20(%r14), %rdx
addq $0x5, %rdx
leaq 0x10(%rsp), %r12
movl $0x2, %ecx
movq %r12, %rsi
callq 0xeeee8
movb %bl, 0x2(%r12)
movq %r12, %rdi
callq 0xea786
movq %rax, 0x30(%rsp)
movq 0x18(%r15), %rdi
movq 0x20(%r14), %rdx
addq $0x8, %rdx
leaq 0x10(%rsp), %r12
movl $0x2, %ecx
movq %r12, %rsi
callq 0xeeee8
movb %bl, 0x2(%r12)
movq %r12, %rdi
callq 0xea786
movq %rax, %rbp
movq 0x18(%r15), %rdi
movq 0x20(%r14), %rdx
addq $0xb, %rdx
leaq 0x10(%rsp), %r12
movl $0x2, %ecx
movq %r12, %rsi
callq 0xeeee8
movb %bl, 0x2(%r12)
movq %r12, %rdi
callq 0xea786
movq %rax, %r12
movq 0x18(%r15), %rdi
movq 0x20(%r14), %rdx
addq $0xe, %rdx
leaq 0x10(%rsp), %r13
movl $0x2, %ecx
movq %r13, %rsi
callq 0xeeee8
movb %bl, 0x2(%r13)
movq %r13, %rdi
callq 0xea786
movq %rax, %r13
movq 0x18(%r15), %rdi
movq 0x20(%r14), %rdx
addq $0x11, %rdx
leaq 0x10(%rsp), %r14
movl $0x2, %ecx
movq %r14, %rsi
callq 0xeeee8
movb %bl, 0x2(%r14)
movq %r14, %rdi
callq 0xea786
movq %rax, (%rsp)
movq 0x40(%rsp), %r14
movq %r14, %rdi
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbp, %rcx
movq %r12, %r8
movq %r13, %r9
callq 0xeae97
cmpb %bl, (%r14)
je 0xce9c0
movq 0x28(%rsp), %rax
movw $0x1e00, 0xc1(%rax)     # imm = 0x1E00
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_predictor
static int valdec_predictor(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "none"}, {2, "horizontal differencing"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbdc61(%rip), %r8      # 0x18c640
leaq 0x5d483(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xce9f6
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcea03
addq $0x10, %rcx
cmpq $0x20, %rcx
jne 0xce9e6
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_subifd
static void handler_subifd(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	i64 j;
	i64 tmpoffset;
	u8 ifdtype = IFDTYPE_NORMAL;

	if(d->fmt==DE_TIFFFMT_NIKONMN && tg->tagnum==0x11) ifdtype = IFDTYPE_NIKONPREVIEW;
	else if(tg->tagnum==330) ifdtype = IFDTYPE_SUBIFD;
	else if(tg->tagnum==400) ifdtype = IFDTYPE_GLOBALPARAMS;
	else if(tg->tagnum==34665) ifdtype = IFDTYPE_EXIF;
	else if(tg->tagnum==34731) ifdtype = IFDTYPE_MASKSUBIFD;
	else if(tg->tagnum==34853) ifdtype = IFDTYPE_GPS;
	else if(tg->tagnum==40965) ifdtype = IFDTYPE_EXIFINTEROP;

	for(j=0; j<tg->valcount;j++) {
		read_tag_value_as_int64(c, d, tg, j, &tmpoffset);
		de_dbg(c, "offset of %s: %d", tni->tagname, (int)tmpoffset);
		push_ifd(c, d, tmpoffset, ifdtype, 0);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
cmpl $0x9, 0x4(%rsi)
jne 0xceca9
movb $0x7, %al
cmpl $0x11, 0x8(%rbx)
je 0xcecf7
movl 0x8(%rbx), %eax
cmpl $0x87aa, %eax           # imm = 0x87AA
jg 0xceccc
cmpl $0x14a, %eax            # imm = 0x14A
je 0xcece5
cmpl $0x190, %eax            # imm = 0x190
je 0xcecf1
cmpl $0x8769, %eax           # imm = 0x8769
jne 0xceced
movb $0x2, %al
jmp 0xcecf7
cmpl $0x87ab, %eax           # imm = 0x87AB
je 0xcece9
cmpl $0x8825, %eax           # imm = 0x8825
je 0xcecf5
cmpl $0xa005, %eax           # imm = 0xA005
jne 0xceced
movb $0x3, %al
jmp 0xcecf7
movb $0x1, %al
jmp 0xcecf7
movb $0x9, %al
jmp 0xcecf7
xorl %eax, %eax
jmp 0xcecf7
movb $0x5, %al
jmp 0xcecf7
movb $0x4, %al
cmpq $0x0, 0x18(%rbx)
jle 0xced58
movzbl %al, %eax
movl %eax, 0xc(%rsp)
xorl %r13d, %r13d
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
leaq 0x10(%rsp), %r8
callq 0xd03d8
movq 0x8(%r15), %rdx
movq 0x10(%rsp), %rbp
movq %r12, %rdi
leaq 0x6ffa8(%rip), %rsi     # 0x13ecd9
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movl 0xc(%rsp), %ecx
xorl %r8d, %r8d
callq 0xcddcb
incq %r13
cmpq 0x18(%rbx), %r13
jl 0xced08
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_inkset
static int valdec_inkset(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "CMYK"}, {2, "not CMYK"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbd8e9(%rip), %r8      # 0x18c660
leaq 0x5d0eb(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xced8e
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xced9b
addq $0x10, %rcx
cmpq $0x20, %rcx
jne 0xced7e
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_extrasamples
static void handler_extrasamples(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	struct page_ctx *pg = tg->pg;
	u8 i;

	pg->extrasamples_count = (u8)tg->valcount;
	if(pg->extrasamples_count>DE_TIFF_MAX_SAMPLES) {
		pg->extrasamples_count = DE_TIFF_MAX_SAMPLES;
	}

	for(i=0; i<pg->extrasamples_count; i++) {
		i64 val;

		read_tag_value_as_int64(c, d, tg, 0, &val);
		pg->extrasample_type[(size_t)i] = (u8)val;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdx), %r13
movq 0x18(%rdx), %rax
movzbl %al, %ecx
cmpl $0xb, %ecx
movl $0xa, %ecx
cmovbl %eax, %ecx
movb %cl, 0x9c(%r13)
testb %cl, %cl
je 0xcee14
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %ebp, %ebp
movq %rsp, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0xd03d8
movb (%rsp), %al
movb %al, 0x9d(%r13,%rbp)
incq %rbp
movzbl 0x9c(%r13), %eax
cmpq %rax, %rbp
jb 0xcede6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_extrasamples
static int valdec_extrasamples(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{0, "unspecified"}, {1, "assoc-alpha"}, {2, "unassoc-alpha"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbd84a(%rip), %r8      # 0x18c680
leaq 0x5d02c(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xcee4d
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcee5a
addq $0x10, %rcx
cmpq $0x38, %rcx
jne 0xcee3d
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_sampleformat
static int valdec_sampleformat(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "uint"}, {2, "signed int"}, {3, "float"}, {4, "undefined"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbd808(%rip), %r8      # 0x18c6b0
leaq 0x5cfba(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xceebf
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xceecc
addq $0x10, %rcx
cmpq $0x40, %rcx
jne 0xceeaf
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_jpegproc
static int valdec_jpegproc(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "baseline"}, {14, "lossless+huffman"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbd802(%rip), %r8      # 0x18c6f0
leaq 0x5cf74(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xcef05
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcef12
addq $0x10, %rcx
cmpq $0x20, %rcx
jne 0xceef5
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_ycbcrpositioning
static int valdec_ycbcrpositioning(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{1, "centered"}, {2, "cosited"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbd7dc(%rip), %r8      # 0x18c710
leaq 0x5cf2e(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xcef4b
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcef58
addq $0x10, %rcx
cmpq $0x20, %rcx
jne 0xcef3b
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_matteing
static void handler_matteing(deark *c, lctx *d, const struct taginfo *tg,
	const struct tagnuminfo *tni)
{
	i64 val;

	if(tg->valcount<1) return;
	read_tag_value_as_int64(c, d, tg, 0, &val);
	if(val==1) {
		tg->pg->extrasamples_count = 1;
		tg->pg->extrasample_type[0] = 1; // = Assoc. alpha
	}
}

// Assembly:
cmpq $0x0, 0x18(%rdx)
jle 0xcefbf
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsp, %r14
xorl %ecx, %ecx
movq %r14, %r8
callq 0xd03d8
cmpq $0x1, (%r14)
jne 0xcefb8
movq (%rbx), %rax
movw $0x101, 0x9c(%rax)      # imm = 0x101
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: handler_photoshoprsrc
static void handler_photoshoprsrc(deark *c, lctx *d, const struct taginfo *tg, const struct tagnuminfo *tni)
{
	de_dbg(c, "Photoshop resources at %d, len=%d",
		(int)tg->val_offset, (int)tg->total_size);
	de_dbg_indent(c, 1);
	fmtutil_handle_photoshop_rsrc(c, c->infile, tg->val_offset, tg->total_size,
		d->is_deark_8bim?0x2:0x0);
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl 0x20(%rdx), %edx
movl 0x30(%r14), %ecx
leaq 0x6fc56(%rip), %rsi     # 0x13ed73
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rsi
movq 0x20(%r14), %rdx
movq 0x30(%r14), %rcx
xorl %r8d, %r8d
cmpb $0x0, 0x18(%r15)
setne %r8b
addl %r8d, %r8d
movq %rbx, %rdi
callq 0xf8388
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %r15
jmp 0xe9585
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_exposureprogram
static int valdec_exposureprogram(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{0, "not defined"}, {1, "manual"}, {2, "normal program"}, {3, "aperture priority"},
		{4, "shutter priority"}, {5, "creative program"}, {6, "action program"},
		{7, "portrait mode"}, {8, "landscape mode"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbd596(%rip), %r8      # 0x18c730
leaq 0x5ccc8(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xcf1b1
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcf1c1
addq $0x10, %rcx
cmpq $0x98, %rcx
jne 0xcf1a1
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_componentsconfiguration
static int valdec_componentsconfiguration(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{0, "n/a"}, {1, "Y"}, {2, "Cb"}, {3, "Cr"}, {4, "R"}, {5, "G"}, {6, "B"},
		{48, "n/a?"}, {49, "Y?"}, {50, "Cb?"}, {51, "Cr?"}, {52, "R?"}, {53, "G?"}, {54, "B?"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbd590(%rip), %r8      # 0x18c7c0
leaq 0x5cc32(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xcf247
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcf257
addq $0x10, %rcx
cmpq $0xe8, %rcx
jne 0xcf237
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_meteringmode
static int valdec_meteringmode(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{0, "unknown"}, {1, "Average"}, {2, "CenterWeightedAverage"},
		{3, "Spot"}, {4, "MultiSpot"}, {5, "Pattern"}, {6, "Partial"},
		{255, "other"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
xorl %ecx, %ecx
leaq 0xbd627(%rip), %r8      # 0x18c8a0
leaq 0x5cbe9(%rip), %rdx     # 0x12be69
cmpq %rax, (%rcx,%r8)
jne 0xcf290
movq 0x8(%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcf2a0
addq $0x10, %rcx
cmpq $0x80, %rcx
jne 0xcf280
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_lightsource
static int valdec_lightsource(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	static const struct int_and_str name_map[] = {
		{0, "unknown"}, {1, "Daylight"}, {2, "Fluorescent"},
		{3, "Tungsten"}, {4, "Flash"}, {9, "Fine weather"}, {10, "Cloudy weather"},
		{11, "Shade"}, {12, "D 5700-7100K"}, {13, "N 4600-5500K"},
		{14, "W 3800-4500K"}, {15, "WW 3250-3800K"}, {16, "L 2600-3260K"},
		{17, "Standard light A"}, {18, "Standard light B"}, {19, "Standard light C"},
		{20, "D55"}, {21, "D65"}, {22, "D75"}, {23, "D50"}, {24, "ISO studio tungsten"},
		{255, "other"}
	};
	lookup_str_and_append_to_ucstring(name_map, ITEMS_IN_ARRAY(name_map), vp->n, vr->s);
	return 1;
}

// Assembly:
movq 0x18(%rsi), %rax
movq (%rdx), %rdi
movl $0x8, %ecx
leaq 0xbd65b(%rip), %r8      # 0x18c920
leaq 0x5cb9d(%rip), %rdx     # 0x12be69
cmpq %rax, -0x8(%rcx,%r8)
jne 0xcf2dc
movq (%rcx,%r8), %rsi
testq %rsi, %rsi
jne 0xcf2ec
addq $0x10, %rcx
cmpq $0x168, %rcx            # imm = 0x168
jne 0xcf2cc
movq %rdx, %rsi
pushq %rax
movl $0x2, %edx
callq 0xf6a40
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/tiff.c
// Function: valdec_flash
static int valdec_flash(deark *c, const struct valdec_params *vp, struct valdec_result *vr)
{
	i64 v;

	ucstring_append_flags_item(vr->s, (vp->n&0x01)?"flash fired":"flash did not fire");

	v = (vp->n&0x06)>>1;
	if(v==0) ucstring_append_flags_item(vr->s, "no strobe return detection function");
	else if(v==2) ucstring_append_flags_item(vr->s, "strobe return light not detected");
	else if(v==3) ucstring_append_flags_item(vr->s, "strobe return light detected");

	v = (vp->n&0x18)>>3;
	if(v==1) ucstring_append_flags_item(vr->s, "compulsory flash firing");
	else if(v==2) ucstring_append_flags_item(vr->s, "compulsory flash suppression");
	else if(v==3) ucstring_append_flags_item(vr->s, "auto mode");

	ucstring_append_flags_item(vr->s, (vp->n&0x20)?"no flash function":"flash function present");

	if(vp->n&0x40) ucstring_append_flags_item(vr->s, "red eye reduction supported");

	if((vp->n & ~0x7f)!=0) {
		ucstring_append_flags_item(vr->s, "?");
	}

	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq (%rdx), %rdi
testb $0x1, 0x18(%rsi)
leaq 0x6fc27(%rip), %rax     # 0x13ef3d
leaq 0x6fc14(%rip), %rsi     # 0x13ef31
cmoveq %rax, %rsi
callq 0xf7566
movl 0x18(%r14), %eax
shrl %eax
andl $0x3, %eax
leaq 0x6d0ae(%rip), %rcx     # 0x13c3e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6fc0a(%rip), %rsi     # 0x13ef50
jmp 0xcf358
leaq 0x6fc25(%rip), %rsi     # 0x13ef74
jmp 0xcf358
leaq 0x6fc3d(%rip), %rsi     # 0x13ef95
movq (%rbx), %rdi
callq 0xf7566
movl 0x18(%r14), %eax
shrl $0x3, %eax
andl $0x3, %eax
leaq 0x6d083(%rip), %rcx     # 0x13c3f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6fc31(%rip), %rsi     # 0x13efb2
jmp 0xcf393
leaq 0x6fc40(%rip), %rsi     # 0x13efca
jmp 0xcf393
leaq 0x6fc54(%rip), %rsi     # 0x13efe7
movq (%rbx), %rdi
callq 0xf7566
movq (%rbx), %rdi
testb $0x20, 0x18(%r14)
leaq 0x6fc59(%rip), %rax     # 0x13f003
leaq 0x6fc40(%rip), %rsi     # 0x13eff1
cmoveq %rax, %rsi
callq 0xf7566
testb $0x40, 0x18(%r14)
je 0xcf3d0
movq (%rbx), %rdi
leaq 0x6fc4f(%rip), %rsi     # 0x13f01a
callq 0xf7566
cmpq $0x80, 0x18(%r14)
jb 0xcf3e9
movq (%rbx), %rdi
leaq 0x5ca85(%rip), %rsi     # 0x12be69
callq 0xf7566
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq