// File: Shenggan[P]SnowFlake/test/../SnowFlake.h
// Function: SnowFlake::nextId()
uint64_t nextId() {
        std::unique_lock<std::mutex> lock(mutex_);
        uint64_t currStmp = getNewstmp();
        if (currStmp < lastStmp) {
            LLOG(ERRO) << "Clock moved backwards.  Refusing to generate id";
            exit(0);
        }

        if (currStmp == lastStmp) {
            sequence = (sequence + 1) & max_sequence_num_;
            if (sequence == 0) {
                currStmp = getNextMill();
            }
        } else {
            sequence = 0;
        }
        lastStmp = currStmp;
        return (currStmp - start_stmp_) << timestmp_left
                | datacenterId << datacenter_left
                | machineId << machine_left
                | sequence;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xf0(%rbp)
addq $0x20, %rsi
leaq -0x18(%rbp), %rdi
callq 0x4d80
movq -0xf0(%rbp), %rdi
callq 0x4dc0
movq %rax, -0xe8(%rbp)
jmp 0x302c
movq -0xf0(%rbp), %rcx
movq -0xe8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq 0x18(%rcx), %rax
jae 0x3209
callq 0x2b40
movq %rax, -0xf8(%rbp)
jmp 0x305a
movq -0xf8(%rbp), %rdi
callq 0x2bf0
movl %eax, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
jl 0x3202
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x23b0
movq -0x100(%rbp), %rdx
leaq 0x2fe3(%rip), %rsi      # 0x6079
leaq -0xb0(%rbp), %rdi
callq 0x2c00
jmp 0x30a4
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x23b0
movq -0x108(%rbp), %rdx
leaq 0x2fc8(%rip), %rsi      # 0x608d
leaq -0xd8(%rbp), %rdi
callq 0x2c00
jmp 0x30d3
leaq -0x90(%rbp), %rdi
movl $0x2, %esi
leaq -0xb0(%rbp), %rdx
leaq -0xd8(%rbp), %rcx
movl $0x43, %r8d
callq 0x2cb0
jmp 0x30fa
leaq 0x2f93(%rip), %rsi      # 0x6094
leaq -0x90(%rbp), %rdi
callq 0x4e10
movq %rax, -0x110(%rbp)
jmp 0x3116
callq 0x2b40
movq %rax, -0x118(%rbp)
jmp 0x3124
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdi
callq 0x32e0
jmp 0x3139
leaq -0x90(%rbp), %rdi
callq 0x3470
leaq -0xd8(%rbp), %rdi
callq 0x20e0
leaq -0xd9(%rbp), %rdi
callq 0x2250
leaq -0xb0(%rbp), %rdi
callq 0x20e0
leaq -0xb1(%rbp), %rdi
callq 0x2250
jmp 0x3202
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x32c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x31f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x31d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x31cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3470
leaq -0xd8(%rbp), %rdi
callq 0x20e0
leaq -0xd9(%rbp), %rdi
callq 0x2250
leaq -0xb0(%rbp), %rdi
callq 0x20e0
leaq -0xb1(%rbp), %rdi
callq 0x2250
jmp 0x32c9
xorl %edi, %edi
callq 0x2290
movq -0xf0(%rbp), %rcx
movq -0x20(%rbp), %rax
cmpq 0x18(%rcx), %rax
jne 0x325d
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
andq $0xfff, %rcx            # imm = 0xFFF
movq %rcx, 0x10(%rax)
cmpq $0x0, 0x10(%rax)
jne 0x325b
movq -0xf0(%rbp), %rdi
callq 0x4ef0
movq %rax, -0x120(%rbp)
jmp 0x3250
movq -0x120(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x326c
movq -0xf0(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0xf0(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rax, 0x18(%rcx)
movq -0x20(%rbp), %rax
movabsq $0x158a0cbe05f, %rdx    # imm = 0x158A0CBE05F
subq %rdx, %rax
shlq $0x16, %rax
movq (%rcx), %rdx
shlq $0x11, %rdx
orq %rdx, %rax
movq 0x8(%rcx), %rdx
shlq $0xc, %rdx
orq %rdx, %rax
orq 0x10(%rcx), %rax
movq %rax, -0x128(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x4f40
movq -0x128(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
leaq -0x18(%rbp), %rdi
callq 0x4f40
movq -0x28(%rbp), %rdi
callq 0x23a0
nopl (%rax,%rax)