#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ genrand_int32_omp(unsigned long *, int *);
unsigned int get_rand_omp(unsigned int max, unsigned int mask,
                          unsigned long *mt_r, int *mti_r) {
  unsigned int rand = (unsigned int)genrand_int32_omp(mt_r, mti_r) & mask;
  while (rand > max)
    rand = (unsigned int)genrand_int32_omp(mt_r, mti_r) & mask;
  return rand;
}


x86 assembly (clang, -O0):
<get_rand_omp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <genrand_int32_omp@plt>
and    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jbe    115d <get_rand_omp+0x4d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <genrand_int32_omp@plt>
and    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <get_rand_omp+0x29>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rand_omp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rdx,%rdi
mov    %rcx,%rsi
nopw   0x0(%rax,%rax,1)
call   1030 <genrand_int32_omp@plt>
and    %ebp,%eax
cmp    %ebx,%eax
jbe    1143 <get_rand_omp+0x33>
mov    %r15,%rdi
mov    %r14,%rsi
jmp    1130 <get_rand_omp+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_rand_omp(i32 %0, i32 %1, i64* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i64* %2, i64** %7
store i32* %3, i32** %8
%10 = load i64*, i64** %7
%11 = load i32*, i32** %8
%12 = call i64 @genrand_int32_omp(i64* %10, i32* %11)
%13 = trunc i64 %12 to i32
%14 = load i32, i32* %6
%15 = and i32 %13, %14
store i32 %15, i32* %9
br label %16
16: ; preds = %20, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %5
%19 = icmp ugt i32 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i64*, i64** %7
%22 = load i32*, i32** %8
%23 = call i64 @genrand_int32_omp(i64* %21, i32* %22)
%24 = trunc i64 %23 to i32
%25 = load i32, i32* %6
%26 = and i32 %24, %25
store i32 %26, i32* %9
br label %16
27: ; preds = %16
%28 = load i32, i32* %9
ret i32 %28
}

LLVM IR (-O2):
define i32 @get_rand_omp(i32 %0, i32 %1, i64* %2, i32* %3) {
%5 = tail call i64 @genrand_int32_omp(i64* %2, i32* %3)
%6 = trunc i64 %5 to i32
%7 = and i32 %6, %1
%8 = icmp ugt i32 %7, %0
br i1 %8, label %9, label %14
9: ; preds = %4, %9
%10 = tail call i64 @genrand_int32_omp(i64* %2, i32* %3)
%11 = trunc i64 %10 to i32
%12 = and i32 %11, %1
%13 = icmp ugt i32 %12, %0
br i1 %13, label %9, label %14
14: ; preds = %9, %4
%15 = phi i32 [ %7, %4 ], [ %12, %9 ]
ret i32 %15
}