// File: /workspace/github_c_makefile_star2_O3/CBaquero[P]random/Random.cc
// Function: RandomLUnif_RedisCommand(RedisModuleCtx*, RedisModuleString**, int)
int RandomLUnif_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
  double start, end;
  if (argc != 5) return RedisModule_WrongArity(ctx);
  if (RedisModule_StringToDouble(argv[3],&start) != REDISMODULE_OK)
    return RedisModule_ReplyWithError(ctx,"ERR invalid start");
  if (RedisModule_StringToDouble(argv[4],&end) != REDISMODULE_OK)
    return RedisModule_ReplyWithError(ctx,"ERR invalid end");

  /* Open key */
  RedisModuleKey *key = (RedisModuleKey *) RedisModule_OpenKey(ctx, argv[1], REDISMODULE_READ | REDISMODULE_WRITE);
 /* Key must be empty or list */
  if ((RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST &&
       RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_EMPTY)) 
  {
     RedisModule_CloseKey(key);
     return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
  }

  /* Get count */
  long long count;
  if ((RedisModule_StringToLongLong(argv[2],&count) != REDISMODULE_OK) ||
        (count < 0)) 
  {
     RedisModule_CloseKey(key);
     return RedisModule_ReplyWithError(ctx,"ERR invalid count");
  }

  /* Push count randoms */
  std::uniform_real_distribution<double> runif(start,end);
  while (count-- > 0)
  {
    RedisModuleString *ele;
    /* Make string with the same 19 digita precision of ReplyWithDouble */
    ele=RedisModule_CreateStringPrintf(ctx,"%.19f",runif(gen));
    RedisModule_ListPush(key,REDISMODULE_LIST_HEAD,ele);
    RedisModule_FreeString(ctx,ele);
  }
 
  size_t len = RedisModule_ValueLength(key);
  RedisModule_CloseKey(key);
  RedisModule_ReplyWithLongLong(ctx, len);
  return REDISMODULE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
cmpl $0x5, %edx
jne 0x45c1
movq %rsi, %r15
movq 0x593e(%rip), %r14      # 0x9ee0
movq 0x18(%rsi), %rdi
leaq -0x50(%rbp), %rsi
callq *(%r14)
testl %eax, %eax
je 0x45db
movq 0x57b8(%rip), %rax      # 0x9d70
leaq 0x2aef(%rip), %rsi      # 0x70ae
jmp 0x45f8
movq 0x5978(%rip), %rax      # 0x9f40
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *(%rax)
movq 0x20(%r15), %rdi
leaq -0x48(%rbp), %rsi
callq *(%r14)
testl %eax, %eax
je 0x460c
movq 0x577f(%rip), %rax      # 0x9d70
leaq 0x2ac8(%rip), %rsi      # 0x70c0
movq %rbx, %rdi
callq *(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x57f5(%rip), %rax      # 0x9e08
movq 0x8(%r15), %rsi
movq %rbx, %rdi
movl $0x3, %edx
callq *(%rax)
movq %rax, %r14
movq 0x5805(%rip), %r12      # 0x9e30
movq %rax, %rdi
callq *(%r12)
cmpl $0x2, %eax
je 0x465e
movq %r14, %rdi
callq *(%r12)
testl %eax, %eax
je 0x465e
movq 0x599f(%rip), %rax      # 0x9fe8
movq %r14, %rdi
callq *(%rax)
movq 0x571b(%rip), %rax      # 0x9d70
leaq 0x2a74(%rip), %rsi      # 0x70d0
jmp 0x45f8
movq 0x58bb(%rip), %rax      # 0x9f20
movq 0x10(%r15), %rdi
leaq -0x38(%rbp), %r15
movq %r15, %rsi
callq *(%rax)
testl %eax, %eax
setne %cl
movq (%r15), %rax
testq %rax, %rax
sets %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x46a6
movq 0x595a(%rip), %rax      # 0x9fe8
movq %r14, %rdi
callq *(%rax)
movq 0x56d6(%rip), %rax      # 0x9d70
leaq 0x2a71(%rip), %rsi      # 0x7112
jmp 0x45f8
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
subq $0x1, %rax
movq %rax, -0x38(%rbp)
jb 0x4739
movsd -0x30(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x5856(%rip), %r15      # 0x9f30
movq 0x558f(%rip), %r12      # 0x9c70
movq 0x5738(%rip), %rax      # 0x9e20
movq (%rax), %r13
movq 0x58a6(%rip), %rdi      # 0x9f98
callq 0x4180
mulsd -0x30(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movq %rbx, %rdi
leaq 0x2a19(%rip), %rsi      # 0x7124
movb $0x1, %al
callq *%r13
movq %rax, %r13
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq *(%r15)
movq %rbx, %rdi
movq %r13, %rsi
callq *(%r12)
movq -0x38(%rbp), %rax
leaq -0x1(%rax), %rcx
movq %rcx, -0x38(%rbp)
testq %rax, %rax
jg 0x46e1
movq 0x54d8(%rip), %rax      # 0x9c18
movq %r14, %rdi
callq *(%rax)
movq %rax, %r15
movq 0x5899(%rip), %rax      # 0x9fe8
movq %r14, %rdi
callq *(%rax)
movq 0x5815(%rip), %rax      # 0x9f70
movq %rbx, %rdi
movq %r15, %rsi
callq *(%rax)
xorl %eax, %eax
jmp 0x45fd