// File: /workspace/github_c_makefile_star2_O0/vi[P]simple_cbor_stream_parse/scsp_cpp.cpp
// Function: scsp::Generator::writething(unsigned char, unsigned long)
void Generator::writething(uint8_t maj, uint64_t value) {
    if (value < 24) {
        uint8_t t = value | maj;
        o.write((char*)&t, 1);
    } else
    if (value < 0x100) {
        uint8_t q = value;
        uint8_t t = 0x18 | maj;
        o.write((char*)&t, 1);
        o.write((char*)&q, 1);
    } else
    if (value < 0x10000) {
        uint8_t q[2];
        q[0] = (value & 0xFF00) >> 8;
        q[1] = (value & 0x00FF) >> 0;
        uint8_t t = 0x19 | maj;
        o.write((char*)&t, 1);
        o.write((char*)&q, 2);
    } else
    if (value < 0x100000000LL) {
        uint8_t q[4];
        q[0] = (value & 0xFF000000UL) >> 24;
        q[1] = (value & 0x00FF0000UL) >> 16;
        q[2] = (value & 0x0000FF00UL) >> 8;
        q[3] = (value & 0x000000FFUL) >> 0;
        uint8_t t = 0x1A | maj;
        o.write((char*)&t, 1);
        o.write((char*)&q, 4);
    } else {
        uint8_t t = 0x1B | maj;
        o.write((char*)&t, 1);
        int i;
        for (i=0; i<8; ++i) {
            uint8_t q = (value&0xFF00000000000000ULL) >> 56;
            value<<=8;
            o.write((char*)&q, 1);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x18, -0x18(%rbp)
jae 0x26ae
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movzbl -0x9(%rbp), %edx
orq %rdx, %rcx
movb %cl, -0x19(%rbp)
movq 0x8(%rax), %rdi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
jmp 0x2871
cmpq $0x100, -0x18(%rbp)     # imm = 0x100
jae 0x26fa
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movb %cl, -0x1a(%rbp)
movzbl -0x9(%rbp), %ecx
orl $0x18, %ecx
movb %cl, -0x1b(%rbp)
movq 0x8(%rax), %rdi
leaq -0x1b(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x1a(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
jmp 0x286f
cmpq $0x10000, -0x18(%rbp)   # imm = 0x10000
jae 0x2763
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
andq $0xff00, %rcx           # imm = 0xFF00
shrq $0x8, %rcx
movb %cl, -0x1d(%rbp)
movq -0x18(%rbp), %rcx
andq $0xff, %rcx
shrq $0x0, %rcx
movb %cl, -0x1c(%rbp)
movzbl -0x9(%rbp), %ecx
orl $0x19, %ecx
movb %cl, -0x1e(%rbp)
movq 0x8(%rax), %rdi
leaq -0x1e(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x1d(%rbp), %rsi
movl $0x2, %edx
callq 0x20d0
jmp 0x286d
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, -0x18(%rbp)
jae 0x27fa
movq -0x38(%rbp), %rax
movabsq $0xff000000, %rcx       # imm = 0xFF000000
andq -0x18(%rbp), %rcx
shrq $0x18, %rcx
movb %cl, -0x22(%rbp)
movq -0x18(%rbp), %rcx
andq $0xff0000, %rcx         # imm = 0xFF0000
shrq $0x10, %rcx
movb %cl, -0x21(%rbp)
movq -0x18(%rbp), %rcx
andq $0xff00, %rcx           # imm = 0xFF00
shrq $0x8, %rcx
movb %cl, -0x20(%rbp)
movq -0x18(%rbp), %rcx
andq $0xff, %rcx
shrq $0x0, %rcx
movb %cl, -0x1f(%rbp)
movzbl -0x9(%rbp), %ecx
orl $0x1a, %ecx
movb %cl, -0x23(%rbp)
movq 0x8(%rax), %rdi
leaq -0x23(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x22(%rbp), %rsi
movl $0x4, %edx
callq 0x20d0
jmp 0x286b
movq -0x38(%rbp), %rax
movzbl -0x9(%rbp), %ecx
orl $0x1b, %ecx
movb %cl, -0x24(%rbp)
movq 0x8(%rax), %rdi
leaq -0x24(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
movl $0x0, -0x28(%rbp)
cmpl $0x8, -0x28(%rbp)
jge 0x2869
movq -0x38(%rbp), %rax
movabsq $-0x100000000000000, %rcx # imm = 0xFF00000000000000
andq -0x18(%rbp), %rcx
shrq $0x38, %rcx
movb %cl, -0x29(%rbp)
movq -0x18(%rbp), %rcx
shlq $0x8, %rcx
movq %rcx, -0x18(%rbp)
movq 0x8(%rax), %rdi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x20d0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2821
jmp 0x286b
jmp 0x286d
jmp 0x286f
jmp 0x2871
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)