// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/scripting.c
// Function: redis_math_random
int redis_math_random (lua_State *L) {
  /* the `%' avoids the (rare) case of r==1, and is needed also because on
     some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
  lua_Number r = (lua_Number)(redisLrand48()%REDIS_LRAND48_MAX) /
                                (lua_Number)REDIS_LRAND48_MAX;
  switch (lua_gettop(L)) {  /* check number of arguments */
    case 0: {  /* no arguments */
      lua_pushnumber(L, r);  /* Number between 0 and 1 */
      break;
    }
    case 1: {  /* only upper limit */
      int u = luaL_checkint(L, 1);
      luaL_argcheck(L, 1<=u, 1, "interval is empty");
      lua_pushnumber(L, floor(r*u)+1);  /* int between 1 and `u' */
      break;
    }
    case 2: {  /* lower and upper limits */
      int l = luaL_checkint(L, 1);
      int u = luaL_checkint(L, 2);
      luaL_argcheck(L, l<=u, 2, "interval is empty");
      lua_pushnumber(L, floor(r*(u-l+1))+l);  /* int between `l' and `u' */
      break;
    }
    default: return luaL_error(L, "wrong number of arguments");
  }
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
xorl %eax, %eax
callq 0x8f090
movslq %eax, %rdx
movq %rdx, %rcx
shlq $0x1e, %rcx
addq %rcx, %rdx
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x3d, %rdx
addl %ecx, %edx
movl %edx, %ecx
shll $0x1f, %ecx
addl %edx, %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xb9026(%rip), %xmm1    # 0x143858
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0xac540
movl %eax, %ecx
movl %ecx, -0x28(%rbp)
testl %eax, %eax
je 0x8a86a
jmp 0x8a84f
movl -0x28(%rbp), %eax
subl $0x1, %eax
je 0x8a87d
jmp 0x8a859
movl -0x28(%rbp), %eax
subl $0x2, %eax
je 0x8a8f3
jmp 0x8a97a
movq -0x10(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
callq 0xad2f0
jmp 0x8a991
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xc09f0
movl %eax, -0x1c(%rbp)
movb $0x1, %al
movl $0x1, %ecx
cmpl -0x1c(%rbp), %ecx
movb %al, -0x29(%rbp)
jle 0x8a8bb
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0xb987c(%rip), %rdx     # 0x144129
callq 0xc0270
cmpl $0x0, %eax
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movsd -0x18(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x26b60
movq -0x38(%rbp), %rdi
movsd 0xacb83(%rip), %xmm1    # 0x137468
addsd %xmm1, %xmm0
callq 0xad2f0
jmp 0x8a991
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xc09f0
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0xc09f0
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %ecx
movb $0x1, %al
cmpl -0x24(%rbp), %ecx
movb %al, -0x39(%rbp)
jle 0x8a940
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0xb97f7(%rip), %rdx     # 0x144129
callq 0xc0270
cmpl $0x0, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movl -0x24(%rbp), %eax
subl -0x20(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
callq 0x26b60
movq -0x48(%rbp), %rdi
cvtsi2sdl -0x20(%rbp), %xmm1
addsd %xmm1, %xmm0
callq 0xad2f0
jmp 0x8a991
movq -0x10(%rbp), %rdi
leaq 0xb448a(%rip), %rsi     # 0x13ee0f
movb $0x0, %al
callq 0xc0370
movl %eax, -0x4(%rbp)
jmp 0x8a998
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)