// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/gif.c
// Function: do_graphic_control_extension
static void do_graphic_control_extension(deark *c, lctx *d, i64 pos)
{
	i64 n;
	u8 packed_fields;
	u8 user_input_flag;
	i64 delay_time_raw;
	double delay_time;
	const char *name;

	discard_current_gce_data(c, d);

	n = (i64)de_getbyte(pos);
	if(n!=4) {
		de_warn(c, "Wrong graphic control ext. block size (expected 4, is %d)",
			(int)n);
		if(n<4) return;
	}

	d->gce = de_malloc(c, sizeof(struct gceinfo));

	packed_fields = de_getbyte(pos+1);
	de_dbg(c, "packed fields: 0x%02x", (unsigned int)packed_fields);
	de_dbg_indent(c, 1);
	d->gce->trns_color_idx_valid = packed_fields&0x01;
	de_dbg(c, "has transparency: %d", (int)d->gce->trns_color_idx_valid);

	user_input_flag = (packed_fields>>1)&0x1;
	de_dbg(c, "user input flag: %d", (int)user_input_flag);

	d->gce->disposal_method = (packed_fields>>2)&0x7;
	switch(d->gce->disposal_method) {
	case 0: name="unspecified"; break;
	case DISPOSE_LEAVE: name="leave in place"; break;
	case DISPOSE_BKGD: name="restore to background"; break;
	case DISPOSE_PREVIOUS: name="restore to previous"; break;
	default: name="?";
	}
	de_dbg(c, "disposal method: %d (%s)", (int)d->gce->disposal_method, name);
	de_dbg_indent(c, -1);

	delay_time_raw = de_getu16le(pos+2);
	delay_time = ((double)delay_time_raw)/100.0;
	de_dbg(c, "delay time: %d (%.02f sec)", (int)delay_time_raw, delay_time);

	if(d->gce->trns_color_idx_valid) {
		d->gce->trns_color_idx = de_getbyte(pos+4);
		de_dbg(c, "transparent color index: %d", (int)d->gce->trns_color_idx);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x733e0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165060
movzbl %al, %eax
movq %rax, -0x20(%rbp)
cmpq $0x4, -0x20(%rbp)
je 0x736a6
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0x138229(%rip), %rsi    # 0x1ab8ba
movb $0x0, %al
callq 0x15bc10
cmpq $0x4, -0x20(%rbp)
jge 0x736a4
jmp 0x738af
jmp 0x736a6
movq -0x8(%rbp), %rdi
movl $0x3, %esi
callq 0x15b780
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x440(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
incq %rsi
callq 0x165060
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x21(%rbp), %edx
leaq 0x138000(%rip), %rsi    # 0x1ab6e8
xorl %eax, %eax
movb %al, -0x49(%rbp)
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movb -0x49(%rbp), %al
movb -0x21(%rbp), %dl
andb $0x1, %dl
movq -0x10(%rbp), %rcx
movq 0x440(%rcx), %rcx
movb %dl, 0x1(%rcx)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x440(%rcx), %rcx
movzbl 0x1(%rcx), %edx
leaq 0x12a1ea(%rip), %rsi    # 0x19d91b
callq 0x15b0d0
movb -0x49(%rbp), %al
movb -0x21(%rbp), %cl
shrb %cl
andb $0x1, %cl
movb %cl, -0x22(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x22(%rbp), %edx
leaq 0x1381a1(%rip), %rsi    # 0x1ab8f4
callq 0x15b0d0
movb -0x21(%rbp), %cl
shrb $0x2, %cl
andb $0x7, %cl
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
movzbl (%rax), %eax
movq %rax, -0x48(%rbp)
subq $0x3, %rax
ja 0x737ce
movq -0x48(%rbp), %rax
leaq 0x137ebf(%rip), %rcx    # 0x1ab650
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x13fffc(%rip), %rax    # 0x1b379d
movq %rax, -0x40(%rbp)
jmp 0x737d9
leaq 0x13815a(%rip), %rax    # 0x1ab908
movq %rax, -0x40(%rbp)
jmp 0x737d9
leaq 0x13815c(%rip), %rax    # 0x1ab917
movq %rax, -0x40(%rbp)
jmp 0x737d9
leaq 0x138165(%rip), %rax    # 0x1ab92d
movq %rax, -0x40(%rbp)
jmp 0x737d9
leaq 0x144458(%rip), %rax    # 0x1b7c2d
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
movzbl (%rax), %edx
movq -0x40(%rbp), %rcx
leaq 0x13814b(%rip), %rsi    # 0x1ab941
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x2, %rsi
callq 0x165280
movq %rax, -0x30(%rbp)
cvtsi2sdq -0x30(%rbp), %xmm0
movsd 0x132a96(%rip), %xmm1   # 0x1a62c8
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
movsd -0x38(%rbp), %xmm0
leaq 0x138109(%rip), %rsi    # 0x1ab95a
movb $0x1, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
cmpb $0x0, 0x1(%rax)
je 0x738af
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
callq 0x165060
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
movb %cl, 0x2(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
movzbl 0x2(%rax), %edx
leaq 0x1380cd(%rip), %rsi    # 0x1ab975
movb $0x0, %al
callq 0x15b0d0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)