// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %cl, -0x19(%rbp)
movb %al, -0x1a(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x12e3c9
jmp 0x12e56d
cmpq $0x0, -0x18(%rbp)
jl 0x12e3e2
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x12e405
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %r8
xorl %eax, %eax
movl %eax, %edx
leaq 0x9a3e4(%rip), %rcx     # 0x1c87dd
movb $0x0, %al
callq 0x12dfd0
jmp 0x12e56d
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x12e424
movq -0x8(%rbp), %rdi
callq 0x15e600
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
cmpl $0x3e8, 0x48(%rax)      # imm = 0x3E8
jl 0x12e450
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq 0x9a3b1(%rip), %rcx     # 0x1c87f5
movb $0x0, %al
callq 0x12dfd0
jmp 0x12e56d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x15e810
cmpl $0x0, %eax
jne 0x12e48d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq 0x9a387(%rip), %rcx     # 0x1c8808
movb $0x0, %al
callq 0x12ee30
jmp 0x12e56d
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x12e4dc
movq -0x10(%rbp), %rax
movl $0xc8, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x30(%rax), %rsi
movl $0x10, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x34(%rax)
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jl 0x12e508
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq 0x9a2f6(%rip), %rcx     # 0x1c87f5
movb $0x0, %al
callq 0x12dfd0
jmp 0x12e56d
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rdx
movslq 0x34(%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movb -0x19(%rbp), %cl
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rdx
movslq 0x34(%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movb %cl, 0x8(%rax)
movb -0x1a(%rbp), %cl
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rdx
movslq 0x34(%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movb %cl, 0x9(%rax)
movq -0x10(%rbp), %rax
movl 0x34(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x34(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)