// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/bpg.c
// Function: do_hevc_file
static void do_hevc_file(deark *c, lctx *d)
{
	i64 pos;
	u8 b;

	pos = 4;
	b = de_getbyte(pos);
	pos++;
	d->pixel_format = b>>5;
	d->alpha_flag = (b>>4)&0x01;
	d->bit_depth = (i64)(b&0x0f) +8;
	de_dbg(c, "pixel format: %d", (int)d->pixel_format);
	de_dbg(c, "alpha flag: %d", (int)d->alpha_flag);
	de_dbg(c, "bit depth: %d", (int)d->bit_depth);

	b = de_getbyte(pos);
	pos++;
	d->color_space = b>>4;
	d->extension_present_flag = (b>>3)&0x01;
	d->alpha2_flag = (b>>2)&0x01;
	d->limited_range_flag = (b>>1)&0x01;
	de_dbg(c, "color_space: %d", (int)d->color_space);
	de_dbg(c, "extension_present_flag: %d", (int)d->extension_present_flag);
	de_dbg(c, "alpha2_flag: %d", (int)d->alpha2_flag);
	de_dbg(c, "limited_range_flag: %d", (int)d->limited_range_flag);

	d->width = get_ue7(c, &pos);
	d->height = get_ue7(c, &pos);
	de_dbg_dimensions(c, d->width, d->height);


	d->picture_data_len = get_ue7(c, &pos);
	de_dbg(c, "picture_data_len: %d%s", (int)d->picture_data_len,
		(d->picture_data_len==0)?" (= to EOF)":"");

	if(d->extension_present_flag) {
		d->extension_data_len = get_ue7(c, &pos);
		de_dbg(c, "extension data len: %d", (int)d->extension_data_len);
	}

	if(d->extension_present_flag) {
		do_extensions(c, d, pos);
		pos += d->extension_data_len;
	}

	de_dbg(c, "hevc_header_and_data begins at %d", (int)pos);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x4, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165060
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movzbl -0x19(%rbp), %eax
sarl $0x5, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x10(%rax)
movzbl -0x19(%rbp), %eax
sarl $0x4, %eax
andl $0x1, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x11(%rax)
movzbl -0x19(%rbp), %eax
andl $0xf, %eax
movslq %eax, %rcx
addq $0x8, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x10(%rax), %edx
leaq 0x1598e3(%rip), %rsi    # 0x1a4577
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x11(%rax), %edx
leaq 0x1598da(%rip), %rsi    # 0x1a4588
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0x152b26(%rip), %rsi    # 0x19d7f0
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165060
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movzbl -0x19(%rbp), %eax
sarl $0x4, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x20(%rax)
movzbl -0x19(%rbp), %eax
sarl $0x3, %eax
andl $0x1, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x21(%rax)
movzbl -0x19(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x22(%rax)
movzbl -0x19(%rbp), %eax
sarl %eax
andl $0x1, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x23(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %edx
leaq 0x15984b(%rip), %rsi    # 0x1a4597
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %edx
leaq 0x159841(%rip), %rsi    # 0x1a45a7
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x22(%rax), %edx
leaq 0x159842(%rip), %rsi    # 0x1a45c2
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x23(%rax), %edx
leaq 0x159838(%rip), %rsi    # 0x1a45d2
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x4aed0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x4aed0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x4aed0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
leaq 0x185db3(%rip), %rcx    # 0x1d0bd0
leaq 0x1597dc(%rip), %rax    # 0x1a4600
cmpq $0x0, %rsi
cmoveq %rax, %rcx
leaq 0x1597b6(%rip), %rsi    # 0x1a45e9
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpb $0x0, 0x21(%rax)
je 0x4ae78
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x4aed0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %edx
leaq 0x15979b(%rip), %rsi    # 0x1a460c
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpb $0x0, 0x21(%rax)
je 0x4aea3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x4af60
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %edx
leaq 0x15976f(%rip), %rsi    # 0x1a4623
movb $0x0, %al
callq 0x15b0d0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)