// File: halfflat[P]tinyopt/test/googletest/googletest/src/gtest.cc
// Function: testing::internal::Random::Generate(unsigned int)
uint32_t Random::Generate(uint32_t range) {
  // These constants are the same as are used in glibc's rand(3).
  // Use wider types than necessary to prevent unsigned overflow diagnostics.
  state_ = static_cast<uint32_t>(1103515245ULL * state_ + 12345U) % kMaxRange;

  GTEST_CHECK_(range > 0) << "Cannot generate a number in the range [0, 0).";
  GTEST_CHECK_(range <= kMaxRange)
      << "Generation of a number in [0, " << range << ") was requested, "
      << "but this can only generate numbers in [0, " << kMaxRange << ").";

  // Converting via modulus introduces a bit of downward bias, but
  // it's simple, and a linear congruential generator isn't too good
  // to begin with.
  return state_ % range;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl (%rax), %eax
imulq $0x41c64e6d, %rax, %rax # imm = 0x41C64E6D
addq $0x3039, %rax           # imm = 0x3039
movl $0x80000000, %ecx       # imm = 0x80000000
xorl %edx, %edx
divl %ecx
movq -0x28(%rbp), %rax
movl %edx, (%rax)
cmpl $0x0, -0xc(%rbp)
seta %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x78790
testb $0x1, %al
jne 0x803e0
jmp 0x803e2
jmp 0x8045c
leaq 0x4dcd2(%rip), %rdx     # 0xce0bb
leaq -0x10(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movl $0x3, %esi
movl $0x19a, %ecx            # imm = 0x19A
callq 0x7d880
movq -0x38(%rbp), %rdi
callq 0x1f280
movq %rax, -0x30(%rbp)
jmp 0x8040f
movq -0x30(%rbp), %rdi
leaq 0x4dd04(%rip), %rsi     # 0xce11e
callq 0x10720
movq %rax, -0x40(%rbp)
jmp 0x80425
movq -0x40(%rbp), %rdi
leaq 0x4dd0b(%rip), %rsi     # 0xce13b
callq 0x10720
jmp 0x80437
leaq -0x10(%rbp), %rdi
callq 0x7d9c0
jmp 0x8045c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x7d9c0
jmp 0x80571
cmpl $0x80000000, -0xc(%rbp) # imm = 0x80000000
setbe %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x78790
testb $0x1, %al
jne 0x80477
jmp 0x8047c
jmp 0x8055b
leaq 0x4dc38(%rip), %rdx     # 0xce0bb
leaq -0x20(%rbp), %rdi
movq %rdi, -0x50(%rbp)
movl $0x3, %esi
movl $0x19b, %ecx            # imm = 0x19B
callq 0x7d880
movq -0x50(%rbp), %rdi
callq 0x1f280
movq %rax, -0x48(%rbp)
jmp 0x804a9
movq -0x48(%rbp), %rdi
leaq 0x4dcb5(%rip), %rsi     # 0xce169
callq 0x10720
movq %rax, -0x58(%rbp)
jmp 0x804bf
movq -0x58(%rbp), %rdi
leaq 0x4dcc5(%rip), %rsi     # 0xce18f
callq 0x10720
movq %rax, -0x60(%rbp)
jmp 0x804d5
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x10b10
movq %rax, -0x68(%rbp)
jmp 0x804e7
movq -0x68(%rbp), %rdi
leaq 0x4dcbc(%rip), %rsi     # 0xce1ae
callq 0x10720
movq %rax, -0x70(%rbp)
jmp 0x804fd
movq -0x70(%rbp), %rdi
leaq 0x4dcb8(%rip), %rsi     # 0xce1c0
callq 0x10720
movq %rax, -0x78(%rbp)
jmp 0x80513
movq -0x78(%rbp), %rdi
movl $0x80000000, %esi       # imm = 0x80000000
callq 0x10b10
movq %rax, -0x80(%rbp)
jmp 0x80527
movq -0x80(%rbp), %rdi
leaq 0x4dc34(%rip), %rsi     # 0xce166
callq 0x10720
jmp 0x80539
leaq -0x20(%rbp), %rdi
callq 0x7d9c0
jmp 0x8055b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x7d9c0
jmp 0x80571
movq -0x28(%rbp), %rax
movl (%rax), %eax
xorl %edx, %edx
divl -0xc(%rbp)
movl %edx, %eax
addq $0x80, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x10e00
nopw (%rax,%rax)