// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/deps/lua/src/lua_cmsgpack.c
// Function: mp_encode_int
void mp_encode_int(lua_State *L, mp_buf *buf, int64_t n) {
    unsigned char b[9];
    int enclen;

    if (n >= 0) {
        if (n <= 127) {
            b[0] = n & 0x7f;    /* positive fixnum */
            enclen = 1;
        } else if (n <= 0xff) {
            b[0] = 0xcc;        /* uint 8 */
            b[1] = n & 0xff;
            enclen = 2;
        } else if (n <= 0xffff) {
            b[0] = 0xcd;        /* uint 16 */
            b[1] = (n & 0xff00) >> 8;
            b[2] = n & 0xff;
            enclen = 3;
        } else if (n <= 0xffffffffLL) {
            b[0] = 0xce;        /* uint 32 */
            b[1] = (n & 0xff000000) >> 24;
            b[2] = (n & 0xff0000) >> 16;
            b[3] = (n & 0xff00) >> 8;
            b[4] = n & 0xff;
            enclen = 5;
        } else {
            b[0] = 0xcf;        /* uint 64 */
            b[1] = (n & 0xff00000000000000LL) >> 56;
            b[2] = (n & 0xff000000000000LL) >> 48;
            b[3] = (n & 0xff0000000000LL) >> 40;
            b[4] = (n & 0xff00000000LL) >> 32;
            b[5] = (n & 0xff000000) >> 24;
            b[6] = (n & 0xff0000) >> 16;
            b[7] = (n & 0xff00) >> 8;
            b[8] = n & 0xff;
            enclen = 9;
        }
    } else {
        if (n >= -32) {
            b[0] = ((signed char)n);   /* negative fixnum */
            enclen = 1;
        } else if (n >= -128) {
            b[0] = 0xd0;        /* int 8 */
            b[1] = n & 0xff;
            enclen = 2;
        } else if (n >= -32768) {
            b[0] = 0xd1;        /* int 16 */
            b[1] = (n & 0xff00) >> 8;
            b[2] = n & 0xff;
            enclen = 3;
        } else if (n >= -2147483648LL) {
            b[0] = 0xd2;        /* int 32 */
            b[1] = (n & 0xff000000) >> 24;
            b[2] = (n & 0xff0000) >> 16;
            b[3] = (n & 0xff00) >> 8;
            b[4] = n & 0xff;
            enclen = 5;
        } else {
            b[0] = 0xd3;        /* int 64 */
            b[1] = (n & 0xff00000000000000LL) >> 56;
            b[2] = (n & 0xff000000000000LL) >> 48;
            b[3] = (n & 0xff0000000000LL) >> 40;
            b[4] = (n & 0xff00000000LL) >> 32;
            b[5] = (n & 0xff000000) >> 24;
            b[6] = (n & 0xff0000) >> 16;
            b[7] = (n & 0xff00) >> 8;
            b[8] = n & 0xff;
            enclen = 9;
        }
    }
    mp_buf_append(L,buf,b,enclen);
}

// Assembly:
subq $0x18, %rsp
testq %rdx, %rdx
js 0x8a1ec
cmpq $0x7f, %rdx
jbe 0x8a1f2
cmpq $0xff, %rdx
ja 0x8a213
movb $-0x34, 0xf(%rsp)
jmp 0x8a208
cmpq $-0x20, %rdx
jb 0x8a1fd
movb %dl, 0xf(%rsp)
pushq $0x1
jmp 0x8a2f1
cmpq $-0x80, %rdx
jb 0x8a223
movb $-0x30, 0xf(%rsp)
movb %dl, 0x10(%rsp)
pushq $0x2
jmp 0x8a2f1
cmpq $0xffff, %rdx           # imm = 0xFFFF
ja 0x8a240
movb $-0x33, 0xf(%rsp)
jmp 0x8a231
cmpq $-0x8000, %rdx          # imm = 0x8000
jb 0x8a250
movb $-0x2f, 0xf(%rsp)
movb %dh, 0x10(%rsp)
movb %dl, 0x11(%rsp)
pushq $0x3
jmp 0x8a2f1
movq %rdx, %rax
shrq $0x20, %rax
jne 0x8a27c
movb $-0x32, 0xf(%rsp)
jmp 0x8a25e
cmpq $-0x80000000, %rdx      # imm = 0x80000000
jb 0x8a2a4
movb $-0x2e, 0xf(%rsp)
movl %edx, %eax
shrl $0x18, %eax
movb %al, 0x10(%rsp)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x11(%rsp)
movb %dh, 0x12(%rsp)
movb %dl, 0x13(%rsp)
pushq $0x5
jmp 0x8a2f1
movb $-0x31, 0xf(%rsp)
movq %rdx, %rcx
shrq $0x38, %rcx
movb %cl, 0x10(%rsp)
movq %rdx, %rcx
shrq $0x30, %rcx
movb %cl, 0x11(%rsp)
movq %rdx, %rcx
shrq $0x28, %rcx
movb %cl, 0x12(%rsp)
jmp 0x8a2d1
movb $-0x2d, 0xf(%rsp)
movq %rdx, %rax
shrq $0x38, %rax
movb %al, 0x10(%rsp)
movq %rdx, %rax
shrq $0x30, %rax
movb %al, 0x11(%rsp)
movq %rdx, %rax
shrq $0x28, %rax
movb %al, 0x12(%rsp)
movq %rdx, %rax
shrq $0x20, %rax
movb %al, 0x13(%rsp)
movl %edx, %eax
shrl $0x18, %eax
movb %al, 0x14(%rsp)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x15(%rsp)
movb %dh, 0x16(%rsp)
movb %dl, 0x17(%rsp)
pushq $0x9
popq %rcx
leaq 0xf(%rsp), %rdx
callq 0x8a013
addq $0x18, %rsp
retq