// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/gif.c
// Function: do_read_extension
static int do_read_extension(deark *c, lctx *d, i64 pos1, i64 *bytesused)
{
	i64 bytesused2 = 0;
	u8 ext_type;
	i64 pos;
	const char *ext_name;

	de_dbg_indent(c, 1);
	pos = pos1;
	*bytesused = 0;
	ext_type = de_getbyte(pos);

	switch(ext_type) {
	case 0x01: ext_name="plain text"; break;
	case 0xf9: ext_name="graphic control"; break;
	case 0xce: ext_name="frame name"; break;
	case 0xfe: ext_name="comment"; break;
	case 0xff: ext_name="application"; break;
	default: ext_name="?";
	}

	de_dbg(c, "extension type 0x%02x (%s) at %d", (unsigned int)ext_type, ext_name, (int)pos);
	pos++;

	de_dbg_indent(c, 1);
	switch(ext_type) {
	case 0x01:
		do_plaintext_extension(c, d, pos);
		break;
	case 0xf9:
		do_graphic_control_extension(c, d, pos);
		break;
	case 0xfe:
		do_comment_extension(c, d, pos);
		break;
	case 0xff:
		do_application_extension(c, d, pos);
		break;
	case 0xce:
		do_framename_extension(c, d, pos);
		break;
	}
	de_dbg_indent(c, -1);

	// TODO?: It's inefficient to do this unconditionally, since we usually have
	// already figured out where the extension ends.
	do_skip_subblocks(c, d, pos, &bytesused2);
	pos += bytesused2;

	*bytesused = pos - pos1;
	de_dbg_indent(c, -1);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x165060
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %eax
movl %eax, -0x44(%rbp)
subl $0x1, %eax
je 0x72ea3
jmp 0x72e73
movl -0x44(%rbp), %eax
subl $0xce, %eax
je 0x72ebd
jmp 0x72e7f
movl -0x44(%rbp), %eax
subl $0xf9, %eax
je 0x72eb0
jmp 0x72e8b
movl -0x44(%rbp), %eax
subl $0xfe, %eax
je 0x72eca
jmp 0x72e97
movl -0x44(%rbp), %eax
subl $0xff, %eax
je 0x72ed7
jmp 0x72ee4
leaq 0x138920(%rip), %rax    # 0x1ab7ca
movq %rax, -0x40(%rbp)
jmp 0x72eef
leaq 0x13891e(%rip), %rax    # 0x1ab7d5
movq %rax, -0x40(%rbp)
jmp 0x72eef
leaq 0x138921(%rip), %rax    # 0x1ab7e5
movq %rax, -0x40(%rbp)
jmp 0x72eef
leaq 0x15d474(%rip), %rax    # 0x1d0345
movq %rax, -0x40(%rbp)
jmp 0x72eef
leaq 0x1462c0(%rip), %rax    # 0x1b919e
movq %rax, -0x40(%rbp)
jmp 0x72eef
leaq 0x144d42(%rip), %rax    # 0x1b7c2d
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x29(%rbp), %edx
movq -0x40(%rbp), %rcx
movl -0x38(%rbp), %r8d
leaq 0x1388ea(%rip), %rsi    # 0x1ab7f0
xorl %eax, %eax
callq 0x15b0d0
movq -0x38(%rbp), %rax
incq %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movzbl -0x29(%rbp), %eax
movl %eax, -0x48(%rbp)
subl $0x1, %eax
je 0x72f64
jmp 0x72f34
movl -0x48(%rbp), %eax
subl $0xce, %eax
je 0x72fb0
jmp 0x72f40
movl -0x48(%rbp), %eax
subl $0xf9, %eax
je 0x72f77
jmp 0x72f4c
movl -0x48(%rbp), %eax
subl $0xfe, %eax
je 0x72f8a
jmp 0x72f58
movl -0x48(%rbp), %eax
subl $0xff, %eax
je 0x72f9d
jmp 0x72fc1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x73480
jmp 0x72fc1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x73640
jmp 0x72fc1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x738c0
jmp 0x72fc1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x73990
jmp 0x72fc1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x73be0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x28(%rbp), %rcx
callq 0x73c80
movq -0x28(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl $0x1, %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)