// File: /workspace/github_c_makefile_star2_O3/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 0x99512
cmpq $0x7f, %rdx
jbe 0x99518
cmpq $0xff, %rdx
ja 0x9953f
movb $-0x34, 0xf(%rsp)
jmp 0x99531
cmpq $-0x20, %rdx
jb 0x99526
movb %dl, 0xf(%rsp)
movl $0x1, %ecx
jmp 0x99626
cmpq $-0x80, %rdx
jb 0x9954f
movb $-0x30, 0xf(%rsp)
movb %dl, 0x10(%rsp)
movl $0x2, %ecx
jmp 0x99626
cmpq $0xffff, %rdx           # imm = 0xFFFF
ja 0x9956f
movb $-0x33, 0xf(%rsp)
jmp 0x9955d
cmpq $-0x8000, %rdx          # imm = 0x8000
jb 0x9957f
movb $-0x2f, 0xf(%rsp)
movb %dh, 0x10(%rsp)
movb %dl, 0x11(%rsp)
movl $0x3, %ecx
jmp 0x99626
movq %rdx, %rax
shrq $0x20, %rax
jne 0x995ae
movb $-0x32, 0xf(%rsp)
jmp 0x9958d
cmpq $-0x80000000, %rdx      # imm = 0x80000000
jb 0x995d6
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 0x99626
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 0x99603
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 0x992c4
addq $0x18, %rsp
retq