// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 0x9caa4
cmpq $0x7f, %rdx
jg 0x9cab8
andb $0x7f, %dl
jmp 0x9caaa
cmpq $-0x20, %rdx
jl 0x9cac8
movb %dl, 0xf(%rsp)
movl $0x1, %ecx
jmp 0x9cba8
cmpq $0xff, %rdx
jg 0x9cae1
movb $-0x34, 0xf(%rsp)
jmp 0x9cad3
cmpq $-0x80, %rdx
jl 0x9caf1
movb $-0x30, 0xf(%rsp)
movb %dl, 0x10(%rsp)
movl $0x2, %ecx
jmp 0x9cba8
cmpq $0xffff, %rdx           # imm = 0xFFFF
jg 0x9cb11
movb $-0x33, 0xf(%rsp)
jmp 0x9caff
cmpq $-0x8000, %rdx          # imm = 0x8000
jl 0x9cb22
movb $-0x2f, 0xf(%rsp)
movb %dh, 0x10(%rsp)
movb %dl, 0x11(%rsp)
movl $0x3, %ecx
jmp 0x9cba8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rdx
jg 0x9cb51
movb $-0x32, 0xf(%rsp)
jmp 0x9cb30
cmpq $-0x80000000, %rdx      # imm = 0x80000000
jl 0x9cb58
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)
movl $0x5, %ecx
jmp 0x9cba8
movb $-0x31, 0xf(%rsp)
jmp 0x9cb5d
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)
movl $0x9, %ecx
leaq 0xf(%rsp), %rdx
callq 0x9c85c
addq $0x18, %rsp
retq