// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getint_ext
i64 dbuf_getint_ext(dbuf *f, i64 pos, unsigned int nbytes,
	int is_le, int is_signed)
{
	if(is_signed) {
		// TODO: Extend this to any number of bytes, 1-8.
		switch(nbytes) {
		case 1: return (i64)(signed char)dbuf_getbyte(f, pos); break;
		case 2: return dbuf_geti16x(f, pos, is_le); break;
		case 4: return dbuf_geti32x(f, pos, is_le); break;
		case 8: return dbuf_geti64x(f, pos, is_le); break;
		default:
			return dbuf_getint_ext_x(f, pos, nbytes, is_le);
		}
	}
	else {
		switch(nbytes) {
		case 1: return (i64)dbuf_getbyte(f, pos); break;
		case 2: return dbuf_getu16x(f, pos, is_le); break;
		case 4: return dbuf_getu32x(f, pos, is_le); break;
		case 8: return dbuf_geti64x(f, pos, is_le); break;
		default:
			return dbuf_getuint_ext_x(f, pos, nbytes, is_le);
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %rdx
testl %r8d, %r8d
je 0xef738
leal -0x1(%r14), %r15d
cmpl $0x7, %r15d
ja 0xef7ad
leaq 0x59482(%rip), %rax     # 0x148ba0
movslq (%rax,%r15,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %rdx, %rsi
callq 0xef0d5
movsbq %al, %rax
jmp 0xef858
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0xef850
leaq 0x59474(%rip), %rcx     # 0x148bc0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdx, %rsi
callq 0xef0d5
movzbl %al, %eax
jmp 0xef858
movq %rdx, %rsi
addq $0x18, %rsp
testl %ebp, %ebp
je 0xef845
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef536
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef5b7
movq %rdx, %rsi
addq $0x18, %rsp
testl %ebp, %ebp
je 0xef863
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef417
cmpl $0x18, %r14d
ja 0xef856
movl %r14d, %ebx
movq %rsp, %rsi
movq %rbx, %rcx
callq 0xeeee8
testl %ebp, %ebp
jne 0xef856
cmpl $0x8, %r14d
jbe 0xef7ee
addl $-0x8, %r14d
je 0xef7ee
movl %r14d, %ecx
xorl %eax, %eax
xorl %edx, %edx
cmpb $-0x1, (%rsp,%rdx)
jne 0xef858
incq %rdx
cmpq %rdx, %rcx
jne 0xef7e0
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
movl $0xff, %esi
cmpq %rbx, %rdx
jae 0xef805
movl %r15d, %esi
movzbl (%rsp,%rsi), %esi
shlq %cl, %rsi
orq %rsi, %rax
incq %rdx
decl %r15d
addq $0x8, %rcx
cmpq $0x8, %rdx
jne 0xef7f4
jmp 0xef858
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef614
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef570
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef4c3
cmpl $0x18, %r14d
jbe 0xef86e
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef3cb
movl %r14d, %ebx
movq %rsp, %rsi
movq %rbx, %rcx
callq 0xeeee8
testl %ebp, %ebp
je 0xef8ae
testl %r14d, %r14d
je 0xef856
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
movzbl (%rsp,%rdx), %esi
testq %rsi, %rsi
je 0xef8a0
cmpq $0x7, %rdx
ja 0xef856
shlq %cl, %rsi
orq %rsi, %rax
incq %rdx
addq $0x8, %rcx
cmpq %rdx, %rbx
jne 0xef88b
jmp 0xef858
testl %r14d, %r14d
je 0xef856
xorl %ecx, %ecx
xorl %eax, %eax
movq %rax, %rdx
shrq $0x38, %rdx
jne 0xef856
shlq $0x8, %rax
movzbl (%rsp,%rcx), %edx
orq %rdx, %rax
incq %rcx
cmpq %rcx, %rbx
jne 0xef8b7
jmp 0xef858