// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lmathlib.c
// Function: math_random
static int 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)(rand()%RAND_MAX) / (lua_Number)RAND_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 */
      lua_Number u = luaL_checknumber(L, 1);
      luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty");
      lua_pushnumber(L, l_mathop(floor)(r*u) + (lua_Number)(1.0));  /* [1, u] */
      break;
    }
    case 2: {  /* lower and upper limits */
      lua_Number l = luaL_checknumber(L, 1);
      lua_Number u = luaL_checknumber(L, 2);
      luaL_argcheck(L, l <= u, 2, "interval is empty");
      lua_pushnumber(L, l_mathop(floor)(r*(u-l+1)) + l);  /* [l, u] */
      break;
    }
    default: return luaL_error(L, "wrong number of arguments");
  }
  return 1;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
callq 0x75b0
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 0x1e203(%rip), %xmm1    # 0x35f20
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x48(%rsp), %rdi
callq 0x8e20
movl %eax, %ecx
movl %ecx, 0x24(%rsp)
testl %eax, %eax
je 0x17d5a
jmp 0x17d3d
movl 0x24(%rsp), %eax
subl $0x1, %eax
je 0x17d6f
jmp 0x17d48
movl 0x24(%rsp), %eax
subl $0x2, %eax
je 0x17df8
jmp 0x17ea1
movq 0x48(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
callq 0x9e20
jmp 0x17eba
movq 0x48(%rsp), %rdi
movl $0x1, %esi
callq 0xce90
movsd %xmm0, 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movb $0x1, %al
movsd 0x1e194(%rip), %xmm1    # 0x35f28
ucomisd %xmm1, %xmm0
movb %al, 0x23(%rsp)
jae 0x17dbe
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x1e20d(%rip), %rdx     # 0x35fbc
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x23(%rsp)
movb 0x23(%rsp), %al
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
movsd 0x40(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
callq 0x74e0
movq 0x18(%rsp), %rdi
movsd 0x1e13e(%rip), %xmm1    # 0x35f28
addsd %xmm1, %xmm0
callq 0x9e20
jmp 0x17eba
movq 0x48(%rsp), %rdi
movl $0x1, %esi
callq 0xce90
movsd %xmm0, 0x30(%rsp)
movq 0x48(%rsp), %rdi
movl $0x2, %esi
callq 0xce90
movsd %xmm0, 0x28(%rsp)
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
movb $0x1, %al
ucomisd %xmm1, %xmm0
movb %al, 0x17(%rsp)
jae 0x17e5a
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x1e171(%rip), %rdx     # 0x35fbc
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movsd 0x40(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
subsd 0x30(%rsp), %xmm1
movsd 0x1e0a6(%rip), %xmm2    # 0x35f28
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
callq 0x74e0
movq 0x8(%rsp), %rdi
addsd 0x30(%rsp), %xmm0
callq 0x9e20
jmp 0x17eba
movq 0x48(%rsp), %rdi
leaq 0x1e121(%rip), %rsi     # 0x35fce
movb $0x0, %al
callq 0xc520
movl %eax, 0x54(%rsp)
jmp 0x17ec2
movl $0x1, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)