// File: JMMackenzie[P]binary_to_jass/./compress_integer_variable_byte.h
// Function: void JASS::compress_integer_variable_byte::compress_into<unsigned char*>(unsigned char*&, unsigned int)
static inline void compress_into(DESTINATION &destination, integer value)
				{
				/*
					Work out how many bytes it'll take to encode
				*/
				if (value < ((uint64_t)1 << 7))
					goto one;
				else if (value < ((uint64_t)1 << 14))
					goto two;
				else if (value < ((uint64_t)1 << 21))
					goto three;
				else if (value < ((uint64_t)1 << 28))
					goto four;
#if JASS_COMPRESS_INTEGER_BITS_PER_INTEGER == 32
				goto five;
#else
				else if (value < ((uint64_t)1 << 35))
					goto five;
				else if (value < ((uint64_t)1 << 42))
					goto six;
				else if (value < ((uint64_t)1 << 49))
					goto seven;
				else if (value < ((uint64_t)1 << 56))
					goto eight;
				else if (value < ((uint64_t)1 << 63))
					goto nine;
				else
					goto ten;
#endif

				/*
					Now encode byte at a time with fall-through
				*/
#if JASS_COMPRESS_INTEGER_BITS_PER_INTEGER == 64
				ten:
					*destination = (value >> 63) & 0x7F;
					++destination;
				nine:
					*destination = (value >> 56) & 0x7F;
					++destination;
				eight:
					*destination = (value >> 49) & 0x7F;
					++destination;
				seven:
					*destination = (value >> 42) & 0x7F;
					++destination;
				six:
					*destination = (value >> 35) & 0x7F;
					++destination;
#endif
				five:
					*destination = (value >> 28) & 0x7F;
					++destination;
				four:
					*destination = (value >> 21) & 0x7F;
					++destination;
				three:
					*destination = (value >> 14) & 0x7F;
					++destination;
				two:
					*destination = (value >> 7) & 0x7F;
					++destination;
				one:
					*destination = (value & 0x7F) | 0x80;
					++destination;
				}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl -0xc(%rsp), %eax
cmpq $0x80, %rax
jae 0x301eaa
jmp 0x301f73
movl -0xc(%rsp), %eax
cmpq $0x4000, %rax           # imm = 0x4000
jae 0x301ebb
jmp 0x301f4e
movl -0xc(%rsp), %eax
cmpq $0x200000, %rax         # imm = 0x200000
jae 0x301ec9
jmp 0x301f29
movl -0xc(%rsp), %eax
cmpq $0x10000000, %rax       # imm = 0x10000000
jae 0x301ed7
jmp 0x301f04
jmp 0x301ed9
jmp 0x301edb
jmp 0x301edd
jmp 0x301edf
movl -0xc(%rsp), %eax
shrl $0x1c, %eax
andl $0x7f, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movq (%rax), %rax
movb %cl, (%rax)
movq -0x8(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl -0xc(%rsp), %eax
shrl $0x15, %eax
andl $0x7f, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movq (%rax), %rax
movb %cl, (%rax)
movq -0x8(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl -0xc(%rsp), %eax
shrl $0xe, %eax
andl $0x7f, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movq (%rax), %rax
movb %cl, (%rax)
movq -0x8(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl -0xc(%rsp), %eax
shrl $0x7, %eax
andl $0x7f, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movq (%rax), %rax
movb %cl, (%rax)
movq -0x8(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl -0xc(%rsp), %eax
andl $0x7f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x8(%rsp), %rax
movq (%rax), %rax
movb %cl, (%rax)
movq -0x8(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
retq
nopl (%rax,%rax)